More robust variant of inspect.getmodule.
    E.g. has less issues on Jython.
338692
def getmodule(code):
    
    try:
        md = inspect.getmodule(code, code.co_filename)
    except AttributeError:
        return inspect.getmodule(code)
    if md is None:
        # Jython-specific:
        # This is currently just a crutch; todo: resolve __pyclasspath__ properly!
        cfname = code.co_filename.replace('__pyclasspath__',
                os.path.realpath('')+os.sep+'__pyclasspath__')
        cfname = cfname.replace('$py.class', '.py')
        md = inspect.getmodule(code, cfname)
    if md is None:
        md = inspect.getmodule(code)
    return md
595484
def get_obj_module(qualname):
    """"""
    modname = qualname
    classname = None
    attrname = None
    while modname not in sys.modules:
        attrname = classname
        modname, classname = modname.rsplit('.', 1)

    # retrieve object and find original module name
    if classname:
        cls = getattr(sys.modules[modname], classname)
        modname = cls.__module__
        obj = getattr(cls, attrname) if attrname else cls
    else:
        obj = None

    return obj, sys.modules[modname]
1371681
private List<File> locateModules() {
    File[] files = modRoot.listFiles();
    List<File> modFiles = new ArrayList<>();
    for (File file : files) {
      if (file.isDirectory()) {
        // Check to determine whether the directory is a valid module directory.
        boolean isValid = true;
        try {
          new ModuleIdentifier(file.getName());
        } catch (Exception e) {
          isValid = false;
        }

        // If the directory is a valid module name then check for a mod.json file.
        if (isValid) {
          File modJson = new File(file, MOD_JSON_FILE);
          if (modJson.exists()) {
            modFiles.add(file);
          }
        }
      }
    }
    return modFiles;
  }
1347894
function findModuleNameByInteractive() {
        var scripts = document.getElementsByTagName('script'),
            re,
            i,
            name,
            script;

        for (i = scripts.length - 1; i >= 0; i--) {
            script = scripts[i];
            if (script.readyState === 'interactive') {
                re = script;
                break;
            }
        }
        if (re) {
            name = re.getAttribute('data-mod-name');
        } else {
            // sometimes when read module file from cache,
            // interactive status is not triggered
            // module code is executed right after inserting into dom
            // i has to preserve module name before insert module script into dom,
            // then get it back here
            logger.debug('can not find interactive script,time diff : ' + (+new Date() - startLoadModTime));
            logger.debug('old_ie get mod name from cache : ' + startLoadModName);
            name = startLoadModName;
        }
        return name;
    }
411163
def get_function_source(ft, **kwargs)->str:
    ""
    try: line = inspect.getsourcelines(ft)[1]
    except Exception: return ''
    mod_path = get_module_name(ft).replace('.', '/') + '.py'
    return get_source_link(mod_path, line, **kwargs)
405996
def is_mod_class(mod, cls):
    
    return inspect.isclass(cls) and inspect.getmodule(cls) == mod
284041
public com.google.javascript.jscomp.FunctionInformationMap.ModuleOrBuilder getModuleOrBuilder(
      int index) {
    return module_.get(index);
  }
570042
def getmodule(object):
    """"""
    if ismodule(object):
        return object
    if isclass(object):
        return sys.modules.get(object.__module__)
    try:
        file = getabsfile(object)
    except TypeError:
        return None
    if modulesbyfile.has_key(file):
        return sys.modules[modulesbyfile[file]]
    for module in sys.modules.values():
        if hasattr(module, '__file__'):
            modulesbyfile[getabsfile(module)] = module.__name__
    if modulesbyfile.has_key(file):
        return sys.modules[modulesbyfile[file]]
    main = sys.modules['__main__']
    if hasattr(main, object.__name__):
        mainobject = getattr(main, object.__name__)
        if mainobject is object:
            return main
    builtin = sys.modules['__builtin__']
    if hasattr(builtin, object.__name__):
        builtinobject = getattr(builtin, object.__name__)
        if builtinobject is object:
            return builtin
981230
def get_module_path(module):
    """"""
    return pathlib.Path(
        os.path.dirname(os.path.abspath(inspect.getfile(module))))
964881
def getClassInModuleFromName(className, module):
    
    n = getAvClassNamesInModule(module)
    i = n.index(className)
    c = getAvailableClassesInModule(module)
    return c[i]
144615
def get_py_impl():
    """"""
    if hasattr(sys, 'pypy_version_info'):
        pyimpl = 'PyPy'
    elif sys.platform.startswith('java'):
        pyimpl = 'Jython'
    elif sys.platform == 'cli':
        pyimpl = 'IronPython'
    else:
        pyimpl = 'CPython'
    return pyimpl
232197
def inspect_build(self, module, modname=None, path=None):
        
        self._module = module
        if modname is None:
            modname = module.__name__
        try:
            node = build_module(modname, module.__doc__)
        except AttributeError:
            # in jython, java modules have no __doc__ (see #109562)
            node = build_module(modname)
        node.file = node.path = os.path.abspath(path) if path else path
        node.name = modname
        MANAGER.cache_module(node)
        node.package = hasattr(module, "__path__")
        self._done = {}
        self.object_build(node, module)
        return node
578265
def do_inspect(self, arg):
        
        if arg in self.curframe.f_locals:
            obj = self.curframe.f_locals[arg]
        elif arg in self.curframe.f_globals:
            obj = self.curframe.f_globals[arg]
        else:
            obj = WebPdb.null
        if obj is not WebPdb.null:
            self.console.writeline(
                '{0} = {1}:\n'.format(arg, type(obj))
            )
            for name, value in inspect.getmembers(obj):
                if not (name.startswith('__') and (name.endswith('__'))):
                    self.console.writeline('    {0}: {1}\n'.format(
                        name, self._get_repr(value, pretty=True, indent=8)
                    ))
        else:
            self.console.writeline(
                'NameError: name "{0}" is not defined\n'.format(arg)
            )
        self.console.flush()
183419
private String getModuleFromClass(Class<?> klass, Map<String, ModuleProperties> moduleMap) {
        String file = getClassFileLocation(klass);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "File name : " + file);
        }
        String moduleName = null;
        for (Map.Entry<String, ModuleProperties> entry : moduleMap.entrySet()) {
            URL location = entry.getValue().getLocation();
            String filePath = location.getFile();
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "location : " + filePath);
            }

            if (location.getProtocol().equals("file") && file.startsWith(filePath)) {
                moduleName = entry.getKey();
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "module name from the list  : " + moduleName);
                }
                break;
            }
        }
        if (moduleName == null) {
            moduleName = file;
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "no match. use filename as module name : " + moduleName);
            }
        }
        return moduleName;
    }
1122431
public com.google.javascript.jscomp.FunctionInformationMap.Module getModule(int index) {
    return module_.get(index);
  }
911294
function getModulePath(sModuleName, sSuffix){
		return sap.ui.require.toUrl(sModuleName.replace(/\./g, "/") + sSuffix);
	}
449600
function getModule(moduleName) {
                    try {
                        return ngModuleFct(moduleName);
                    } catch (e) {
                        // this error message really suxx
                        if (/No module/.test(e) || e.message.indexOf('$injector:nomod') > -1) {
                            e.message = 'The module "' + stringify(moduleName) + '" that you are trying to load does not exist. ' + e.message;
                        }
                        throw e;
                    }
                }