Attempt to import a Python module located at path.  If
    successful, and if the newly imported module has an init()
    function, then set the global PATH in order to simplify the
    add_bundle() interface and call init() on the module, passing the
    current global namespace, conveniently converted into a DictObj so
    that it can be accessed with normal module style dot notation
    instead of as a dict.

    http://stackoverflow.com/questions/990422/how-to-get-a-reference-to-current-modules-attributes-in-python

def init_module(path):

    """Attempt to import a Python module located at path.  If
    successful, and if the newly imported module has an init()
    function, then set the global PATH in order to simplify the
    add_bundle() interface and call init() on the module, passing the
    current global namespace, conveniently converted into a DictObj so
    that it can be accessed with normal module style dot notation
    instead of as a dict.

    http://stackoverflow.com/questions/990422/how-to-get-a-reference-to-current-modules-attributes-in-python"""

    mod = import_by_path(path)
    if mod is not None and hasattr(mod, 'init'):
        logger.debug('calling init on {0}'.format(mod))
        global PATH
        PATH = path
        mod.init(DictObj(globals()))