# mcedit2.util.scanmodules — mceditlib 0.1 documentation

### Navigation

- index
- modules |
- mceditlib 0.1 documentation »
- Module code »

# Source code for mcedit2.util.scanmodules

    """
        ${NAME}
    """
    from __future__ import absolute_import, division, print_function, unicode_literals
    from importlib import import_module
    import logging
    import os
    import pkgutil

    log = logging.getLogger(__name__)

    def ScanModules(modulename, path):
        log.info("Scanning %s (%s)", modulename, path)
        for _, name, _ in pkgutil.iter_modules([os.path.dirname(path)]):
            log.debug("Found %s.%s", modulename, name)
            try:
                yield import_module(modulename + "." + name)
            except ImportError as e:
                log.exception("Failed to import %s from %s (%s): %s", name, path, modulename, e)

### Navigation

- index
- modules |
- mceditlib 0.1 documentation »
- Module code »