find the modulename of the prefix, and set `stmt.keyword`
515217
def v_init_extension(ctx, stmt):
    """"""
    (prefix, identifier) = stmt.raw_keyword
    (modname, revision) = \
        prefix_to_modulename_and_revision(stmt.i_module, prefix,
                                          stmt.pos, ctx.errors)
    stmt.keyword = (modname, identifier)
    stmt.i_extension_modulename = modname
    stmt.i_extension_revision = revision
    stmt.i_extension = None
1294039
def is_module(self, name):
        """"""
        if self.module_prefix.startswith(self.mount_prefix):
            return name.startswith(self.module_prefix)
        return name.startswith(self.module_prefix) and not name.startswith(self.mount_prefix)
552657
def load_stdlib():
    '''
    '''
    if _stdlib:
        return _stdlib

    prefixes = tuple({os.path.abspath(p) for p in (
        sys.prefix,
        getattr(sys, 'real_prefix', sys.prefix),
        getattr(sys, 'base_prefix', sys.prefix),
    )})

    for sp in sys.path:
        if not sp:
            continue
        _import_paths.append(os.path.abspath(sp))

    stdpaths = tuple({p for p in _import_paths
                      if p.startswith(prefixes) and 'site-packages' not in p})

    _stdlib.update(sys.builtin_module_names)

    for stdpath in stdpaths:
        if not os.path.isdir(stdpath):
            continue

        for item in os.listdir(stdpath):
            if item.startswith('.') or item == 'site-packages':
                continue

            p = os.path.join(stdpath, item)
            if not os.path.isdir(p) and not item.endswith(('.py', '.so')):
                continue

            _stdlib.add(item.split('.', 1)[0])

    return _stdlib
1352579
def name(value, known_modules=[]):
    ''''''
    if value is None:
        return 'None'
    if not isinstance(value, type):  # Get the class name first
        value = type(value)
    tname = value.__name__
    if hasattr(builtins, tname):
        return tname
    modname = value.__module__
    if modname == '__main__':
        return tname
    if known_modules and modname in known_modules:
        return tname
    for kmod in known_modules:
        if not kmod:
            continue
        module = importlib.import_module(kmod)
        if hasattr(module, tname):
            return tname
    return '{}.{}'.format(modname, tname)
1329294
function getModuleName(module) {
    var script = module.replace(/[^a-zA-Z0-9]/g, '.'),
        parts = script.split('.'),
        name = parts.shift();

    if (parts.length) {
      for (var p in parts) {
        name += parts[p].charAt(0).toUpperCase() + parts[p].substr(1, parts[p].length);
      }
    }
    return name;
  }
343932
def get_short_module_name(module_name, obj_name):
    
    scope = {}
    try:
        # Find out what the real object is supposed to be.
        exec('from %s import %s' % (module_name, obj_name), scope, scope)
        real_obj = scope[obj_name]
    except Exception:
        return module_name

    parts = module_name.split('.')
    short_name = module_name
    for i in range(len(parts) - 1, 0, -1):
        short_name = '.'.join(parts[:i])
        scope = {}
        try:
            exec('from %s import %s' % (short_name, obj_name), scope, scope)
            # Ensure shortened object is the same as what we expect.
            assert real_obj is scope[obj_name]
        except Exception:  # libraries can throw all sorts of exceptions...
            # get the last working module name
            short_name = '.'.join(parts[:(i + 1)])
            break
    return short_name
687590
def get_module_path(modname):
    """"""
    return osp.abspath(osp.dirname(sys.modules[modname].__file__))
612204
def _parse_PREFIX(value):
        ""
        channel_modes, channel_chars = value.split(')')
        channel_modes = channel_modes[1:]
        return collections.OrderedDict(zip(channel_chars, channel_modes))
988338
def prefixedname_to_str(self, prefix: ShExDocParser.PrefixedNameContext) -> str:
        
        if prefix.PNAME_NS():
            return self._lookup_prefix(prefix.PNAME_NS().getText())
        else:
            prefix, local = prefix.PNAME_LN().getText().split(':', 1)
            return self._lookup_prefix(prefix + ':') + (local if local else "")
939094
def get_module_constant(module, symbol, default=-1, paths=None):
    """"""

    try:
        f, path, (suffix, mode, kind) = find_module(module, paths)
    except ImportError:
        # Module doesn't exist
        return None

    try:
        if kind == PY_COMPILED:
            f.read(8)  # skip magic & date
            code = marshal.load(f)
        elif kind == PY_FROZEN:
            code = imp.get_frozen_object(module)
        elif kind == PY_SOURCE:
            code = compile(f.read(), path, 'exec')
        else:
            # Not something we can parse; we'll have to import it.  :(
            if module not in sys.modules:
                imp.load_module(module, f, path, (suffix, mode, kind))
            return getattr(sys.modules[module], symbol, None)

    finally:
        if f:
            f.close()

    return extract_constant(code, symbol, default)
510180
function getPrefix(mod) {
  var n = 'node_modules'
  var i = mod.lastIndexOf(n)
  return ~i ? mod.slice(0, i + n.length) : ''
}
1163752
def v_type_base(ctx, stmt, no_error_report=False):
    """"""
    # Find the identity
    name = stmt.arg
    stmt.i_identity = None
    if name.find(":") == -1:
        prefix = None
    else:
        [prefix, name] = name.split(':', 1)
    if prefix is None or stmt.i_module.i_prefix == prefix:
        # check local identities
        pmodule = stmt.i_module
    else:
        # this is a prefixed name, check the imported modules
        pmodule = prefix_to_module(stmt.i_module, prefix, stmt.pos, ctx.errors)
        if pmodule is None:
            return
    if name in pmodule.i_identities:
        i = pmodule.i_identities[name]
        if prefix is None and not is_submodule_included(stmt, i):
            pass
        else:
            stmt.i_identity = i
            v_type_identity(ctx, stmt.i_identity)
    if stmt.i_identity is None and no_error_report == False:
        err_add(ctx.errors, stmt.pos,
                'IDENTITY_NOT_FOUND', (name, pmodule.arg))
826218
def search_typedef(stmt, name):
    """"""
    mod = stmt.i_orig_module
    while stmt is not None:
        if name in stmt.i_typedefs:
            t = stmt.i_typedefs[name]
            if (mod is not None and
                mod != t.i_orig_module and
                t.i_orig_module.keyword == 'submodule'):
                # make sure this submodule is included
                if mod.search_one('include', t.i_orig_module.arg) is None:
                    return None
            return t
        stmt = stmt.parent
    return None
946395
def _get_module_name_from_fname(fname):
    """"""
    fname = fname.replace(".pyc", ".py")
    for mobj in sys.modules.values():
        if (
            hasattr(mobj, "__file__")
            and mobj.__file__
            and (mobj.__file__.replace(".pyc", ".py") == fname)
        ):
            module_name = mobj.__name__
            return module_name
    raise RuntimeError("Module could not be found")
800520
def get_prefix(self, key_prefix, sort_order=None, sort_target=None):
        
        return self.get(key_prefix,
                        metadata=True,
                        range_end=_encode(_increment_last_byte(key_prefix)),
                        sort_order=sort_order,
                        sort_target=sort_target)
899297
def find_modules(self, path, prefix):
        """"""

        modules = set([prefix])

        # https://docs.python.org/2/library/pkgutil.html#pkgutil.iter_modules
        for module_info in pkgutil.iter_modules([path]):
            # we want to ignore any "private" modules
            if module_info[1].startswith('_'): continue

            module_prefix = ".".join([prefix, module_info[1]])
            if module_info[2]:
                # module is a package
                submodules = self.find_modules(os.path.join(path, module_info[1]), module_prefix)
                modules.update(submodules)
            else:
                modules.add(module_prefix)

        return modules
484492
def maybedotted(name):
    
    if not name:
        raise LookupError(
            'Not able to resolve %s' % name)
    if not hasattr(name, '__name__'):
        try:
            mod = importlib.import_module(name)
        except ImportError:
            attr = None
            if '.' in name:
                names = name.split('.')
                attr = names.pop(-1)
                try:
                    mod = maybedotted('.'.join(names))
                except LookupError:
                    attr = None
                else:
                    attr = getattr(mod, attr, None)
            if attr is not None:
                return attr
            raise LookupError(
                'Not able to resolve %s' % name)
        else:
            return mod
    return name