Extracts all the subroutine and function definitions from the specified module.
169958
def parse(self, module):
        """"""
        #Because of embedded types, we have to examine the entire module for
        #executable definitions.
        self.parse_block(module.refstring, module, module, 0)

        #Now we can set the value of module.contains as the text after the start of
        #the *first* non-embedded executable.
        min_start = len(module.refstring)
        for x in module.executables:
            if module.executables[x].start < min_start:
                min_start = module.executables[x].start

        module.contains = module.refstring[min_start::]
841294
def extract_func_data(self, func):
        
        code = func.__code__

        # extract all global ref's
        func_global_refs = self.extract_code_globals(code)

        # process all variables referenced by global environment
        f_globals = {}
        for var in func_global_refs:
            if var in func.__globals__:
                f_globals[var] = func.__globals__[var]

        # defaults requires no processing
        defaults = func.__defaults__

        # process closure
        closure = (
            list(map(_get_cell_contents, func.__closure__))
            if func.__closure__ is not None
            else None
        )

        # save the dict
        dct = func.__dict__

        base_globals = self.globals_ref.get(id(func.__globals__), None)
        if base_globals is None:
            # For functions defined in a well behaved module use
            # vars(func.__module__) for base_globals. This is necessary to
            # share the global variables across multiple pickled functions from
            # this module.
            if hasattr(func, '__module__') and func.__module__ is not None:
                base_globals = func.__module__
            else:
                base_globals = {}
        self.globals_ref[id(func.__globals__)] = base_globals

        return (code, f_globals, defaults, closure, dct, base_globals)
938331
def module2md(self, module):
        
        modname = module.__name__
        path = self.get_src_path(module, append_base=False)
        path = "[{}]({})".format(path, os.path.join(self.github_link, path))
        found = set()

        classes = []
        line_nos = []
        for name, obj in getmembers(module, inspect.isclass):
            # handle classes
            found.add(name)
            if not name.startswith("_") and hasattr(obj, "__module__") and obj.__module__ == modname:
                classes.append(self.class2md(obj))
                line_nos.append(self.get_line_no(obj) or 0)
        classes = order_by_line_nos(classes, line_nos)

        # Since functions can have multiple aliases.
        func2names = defaultdict(list)
        for name, obj in getmembers(module, inspect.isfunction):
            func2names[obj].append(name)

        functions = []
        line_nos = []
        for obj in func2names:
            names = func2names[obj]
            found.update(names)

            # Include if within module or included modules within __init__.py and exclude from global variables
            is_module_within_init = '__init__.py' in path and obj.__module__.startswith(modname)
            if is_module_within_init:
                found.add(obj.__module__.replace(modname + '.', ''))

            if hasattr(obj, "__module__") and (obj.__module__ == modname or is_module_within_init):
                names = list(filter(lambda name: not name.startswith("_"), names))
                if len(names) > 0:
                    functions.append(self.func2md(obj, names=names))
                    line_nos.append(self.get_line_no(obj) or 0)
        functions = order_by_line_nos(functions, line_nos)

        variables = []
        line_nos = []
        for name, obj in module.__dict__.items():
            if not name.startswith("_") and name not in found:
                if hasattr(obj, "__module__") and obj.__module__ != modname:
                    continue
                if hasattr(obj, "__name__") and not obj.__name__.startswith(modname):
                    continue

                comments = inspect.getcomments(obj)
                comments = ": %s" % comments if comments else ""
                variables.append("- **%s**%s" % (name, comments))
                line_nos.append(self.get_line_no(obj) or 0)

        variables = order_by_line_nos(variables, line_nos)
        if variables:
            new_list = ["**Global Variables**", "---------------"]
            new_list.extend(variables)
            variables = new_list

        string = MODULE_TEMPLATE.format(path=path,
                                        global_vars="\n".join(variables) if variables else "",
                                        functions="\n".join(functions) if functions else "",
                                        classes="".join(classes) if classes else "")
        return string
655718
def import_submodules(package_name, *submodules):
    """"""
    package = sys.modules[package_name]
    return {
        name: importlib.import_module(package_name + '.' + name)
        for _, name, _ in pkgutil.walk_packages(package.__path__)
        if not submodules or name in submodules
    }
850296
function getSubmodules(packageRoot) {
  const submodules = {};
  const parentPath = resolve(packageRoot, './modules');

  if (fs.existsSync(parentPath)) {
    //monorepo
    fs.readdirSync(parentPath)
    .forEach(item => {
      const itemPath = resolve(parentPath, item);
      const moduleInfo = getModuleInfo(itemPath);
      if (moduleInfo) {
        submodules[moduleInfo.name] = moduleInfo;
      }
    });
  } else {
    const moduleInfo = getModuleInfo(packageRoot);
    submodules[moduleInfo.name] = moduleInfo;
  }

  return submodules;
}
323798
def modpath_all(module, entry_point):
    

    module_paths = getattr(module, '__path__', [])
    if not module_paths:
        logger.warning(
            "module '%s' does not appear to be a namespace module or does not "
            "export available paths onto the filesystem; JavaScript source "
            "files cannot be extracted from this module.", module.__name__
        )
    return module_paths
323947
def extract_conf_from(mod, conf=ModuleConfig(CONF_SPEC), depth=0, max_depth=2):
    

    # extract config keys from module or object
    for key, default_value in six.iteritems(conf):
        conf[key] = _get_key_from_module(mod, key, default_value)

    # support for recursive dependecies
    try:
        filtered_apps = [app for app in conf['apps'] if app not in BLACKLIST]
    except TypeError:
        pass
    except Exception as e:
        warnings.warn('Error %s during loading %s' % (e, conf['apps']))

    for app in filtered_apps:
        try:
            app_module = import_module(app)
            if app_module != mod:
                app_module = _get_correct_module(app_module)
                if depth < max_depth:
                    mod_conf = extract_conf_from(app_module, depth=depth+1)
                    for k, v in six.iteritems(mod_conf):
                        # prevent config duplicity
                        # skip config merge
                        if k == 'config':
                            continue
                        if isinstance(v, dict):
                            conf[k].update(v)
                        elif isinstance(v, (list, tuple)):
                            conf[k] = merge(conf[k], v)
        except Exception as e:
            pass  # swallow, but maybe log for info what happens
    return conf
1318823
def in_function_call(self):
        """"""
        #See if we are calling a function inside a module or other function.
        result = []
        if (self.context.el_section == "body" and
            self.context.el_call in [ "sub", "fun" ]):
            #Do a signature completion for the function/subroutine call.
            result = self.signature()

        if result == []:
            return self.complete()

        return result
27441
def get_submodule_list(package_path: str) -> Tuple[ModuleDescription, ...]:
    """"""
    pkg = importlib.import_module(package_path)

    subs = (
        ModuleDescription(
            name=modname,
            path="{}.{}".format(package_path, modname), is_package=ispkg
        )
        for importer, modname, ispkg in pkgutil.iter_modules(pkg.__path__)
    )
    result = tuple(subs)
    return result
1000592
def _get_module(self, line):
        """"""
        #Finding the module name is trivial; start at the beginning of
        #the module and iterate lines until we find the module.
        for sline in self._source:
            if len(sline) > 0 and sline[0] != "!":
                rmatch = self.RE_MODULE.match(sline)
                if rmatch is not None:
                    self.modulename = rmatch.group("name")
                    break
        else:
            #We don't even have the start of a module in this code file
            return
            
        #Before we carry on with the rest of the context, find the separating
        #CONTAINS keyword so we know whether to look for types or subs/funcs.
        #If the code parser hasn't ever parsed this module, parse it now.
        self.parser.isense_parse(self._orig_path, self.modulename)
        self.module = self.parser.modules[self.modulename]

        if line > self.module.contains_index:
            self.section = "contains"
364064
def _generic_filter_execs(self, module):
        
        interface_execs = []
        for ikey in module.interfaces:
            interface_execs.extend(module.interfaces[ikey].procedures)

        return {k: module.executables[k] for k in module.executables if 
                ("{}.{}".format(module.name, k) not in interface_execs and 
                 not module.executables[k].is_type_target)}
397667
def load_from_module(self, module):
        ''''''
        benchmarks = []
        for name in dir(module):
            obj = getattr(module, name)
            if (inspect.isclass(obj) and issubclass(obj, Benchmark)
                    and obj != Benchmark):
                benchmarks.append(obj)
        return benchmarks
1273090
def __extract_modules(self, loader, name, is_pkg):

        
        mod = loader.find_module(name).load_module(name)

        """ find the attribute method on each module """
        if hasattr(mod, '__method__'):

            """ register to the blueprint if method attribute found """
            module_router = ModuleRouter(mod,
                                         ignore_names=self.__serialize_module_paths()
                                         ).register_route(app=self.application, name=name)

            self.__routers.extend(module_router.routers)
            self.__modules.append(mod)

        else:
            """ prompt not found notification """
            # print('{} has no module attribute method'.format(mod))
            pass
721533
def list_submodules(module_name: str) -> List[str]:   # pylint: disable=invalid-sequence-index
    
    _module = importlib.import_module(module_name)
    return [module_name+'.'+submodule_name for _, submodule_name, _ in pkgutil.iter_modules(_module.__path__)]
184010
def module_function(string):
    
    parts = string.split(':', 2)
    if len(parts) < 2:
        raise ValueError(
            "Illegal specification. Should be module:function[:parameter]")
    module_path, function_name = parts[:2]

    # Import the module
    module_vars = {}
    exec(compile(open(module_path).read(), module_path, 'exec'), module_vars)

    try:
        function = module_vars[function_name]
    except KeyError:
        raise argparse.ArgumentTypeError("{0} has no attribute '{1}'".format(
            module_path, function_name))

    if len(parts) == 3:
        old_function = function
        function = lambda r: old_function(r, parts[2])

    return function
1070144
def modules(self):
        """"""
        defmodule = lib.EnvGetNextDefmodule(self._env, ffi.NULL)

        while defmodule != ffi.NULL:
            yield Module(self._env, defmodule)

            defmodule = lib.EnvGetNextDefmodule(self._env, defmodule)
306960
function getModuleDefinitions(modules) {
      return modules.split(',').map(function(md) {
        var split = md.split(':'), name, path, type;
        name = split[0];
        path = './' + name.toLowerCase();
        if (name === 'Locales') {
          type = 'locales';
        } else if (moduleIsPolyfill(name)) {
          type = 'polyfill';
        } else {
          type = 'module';
        }
        return {
          name: name,
          path: path,
          type: type,
          namespace: split[1]
        };
      });
    }