Generate global name cache for modules listed in `modules`
767219
def generate_modules_cache(self, modules, underlined=None,
                               task_handle=taskhandle.NullTaskHandle()):
        """"""
        job_set = task_handle.create_jobset(
            'Generatig autoimport cache for modules', len(modules))
        for modname in modules:
            job_set.started_job('Working on <%s>' % modname)
            if modname.endswith('.*'):
                mod = self.project.find_module(modname[:-2])
                if mod:
                    for sub in submodules(mod):
                        self.update_resource(sub, underlined)
            else:
                self.update_module(modname, underlined)
            job_set.finished_job()
72319
function (options, iterationInfo, modules) {
        // filename filter
        if (options.fileNameFilter) {
            var match = iterationInfo.fileName.match(options.fileNameFilter);
            if (!match) {
                return;
            }
        }

        // Filter spec.js files
        var match = iterationInfo.fileName.match(/.spec.js/i);
        if (match) {
            return;
        }

        // relative path filter
        if (options.relativePathFilter) {
            var pathMatch = iterationInfo.relativeFullPath.match(options.relativePathFilter);
            if (!pathMatch)
                return;
        }

        //load module
        loadModule(modules, options, iterationInfo);
    }
56999
function getModuleMetadata(programPath) {
    const localData = getLocalExportMetadata(programPath);

    const sourceData = new Map();
    const getData = sourceNode => {
        const source = sourceNode.value;

        let data = sourceData.get(source);
        if (!data) {
            data = {
                name: programPath.scope.generateUidIdentifier(
                    basename(source, extname(source))
                ).name,

                interop: 'none',

                loc: null,

                // Data about the requested sources and names.
                imports: new Map(),
                // importsNamespace: import * as util from './a/b/util';
                importsNamespace: new Set(),

                // Metadata about data that is passed directly from source to export.
                reexports: new Map(),
                reexportNamespace: new Set(),
                reexportAll: null,
            };
            sourceData.set(source, data);
        }
        return data;
    };

    programPath.get('body').forEach(child => {
        if (child.isImportDeclaration()) {
            const data = getData(child.node.source);
            if (!data.loc) {
                data.loc = child.node.loc;
            }

            child.get('specifiers').forEach(spec => {
                if (spec.isImportDefaultSpecifier()) {
                    const localName = spec.get('local').node.name;

                    data.imports.set(localName, 'default');

                    const reexport = localData.get(localName);
                    if (reexport) {
                        localData.delete(localName);

                        reexport.names.forEach(name => {
                            data.reexports.set(name, 'default');
                        });
                    }
                }
                else if (spec.isImportNamespaceSpecifier()) {
                    const localName = spec.get('local').node.name;

                    assert(
                        data.importsNamespace.size === 0,
                        `Duplicate import namespace: ${localName}`
                    );
                    data.importsNamespace.add(localName);

                    const reexport = localData.get(localName);
                    if (reexport) {
                        localData.delete(localName);

                        reexport.names.forEach(name => {
                            data.reexportNamespace.add(name);
                        });
                    }
                }
                else if (spec.isImportSpecifier()) {
                    const importName = spec.get('imported').node.name;
                    const localName = spec.get('local').node.name;

                    data.imports.set(localName, importName);

                    const reexport = localData.get(localName);
                    if (reexport) {
                        localData.delete(localName);

                        reexport.names.forEach(name => {
                            data.reexports.set(name, importName);
                        });
                    }
                }
            });
        }
        else if (child.isExportAllDeclaration()) {
            const data = getData(child.node.source);
            if (!data.loc) {
                data.loc = child.node.loc;
            }

            data.reexportAll = {
                loc: child.node.loc,
            };
        }
        else if (child.isExportNamedDeclaration() && child.node.source) {
            const data = getData(child.node.source);
            if (!data.loc) {
                data.loc = child.node.loc;
            }

            child.get('specifiers').forEach(spec => {
                if (!spec.isExportSpecifier()) {
                    throw spec.buildCodeFrameError('Unexpected export specifier type');
                }
                const importName = spec.get('local').node.name;
                const exportName = spec.get('exported').node.name;

                data.reexports.set(exportName, importName);

                if (exportName === '__esModule') {
                    throw exportName.buildCodeFrameError('Illegal export "__esModule".');
                }
            });
        }
    });

    for (const metadata of sourceData.values()) {
        if (metadata.importsNamespace.size > 0) {
            metadata.interop = 'namespace';
            continue;
        }
        let needsDefault = false;
        let needsNamed = false;
        for (const importName of metadata.imports.values()) {
            if (importName === 'default') {
                needsDefault = true;
            }
            else {
                needsNamed = true;
            }
        }
        for (const importName of metadata.reexports.values()) {
            if (importName === 'default') {
                needsDefault = true;
            }
            else {
                needsNamed = true;
            }
        }

        if (needsDefault && needsNamed) {
            // TODO(logan): Using the namespace interop here is unfortunate. Revisit.
            metadata.interop = 'namespace';
        }
        else if (needsDefault) {
            metadata.interop = 'default';
        }
    }

    return {
        local: localData,
        source: sourceData,
    };
}
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
781067
def external_name(self):
        """"""
        target = self.target
        if target is not None:
            return "{}.{}".format(target.name.lower(), self.name)
        else:
            return "{}.{}".format(self.module.name.lower(), self.name)
120097
function moduleDefine(exports, name, members) {
            var target = [exports];
            var publicNS = null;
            if (name) {
                publicNS = createNamespace(_Global, name);
                target.push(publicNS);
            }
            initializeProperties(target, members, name || "<ANONYMOUS>");
            return publicNS;
        }
734839
def printImportedNames(self):
        """"""
        for module in self.listModules():
            print("%s:" % module.modname)
            print("  %s" % "\n  ".join(imp.name for imp in module.imported_names))
730185
def gen_submodule_names(package):
    
    for importer, modname, ispkg in pkgutil.walk_packages(
        path=package.__path__,
        prefix=package.__name__ + '.',
            onerror=lambda x: None):
        yield modname
640129
def _import_all_modules():
    """"""
    import traceback
    import os
    global results
    globals_, locals_ = globals(), locals()

    def load_module(modulename, package_module):
        try:
            names = []
            module = __import__(package_module, globals_, locals_, [modulename])

            for name in module.__dict__:
                if not name.startswith('_'):
                    globals_[name] = module.__dict__[name]
                    names.append(name)
        except Exception:
            traceback.print_exc()
            raise

        return module, names

    def load_dir(abs_dirpath, rel_dirpath=''):
        results = []

        # dynamically import all the package modules
        for filename in os.listdir(abs_dirpath):
            rel_filepath = os.path.join(rel_dirpath, filename)
            abs_filepath = os.path.join(abs_dirpath, filename)

            if filename[0] != '_' and os.path.isfile(abs_filepath) and filename.split('.')[-1] in ('py', 'pyw'):
                modulename = '.'.join(os.path.normpath(os.path.splitext(rel_filepath)[0]).split(os.sep))
                package_module = '.'.join([__name__, modulename])

                module, names = load_module(modulename, package_module)
                results += names
            elif os.path.isdir(abs_filepath):
                results += load_dir(abs_filepath, rel_filepath)

        return results

    return load_dir(os.path.dirname(__file__))
1015615
def _module_dir(handle):
  """"""
  cache_dir = resolver.tfhub_cache_dir(use_temp=True)
  return resolver.create_local_module_dir(
      cache_dir,
      hashlib.sha1(handle.encode("utf8")).hexdigest())
1185942
def iter_distribution_names(self):
        """"""

        for pkg in self.packages or ():
            yield pkg

        for module in self.py_modules or ():
            yield module

        for ext in self.ext_modules or ():
            if isinstance(ext, tuple):
                name, buildinfo = ext
            else:
                name = ext.name
            if name.endswith('module'):
                name = name[:-6]
            yield name
1096796
def get_module_name(self, path_args):
        """"""
        controller_prefix = self.controller_prefix
        cset = self.module_names
        module_name = controller_prefix
        mod_name = module_name
        while path_args:
            mod_name += "." + path_args[0]
            if mod_name in cset:
                module_name = mod_name
                path_args.pop(0)
            else:
                break

        return module_name, path_args
16801
def index_modules(root) -> Dict:
    

    module_index_dict = {
        node["name"]: (node.get("tag"), index)
        for index, node in enumerate(root)
        if node.get("tag") in ("module", "program", "subroutine")
    }

    return module_index_dict
663771
function (runtime, modNames, refModName) {
            var ret = [], i, l;
            if (modNames) {
                // 1. index map
                for (i = 0, l = modNames.length; i < l; i++) {
                    // conditional loader
                    // requires:[window.localStorage?"local-storage":""]
                    if (modNames[i]) {
                        ret.push(pluginAlias(runtime, indexMap(modNames[i])));
                    }
                }
            }
            // 2. relative to absolute (optional)
            if (refModName) {
                ret = Utils.normalDepModuleName(refModName, ret);
            }
            return ret;
        }
14863
function (moduleName) {
            var moduleNames = Utils.unalias(S, Utils.normalizeModNamesWithAlias(S, [moduleName]));
            if (Utils.attachModsRecursively(moduleNames, S)) {
                return Utils.getModules(S, moduleNames)[1];
            }
            return undefined;
        }
164772
def named_module(name):
    """"""
    module = __import__(name)
    packages = name.split(".")[1:]
    m = module
    for p in packages:
        m = getattr(m, p)
    return m
24535
function (modNames, refModName) {
            var ret = [], i, l;
            if (modNames) {
                // 1. index map
                for (i = 0, l = modNames.length; i < l; i++) {
                    // conditional loader
                    // requires:[window.localStorage?"local-storage":""]
                    if (modNames[i]) {
                        ret.push(pluginAlias(addIndexAndRemoveJsExt(modNames[i])));
                    }
                }
            }
            // 2. relative to absolute (optional)
            if (refModName) {
                ret = Utils.normalDepModuleName(refModName, ret);
            }
            return ret;
        }