Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(3)  |  Derive(0)  |  Import(3)

        def relimport(module_path, current_module_filename, path_to_package, from_=None):
    log.debug(
        "Requesting module path: %r, "
        "current file: %r, path to package root: %r",
        module_path,
        current_module_filename,
        path_to_package
    )
    if not module_path.startswith('.'):
        raise ValueError('The module path %r is not a relative path'%module_path)
    if not path_to_package.startswith('.'):
        raise ValueError('The path to package %r is not a relative path from the importing file'%path_to_package)
    if '/' in module_path:
        raise ValueError("Shouldn't have a / character in the module path")
    if '\\' in module_path:
        raise ValueError("Shouldn't have a \ character in the module path")

    # Find the module path of the module to import
    up, new_rel_mod_path =  how_many_levels_up(module_path)
    if up == 1 and new_rel_mod_path == '':
        path_to_package = path_to_package.strip('/')[:-2]
    package_directory = dir_containing_package_root(path_to_package, current_module_filename)
    up, current_abs_module_path = module_path_of_current_module(current_module_filename, package_directory, up)
    new_abs_mod_path = abs_mod_path(current_abs_module_path, up, new_rel_mod_path)
    module_to_import, directory_containing_module = adjust_path_for_imp(new_abs_mod_path, package_directory)

    __import__(new_abs_mod_path, {}, {})
    mod = sys.modules[new_abs_mod_path]
    return handle_from_clause(mod, from_)
        


src/d/a/dataproxy-0.1.0/dataproxy/bn/relimport_test.py   dataproxy(Download)
from bn import relimport
 
absimport = relimport(
    '.',
    __file__,

src/d/a/dataproxy-HEAD/dataproxy/bn/relimport_test.py   dataproxy(Download)
from bn import relimport
 
absimport = relimport(
    '.',
    __file__,

src/b/a/BareNecessities-0.2.8/bn/relimport_test.py   BareNecessities(Download)
from bn import relimport
 
absimport = relimport(
    '.',
    __file__,