# Path: moult/classes.py
# class PyModule(object):
#     def __init__(self, name, version, location='', missing=False):
#         self.name = name
#         self.import_names = [name]
#         self.version = version
#         self.is_scan = version in ('SCRIPT', 'MODULE', 'DIRECTORY')
#         self.frameworks = []
#         self.location = location
#         self._dependencies = []  # The string list of dependencies
#         self.dependencies = []
#         self.dependants = []
#         self._dependants = []  # This is a shadow dependant list for the turtles
#         self.installed_scripts = []
#         self.installed_files = []
#         self.user = False
#         self.local = False
#         self.hidden = False
#         self.missing = missing
# 
#     def set_import_names(self, names):
#         self.import_names = [x.replace('/', '.') for x in names]
# 
#     def add_framework(self, framework):
#         if framework not in self.frameworks:
#             self.frameworks.append(framework)
# 
#     def add_dependency(self, dep):
#         if dep not in self.dependencies:
#             if dep.is_scan:
#                 self.dependencies.insert(0, dep)
#             else:
#                 self.dependencies.append(dep)
# 
#     def remove_dependency(self, dep):
#         if dep in self.dependencies:
#             self.dependencies.remove(dep)
# 
#     def add_dependant(self, dep):
#         if dep not in self.dependants:
#             if dep.is_scan:
#                 self.dependants.insert(0, dep)
#                 self._dependants.insert(0, dep)
#             else:
#                 self.dependants.append(dep)
#                 self._dependants.append(dep)
# 
#     def remove_dependant(self, dep):
#         if dep in self._dependants:
#             self._dependants.remove(dep)
# 
#     def restore_dependants(self):
#         self._dependants = self.dependants[:]
# 
#     def __hash__(self):
#         return hash((self.name, self.version))
# 
#     def __unicode__(self):
#         if self.is_scan:
#             fmt = '{name} [{version}]'
#         else:
#             fmt = '{name} ({version})'
#         return fmt.format(name=self.name, version=self.version)
# 
#     def __str__(self):
#         if PY3:
#             return self.__unicode__()
#         return self.__unicode__().encode('utf8')
# 
#     def __bytes__(self):
#         return self.__unicode__().encode('utf8')
# 
#     def __repr__(self):
#         r = '<PyModule {}>'.format(self.__unicode__())
#         if PY3:
#             return r
#         return r.encode('utf8')
# 
# Path: moult/compat.py
# PY3 = sys.version_info[0] == 3


import os
import re
import sys
from .classes import PyModule
from .pip_importer import *
from .compat import str_

    for dist in get_installed_distributions(local_only=local):
        pym = PyModule(dist.project_name, dist.version, dist.location)
        if dist.has_metadata('top_level.txt'):
            pym.set_import_names(list(dist.get_metadata_lines('top_level.txt')))

        pym.local = dist_is_local(dist)
        pym.user = dist_in_usersite(dist)
        pym._dependencies = [dep.project_name for dep in dist.requires()]

        for filename in iter_dist_files(dist):
            if not filename.startswith(dist.location):
                if is_script(filename):
                    pym.installed_scripts.append(filename)
                else:
                    pym.installed_files.append(filename)

        if pym.installed_scripts or pym.name in ignore_packages:
            pym.hidden = True

        installed.append(pym)

    for pym in installed[:]:
        for dep in pym._dependencies:
            if dep == 'argparse':
                # Since I'm only testing with Python 2.7, skip any requirements
                # for argparse.
                continue
            pymc = find_package(dep, installed, True)
            if not pymc:

# Path: moult/classes.py
# class PyModule(object):
#     def __init__(self, name, version, location='', missing=False):
#         self.name = name
#         self.import_names = [name]
#         self.version = version
#         self.is_scan = version in ('SCRIPT', 'MODULE', 'DIRECTORY')
#         self.frameworks = []
#         self.location = location
#         self._dependencies = []  # The string list of dependencies
#         self.dependencies = []
#         self.dependants = []
#         self._dependants = []  # This is a shadow dependant list for the turtles
#         self.installed_scripts = []
#         self.installed_files = []
#         self.user = False
#         self.local = False
#         self.hidden = False
#         self.missing = missing
# 
#     def set_import_names(self, names):
#         self.import_names = [x.replace('/', '.') for x in names]
# 
#     def add_framework(self, framework):
#         if framework not in self.frameworks:
#             self.frameworks.append(framework)
# 
#     def add_dependency(self, dep):
#         if dep not in self.dependencies:
#             if dep.is_scan:
#                 self.dependencies.insert(0, dep)
#             else:
#                 self.dependencies.append(dep)
# 
#     def remove_dependency(self, dep):
#         if dep in self.dependencies:
#             self.dependencies.remove(dep)
# 
#     def add_dependant(self, dep):
#         if dep not in self.dependants:
#             if dep.is_scan:
#                 self.dependants.insert(0, dep)
#                 self._dependants.insert(0, dep)
#             else:
#                 self.dependants.append(dep)
#                 self._dependants.append(dep)
# 
#     def remove_dependant(self, dep):
#         if dep in self._dependants:
#             self._dependants.remove(dep)
# 
#     def restore_dependants(self):
#         self._dependants = self.dependants[:]
# 
#     def __hash__(self):
#         return hash((self.name, self.version))
# 
#     def __unicode__(self):
#         if self.is_scan:
#             fmt = '{name} [{version}]'
#         else:
#             fmt = '{name} ({version})'
#         return fmt.format(name=self.name, version=self.version)
# 
#     def __str__(self):
#         if PY3:
#             return self.__unicode__()
#         return self.__unicode__().encode('utf8')
# 
#     def __bytes__(self):
#         return self.__unicode__().encode('utf8')
# 
#     def __repr__(self):
#         r = '<PyModule {}>'.format(self.__unicode__())
#         if PY3:
#             return r
#         return r.encode('utf8')
# 
# Path: moult/compat.py
# PY3 = sys.version_info[0] == 3


# Path: moult/utils.py
import os
import re
import sys
from .classes import PyModule
from .pip_importer import *
from .compat import str_


    for dist in get_installed_distributions(local_only=local):
        pym = PyModule(dist.project_name, dist.version, dist.location)
        if dist.has_metadata('top_level.txt'):
            pym.set_import_names(list(dist.get_metadata_lines('top_level.txt')))

        pym.local = dist_is_local(dist)
        pym.user = dist_in_usersite(dist)
        pym._dependencies = [dep.project_name for dep in dist.requires()]

        for filename in iter_dist_files(dist):
            if not filename.startswith(dist.location):
                if is_script(filename):
                    pym.installed_scripts.append(filename)
                else:
                    pym.installed_files.append(filename)

        if pym.installed_scripts or pym.name in ignore_packages:
            pym.hidden = True

        installed.append(pym)

    for pym in installed[:]:
        for dep in pym._dependencies:
            if dep == 'argparse':
                # Since I'm only testing with Python 2.7, skip any requirements
                # for argparse.
                continue
            pymc = find_package(dep, installed, True)
            if not pymc:

                pymc = PyModule(dep, 'MISSING', missing=True)