Import modules from package and append into sys.modules

    :param package: full package name, e.g. east.asts
508285
def import_modules_from_package(package):
    
    path = [os.path.dirname(__file__), '..'] + package.split('.')
    path = os.path.join(*path)
    for root, dirs, files in os.walk(path):
        for filename in files:
            if filename.startswith('__') or not filename.endswith('.py'):
                continue
            new_package = ".".join(root.split(os.sep)).split("....")[1]
            module_name = '%s.%s' % (new_package, filename[:-3])
            if module_name not in sys.modules:
                __import__(module_name)
622618
def touch_import(package, name, node):
    
    def is_import_stmt(node):
        return (node.type == syms.simple_stmt and node.children and
                is_import(node.children[0]))

    root = find_root(node)

    if does_tree_import(package, name, root):
        return

    # figure out where to insert the new import.  First try to find
    # the first import and then skip to the last one.
    insert_pos = offset = 0
    for idx, node in enumerate(root.children):
        if not is_import_stmt(node):
            continue
        for offset, node2 in enumerate(root.children[idx:]):
            if not is_import_stmt(node2):
                break
        insert_pos = idx + offset
        break

    # if there are no imports where we can insert, find the docstring.
    # if that also fails, we stick to the beginning of the file
    if insert_pos == 0:
        for idx, node in enumerate(root.children):
            if (node.type == syms.simple_stmt and node.children and
               node.children[0].type == token.STRING):
                insert_pos = idx + 1
                break

    if package is None:
        import_ = Node(syms.import_name, [
            Leaf(token.NAME, u"import"),
            Leaf(token.NAME, name, prefix=u" ")
        ])
    else:
        import_ = FromImport(package, [Leaf(token.NAME, name, prefix=u" ")])

    children = [import_, Newline()]
    root.insert_child(insert_pos, Node(syms.simple_stmt, children))
683070
def load_module(name, globals_dict=None, symb_list=None):
    
    _load("scapy.modules." + name,
          globals_dict=globals_dict, symb_list=symb_list)
1212518
def load_module(self, name):
        
        if name not in sys.modules:
            sys.modules[name] = getattr(maps, name.split('.')[2])
        return sys.modules[name]
847325
def import_all_modules(package, skip=None, verbose=False, prefix="", depth=0):
    

    skip = [] if skip is None else skip

    for ff, modname, ispkg in pkgutil.walk_packages(path=package.__path__,
                                                prefix=prefix,
                                                onerror=lambda x: None):
        if ff.path not in package.__path__[0]: # Solves weird bug
            continue
        if verbose:
            print('\t'*depth,modname)
        if modname in skip:
            if verbose:
                print('\t'*depth,'*Skipping*')
            continue
        module = '%s.%s' % (package.__name__,modname)
        subpackage = importlib.import_module(module)
        if ispkg:
            import_all_modules(subpackage, skip=skip,
                               verbose=verbose,depth=depth+1)
506702
def resize(self, package):
        
        if isinstance(package, dict):
            package = package['name']
        action = {'action': 'resize',
                  'package': package}
        j, r = self.datacenter.request('POST', self.path, params=action)
        r.raise_for_status()
543342
def _package_path(package):
    
    from os import path
    confdir = config_dir()
    return path.join(confdir, "{}.cfg".format(package))
165042
public void addExportedPackages(Set<String> packages) {
		String s = (String) getMainAttributes().get(EXPORT_PACKAGE);
		Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
		String result = mergeIntoCommaSeparatedList(s, packages, modified, lineDelimiter);
		this.modified = modified.get();
		getMainAttributes().put(EXPORT_PACKAGE, result);
	}
772310
def unpackage(package_):
    '''
    
    '''
    return salt.utils.msgpack.loads(package_, use_list=True,
                                    _msgpack_module=msgpack)
560011
def importfile(filename):
    
    pkg = packageFromPath(filename, includeModule=True)
    root = packageRootPath(filename)

    if root not in sys.path:
        sys.path.insert(0, root)

    __import__(pkg)
    return sys.modules[pkg]
850366
def load_decorate(package):
    
    # We import the decoration logic from acorn and then overwrite the sys.module
    # for this package with the decorated, original pandas package.
    from acorn.logging.decoration import set_decorating, decorating
    
    #Before we do any imports, we need to set that we are decorating so that
    #everything works as if `acorn` wasn't even here.
    origdecor = decorating
    set_decorating(True)

    #If we try and import the module directly, we will get stuck in a loop; at
    #some point we must invoke the built-in module loader from python. We do
    #this by removing our sys.path hook.
    import sys    
    from importlib import import_module
    apack = import_module(package)    
    from acorn.logging.decoration import decorate
    decorate(apack)

    sys.modules["acorn.{}".format(package)] = apack

    #Set the decoration back to what it was.
    from acorn.logging.decoration import set_decorating
    set_decorating(origdecor)
    
    return apack
280033
def import_module(modulename):
    
    module = None
    try:
        module = importlib.import_module(modulename)
    except ImportError:
        # If importing fails we see if the modulename has dots in it, split the name.
        if "." in modulename:
            modules = modulename.split(".")
            package = ".".join(modules[1:len(modules)])
            # Might raise an ImportError again. If so, we really failed to import the module.
            module = importlib.import_module(package)
        else:
            # No dots, really unable to import the module. Raise.
            raise
    return module
586535
def add_packages(self, packages):
        
        # type: (List[str])->TaskNamespace
        assert isinstance(packages, list), "Packages must be list of strings."
        self._task_packages += packages
        return self
1099878
def _import_module(module_name):
    
    fromlist = []
    dot_position = module_name.rfind('.')
    if dot_position > -1:
        fromlist.append(
            module_name[dot_position+1:len(module_name)]
        )

    # Import module
    module = __import__(module_name, globals(), locals(), fromlist, 0)

    return module
456467
def collect(package='perch.migrations'):
    
    package = importlib.import_module(package)

    for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
        importlib.import_module(package.__name__ + '.' + name)

    return _migrations
1164744
def load_code(self, path, package, callwith):
        '''
        
        '''
        sys.path = [path] + sys.path
        g_o = importlib.import_module(package).get_objects
        del sys.path[0]
        for obj in g_o(callwith):
            self.code[obj.title.lower()] = obj
174470
def _import_module(name, package='vlfd', warn=True, prefix='_py_', ignore='_'):
    
    import warnings
    from importlib import import_module
    try:
        try:
            module = import_module(name)
        except ImportError:
            module = import_module('.' + name, package=package)
    except ImportError:
        if warn:
            warnings.warn("failed to import module %s" % name)
    else:
        for attr in dir(module):
            if ignore and attr.startswith(ignore):
                continue
            if prefix:
                if attr in globals():
                    globals()[prefix + attr] = globals()[attr]
                elif warn:
                    warnings.warn("no Python implementation of " + attr)
            globals()[attr] = getattr(module, attr)
        return True