# Path: habitat/utils/dynamicloader.py
# def load(loadable, force_reload=False):
# def fullname(loadable):
# def isclass(thing):
# def isfunction(thing):
# def isgeneratorfunction(thing):
# def issubclass(thing, the_other_thing):
# def hasattr(thing, attr):
# def isstandardfunction(thing):
# def hasnumargs(thing, num):
# def hasmethod(loadable, name):
# def iscallable(loadable):
# def _expectify(error):
#     def decorator(function):
#         def new_function(*args, **kwargs):
# 
# Path: habitat/tests/test_utils/test_dynamicloader/example_module.py
# class AClass(Parent, Parent2):
#     anattr = "asdf"
#     afunc = afunction


import sys
import os
import time
import datetime
import tempfile
import shutil
from nose.tools import raises
from ....utils import dynamicloader
from . import example_module
from .example_module import AClass
            raise ValueError("modname {0} is already in sys.modules".format(
                                 self.fullmodname))

    def write_code(self, code):
        try:
            newtime = os.path.getmtime(self.filename) + 2
        except OSError:
            newtime = int(time.time())

        with open(self.filename, 'w') as f:
            f.write(code)

        os.utime(self.filename, (newtime, newtime))


class TestLoad:
    """dynamicloader.load():"""

    def setup(self):
        """setup a tempdir for messing about in (e.g. reloadablemodulewriter);
        also use it to copy example_module.py into two other names, then put
        this folder on the path so it can be imported from."""
        self.tempdir = tempfile.mkdtemp()
        unimp_dir = os.path.join(self.tempdir, 'unimp')
        os.mkdir(unimp_dir)
        unimp_a = os.path.join(unimp_dir, 'dynamicloadunimp_a.py')
        unimp_b = os.path.join(unimp_dir, 'dynamicloadunimp_b.py')
        this_path = os.path.abspath(os.path.dirname(__file__))
        file_path = os.path.join(this_path, 'example_module.py')
        shutil.copyfile(file_path, unimp_a)

# Path: habitat/utils/dynamicloader.py
# def load(loadable, force_reload=False):
# def fullname(loadable):
# def isclass(thing):
# def isfunction(thing):
# def isgeneratorfunction(thing):
# def issubclass(thing, the_other_thing):
# def hasattr(thing, attr):
# def isstandardfunction(thing):
# def hasnumargs(thing, num):
# def hasmethod(loadable, name):
# def iscallable(loadable):
# def _expectify(error):
#     def decorator(function):
#         def new_function(*args, **kwargs):
# 
# Path: habitat/tests/test_utils/test_dynamicloader/example_module.py
# class AClass(Parent, Parent2):
#     anattr = "asdf"
#     afunc = afunction


# Path: habitat/tests/test_utils/test_dynamicloader/test_dynamicloader.py
import sys
import os
import time
import datetime
import tempfile
import shutil
from nose.tools import raises
from ....utils import dynamicloader
from . import example_module
from .example_module import AClass

            raise ValueError("modname {0} is already in sys.modules".format(
                                 self.fullmodname))

    def write_code(self, code):
        try:
            newtime = os.path.getmtime(self.filename) + 2
        except OSError:
            newtime = int(time.time())

        with open(self.filename, 'w') as f:
            f.write(code)

        os.utime(self.filename, (newtime, newtime))


class TestLoad:
    """dynamicloader.load():"""

    def setup(self):
        """setup a tempdir for messing about in (e.g. reloadablemodulewriter);
        also use it to copy example_module.py into two other names, then put
        this folder on the path so it can be imported from."""
        self.tempdir = tempfile.mkdtemp()
        unimp_dir = os.path.join(self.tempdir, 'unimp')
        os.mkdir(unimp_dir)
        unimp_a = os.path.join(unimp_dir, 'dynamicloadunimp_a.py')
        unimp_b = os.path.join(unimp_dir, 'dynamicloadunimp_b.py')
        this_path = os.path.abspath(os.path.dirname(__file__))
        file_path = os.path.join(this_path, 'example_module.py')
        shutil.copyfile(file_path, unimp_a)

        shutil.copyfile(file_path, unimp_b)