# Path: moult/log.py
# def set_level(level):
#     def emit(self, record):
# class ColorOutputHandler(logging.Handler):
# 
# Path: moult/utils.py
# def installed_packages(local=False):
#     installed = []
# 
#     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)
#                 installed.append(pymc)
#             pymc.add_dependant(pym)
#             pym.add_dependency(pymc)
# 
#     return installed


import os
import copy
import pytest
import logging
from moult import log
from moult.utils import installed_packages
from py._path.local import LocalPath





log.set_level(logging.DEBUG)


class ScriptData(object):
    def __init__(self, tmpdir):
        self.tmpdir = tmpdir
        self.tmpdata = None
        self.pristine_data = LocalPath(os.path.dirname(__file__)).join('data')
        self.installed_packages = None

    def copy_data(self):
        if self.tmpdata and self.tmpdata.exists():
            self.tmpdata.remove(ignore_errors=True)
        self.tmpdata = self.tmpdir.mkdir('data')
        self.pristine_data.copy(self.tmpdata, mode=True)

        # Can't add .git directories to the index
        git_no_scan = self.pristine_data.join('scripts/project/.hg')
        hg_no_scan = self.tmpdata.join('scripts/project/.git')
        git_no_scan.copy(hg_no_scan)


# Path: moult/log.py
# def set_level(level):
#     def emit(self, record):
# class ColorOutputHandler(logging.Handler):
# 
# Path: moult/utils.py
# def installed_packages(local=False):
#     installed = []
# 
#     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)
#                 installed.append(pymc)
#             pymc.add_dependant(pym)
#             pym.add_dependency(pymc)
# 
#     return installed


# Path: tests/conftest.py
import os
import copy
import pytest
import logging
from moult import log
from moult.utils import installed_packages
from py._path.local import LocalPath






log.set_level(logging.DEBUG)


class ScriptData(object):
    def __init__(self, tmpdir):
        self.tmpdir = tmpdir
        self.tmpdata = None
        self.pristine_data = LocalPath(os.path.dirname(__file__)).join('data')
        self.installed_packages = None

    def copy_data(self):
        if self.tmpdata and self.tmpdata.exists():
            self.tmpdata.remove(ignore_errors=True)
        self.tmpdata = self.tmpdir.mkdir('data')
        self.pristine_data.copy(self.tmpdata, mode=True)

        # Can't add .git directories to the index
        git_no_scan = self.pristine_data.join('scripts/project/.hg')
        hg_no_scan = self.tmpdata.join('scripts/project/.git')
        git_no_scan.copy(hg_no_scan)


        return self.tmpdata