# Path: sumatra/dependency_finder/core.py
# def find_versions_from_versioncontrol(dependencies):
# def find_versions(dependencies, heuristics):
# def find_file(path, current_directory, search_dirs):
#     def __init__(self, name, path=None, version='unknown', diff='', source=None):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
# class BaseDependency(object):
# 
# Path: sumatra/core.py
# def get_encoding():
#     if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
#         encoding = sys.stdout.encoding
#     else:
#         encoding = locale.getpreferredencoding()
#         if encoding == '':  # getpreferredencoding does not guarantee to return an encoding
#             encoding = sys.getdefaultencoding()
#     return encoding


from builtins import str
from modulefinder import Module
from sumatra.dependency_finder import core
from ..core import get_encoding
    from types import ModuleType
    from sumatra import programs
import os
import sys
import textwrap
import warnings
import inspect
import logging
    import textwrap
    import subprocess
    import sys
        'sentinel': SENTINEL,
    }
    script = find_versions_by_attribute_template % context
    if executable.version[0] == '2':
        script = script.replace(' as', ',')  # Python 2.5 and earlier do not have the 'as' keyword
    versions = run_script(executable.path, script)
    i = 0
    for d in dependencies:
        if d.version == 'unknown':
            d.version = versions[i]
            if d.version != 'unknown':
                d.source = "attribute"  # would be nice to pass back the attribute name
            i += 1
    return dependencies


def find_versions_from_egg(dependencies):
    """Determine whether a Python module is provided as an egg, and if so,
       obtain version information from this."""
    for dependency in dependencies:
        if dependency.version == 'unknown':
            dir = os.path.dirname(dependency.path)  # should check if dirname ends in ".egg" - may need parent directory
            if os.path.isdir(dir):
                if 'EGG-INFO' in os.listdir(dir):
                    with open(os.path.join(dir, 'EGG-INFO', 'PKG-INFO')) as f:
                        for line in f.readlines():
                            if line[:7] == 'Version':
                                dependency.version = line.split(' ')[1].strip()
                                dependency.source = 'egg-info'
                                break

# Path: sumatra/dependency_finder/core.py
# def find_versions_from_versioncontrol(dependencies):
# def find_versions(dependencies, heuristics):
# def find_file(path, current_directory, search_dirs):
#     def __init__(self, name, path=None, version='unknown', diff='', source=None):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
# class BaseDependency(object):
# 
# Path: sumatra/core.py
# def get_encoding():
#     if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
#         encoding = sys.stdout.encoding
#     else:
#         encoding = locale.getpreferredencoding()
#         if encoding == '':  # getpreferredencoding does not guarantee to return an encoding
#             encoding = sys.getdefaultencoding()
#     return encoding


# Path: sumatra/dependency_finder/python.py
from builtins import str
from modulefinder import Module
from sumatra.dependency_finder import core
from ..core import get_encoding
    from types import ModuleType
    from sumatra import programs
import os
import sys
import textwrap
import warnings
import inspect
import logging
    import textwrap
    import subprocess
    import sys

        'sentinel': SENTINEL,
    }
    script = find_versions_by_attribute_template % context
    if executable.version[0] == '2':
        script = script.replace(' as', ',')  # Python 2.5 and earlier do not have the 'as' keyword
    versions = run_script(executable.path, script)
    i = 0
    for d in dependencies:
        if d.version == 'unknown':
            d.version = versions[i]
            if d.version != 'unknown':
                d.source = "attribute"  # would be nice to pass back the attribute name
            i += 1
    return dependencies


def find_versions_from_egg(dependencies):
    """Determine whether a Python module is provided as an egg, and if so,
       obtain version information from this."""
    for dependency in dependencies:
        if dependency.version == 'unknown':
            dir = os.path.dirname(dependency.path)  # should check if dirname ends in ".egg" - may need parent directory
            if os.path.isdir(dir):
                if 'EGG-INFO' in os.listdir(dir):
                    with open(os.path.join(dir, 'EGG-INFO', 'PKG-INFO')) as f:
                        for line in f.readlines():
                            if line[:7] == 'Version':
                                dependency.version = line.split(' ')[1].strip()
                                dependency.source = 'egg-info'
                                break

    return dependencies