Iterate over modules.
439703
def _module_iterator(root, recursive=True):
    """"""
    yield root

    stack = collections.deque((root,))
    while stack:
        package = stack.popleft()
        # The '__path__' attribute of a package might return a list of paths if
        # the package is referenced as a namespace.
        paths = getattr(package, '__path__', [])
        for path in paths:
            modules = pkgutil.iter_modules([path])
            for finder, name, is_package in modules:
                module_name = '%s.%s' % (package.__name__, name)
                module = sys.modules.get(module_name, None)
                if module is None:
                    # Import the module through the finder to support package
                    # namespaces.
                    module = _load_module(finder, module_name)

                if is_package:
                    if recursive:
                        stack.append(module)
                        yield module
                else:
                    yield module
193651
def get_imported_modules(self, module):
    """"""
    for name, member in inspect.getmembers(module):
      if inspect.ismodule(member):
        yield name, member
2198
public static Module combineAndOverride(List<? extends Module> modules) {
        Iterator<? extends Module> iter = modules.iterator();
        Module current = Modules.EMPTY_MODULE;
        if (iter.hasNext()) {
            current = iter.next();
            if (iter.hasNext()) {
                current = Modules.override(current).with(iter.next());
            }
        }
        
        return current;
    }
931087
def include(modules)
      modules = Array(modules)

      modules.each { |m| self.class.include m }
    end
469464
def add_to_loaded_modules(self, modules):
        
        modules = util.return_set(modules)
        for module in modules:
            if not isinstance(module, str):
                module = module.__name__
            self.loaded_modules.add(module)
678884
def iter_settings(mixed: Settings) -> Iterator[Tuple[str, Any]]:
    
    if isinstance(mixed, types.ModuleType):
        for attr in dir(mixed):
            if not is_setting_key(attr):
                continue
            yield (attr, getattr(mixed, attr))
    else:
        yield from filter(lambda item: is_setting_key(item[0]), mixed.items())
929082
def add_module(self, module):
        '''
        
        '''
        for key, value in module.__dict__.iteritems():
            if key[0:2] != '__':
                self.__setattr__(attr=key, value=value)
589055
def classes_in_module(module) -> List:
        
        md = module.__dict__
        return [
            md[c] for c in md if (
                    isinstance(md[c], type) and
                    issubclass(md[c], ETKModule
                               ) and
                    md[c].__module__ == module.__name__)
        ]
406194
def get_module_names(p):
    '''
    '''
    mods = list()
    mods = [f.split('.')[0] for f in listdir(p)
            if isfile(join(p, f)) and not f.endswith('.pyc') and not f.startswith('__')]
    print len(mods)
    return mods
107487
def _module_parents(module_name):
        '''
        
        '''
        spl = module_name.split('.')
        for i in range(len(spl), 0, -1):
            yield '.'.join(spl[0:i])
        if module_name:
            yield ''
1020735
def iteritems(cls):
        
        for key in dir(cls):
            val = getattr(cls, key)
            if isinstance(cls, val):
                yield (key, val)
306189
def iflatten(L):
    """"""
    for sublist in L:
        if hasattr(sublist, '__iter__'):
            for item in iflatten(sublist): yield item
        else: yield sublist
205874
def iter_modules(self, module=None, filename=None, source=None, excludes=None):
    

    if excludes is None:
      excludes = self.excludes

    if not filename:
      if not module:
        raise ValueError('need either module or filename parameter')
      module = self.find_module(module)
      if not module.filename or module.type == 'native':
        return
    else:
      module = ModuleInfo('__main__', filename, ModuleInfo.SRC)

    seen = set()
    stack = collections.deque()

    for imp in get_imports(module.filename, source):
      stack.appendleft((module.join_import_from(imp.name), [module.name]))

    yield module
    while stack:
      import_name, imported_from = stack.pop()
      if import_name in seen:
        continue
      seen.add(import_name)
      if check_module_exclude(import_name, excludes):
        continue

      module = self.find_module(import_name)
      module.imported_from[:] = imported_from
      yield module

      if module.type == ModuleInfo.SRC:
        imported_from = [module.name] + imported_from
        for imp in get_imports(module.filename):
          stack.append((module.join_import_from(imp.name), imported_from))
483914
def collect_modules(self):
        """"""
        for path, dirlist, filelist in os.walk(self.root):
            for name in fnmatch.filter(filelist, self.filter):
                if self.is_git_file(path, name):
                    yield (os.path.join(path, name), [])
392091
def load_models(module):
    """"""
    modules = _import_submodules(module)
    return {m for module in modules for m in filter(
        _check_model, (getattr(module, name) for name in dir(module))
    )}
14507
def get_base_modules():
    "  "

    return sorted(filter(
                  lambda x: op.isdir(op.join(MOD_DIR, x)),
                  listdir(MOD_DIR)))
739410
function intersectModules(modulesA, modulesB) {
    const intersection = [];
    for (const module of modulesA) {
      if (modulesB.includes(module)) {
        intersection.push(module);
      }
    }
    return intersection;
  }