Ejemplo n.º 1
0
def eimport(mod, dir):
    """Import module MOD with directory DIR at the head of the search path.
    NB doesn't load from DIR if MOD shadows a system module."""
    from __main__ import __dict__

    path0 = sys.path[0]
    sys.path[0] = dir
    try:
        try:
            if __dict__.has_key(mod) and inspect.ismodule(__dict__[mod]):
                reload(__dict__[mod])
            else:
                __dict__[mod] = __import__(mod)
        except:
            (type, value, tb) = sys.exc_info()
            print "Traceback (most recent call last):"
            traceback.print_exception(type, value, tb.tb_next)
    finally:
        sys.path[0] = path0
Ejemplo n.º 2
0
def eimport (mod, dir):
    """Import module MOD with directory DIR at the head of the search path.
    NB doesn't load from DIR if MOD shadows a system module."""
    from __main__ import __dict__

    path0 = sys.path[0]
    sys.path[0] = dir
    try:
        try:
            if __dict__.has_key(mod) and inspect.ismodule (__dict__[mod]):
                reload (__dict__[mod])
            else:
                __dict__[mod] = __import__ (mod)
        except:
            (type, value, tb) = sys.exc_info ()
            print "Traceback (most recent call last):"
            traceback.print_exception (type, value, tb.tb_next)
    finally:
        sys.path[0] = path0