Given an ImportFrom AST node, guess the prefix that should be tacked
        on to an alias name to produce a canonical name. `fullname` is the name
        of the module in which the ImportFrom appears.
978791
def resolve_relpath(self, fullname, level):
        
        mod = sys.modules.get(fullname, None)
        if hasattr(mod, '__path__'):
            fullname += '.__init__'

        if level == 0 or not fullname:
            return ''

        bits = fullname.split('.')
        if len(bits) <= level:
            # This would be an ImportError in real code.
            return ''

        return '.'.join(bits[:-level]) + '.'
429502
def _Import(self, t):
        
        self._fill("import ")
        
        for i, (name,asname) in enumerate(t.names):
            if i != 0:
                self._write(", ")
            self._write(name)
            if asname is not None:
                self._write(" as "+asname)
162657
def visit_import(self, node, parent):
        """"""
        names = [(alias.name, alias.asname) for alias in node.names]
        newnode = nodes.Import(
            names,
            getattr(node, "lineno", None),
            getattr(node, "col_offset", None),
            parent,
        )
        # save import names in parent's locals:
        for (name, asname) in newnode.names:
            name = asname or name
            parent.set_local(name.split(".")[0], newnode)
        return newnode
708451
def visit_Name(self, node):
        
        if (isinstance(node.ctx, ast.Load) and
                node.id not in self.local_decl and
                node.id in self.to_expand):
            self.update = True
            return ast.Call(func=node,
                            args=[], keywords=[])
        return node
1166061
def prefix_shared_name_attributes(meta_graph, absolute_import_scope):
  """"""
  shared_name_attr = "shared_name"
  for node in meta_graph.graph_def.node:
    shared_name_value = node.attr.get(shared_name_attr, None)
    if shared_name_value and shared_name_value.HasField("s"):
      if shared_name_value.s:
        node.attr[shared_name_attr].s = tf.compat.as_bytes(
            prepend_name_scope(
                shared_name_value.s, import_scope=absolute_import_scope))
260637
def normalize_full_name_true(decl):
    
    if decl.cache.normalized_full_name_true is None:
        decl.cache.normalized_full_name_true = normalize(
            declaration_utils.full_name(decl, with_defaults=True))
    return decl.cache.normalized_full_name_true
1315100
def declares_namespace_package(filename):
  """"""

  import ast

  with open(filename) as fp:
    init_py = ast.parse(fp.read(), filename)
  calls = [node for node in ast.walk(init_py) if isinstance(node, ast.Call)]
  for call in calls:
    if len(call.args) != 1:
      continue
    if isinstance(call.func, ast.Attribute) and call.func.attr != 'declare_namespace':
      continue
    if isinstance(call.func, ast.Name) and call.func.id != 'declare_namespace':
      continue
    if isinstance(call.args[0], ast.Name) and call.args[0].id == '__name__':
      return True
  return False
1374743
def full_name(cla55: Optional[type]) -> str:
    
    # Special case to handle None:
    if cla55 is None:
        return "?"

    if issubclass(cla55, Initializer) and cla55 not in [Initializer, PretrainedModelInitializer]:
        init_fn = cla55()._init_function
        return f"{init_fn.__module__}.{init_fn.__name__}"

    origin = getattr(cla55, '__origin__', None)
    args = getattr(cla55, '__args__', ())

    # Special handling for compound types
    if origin in (Dict, dict):
        key_type, value_type = args
        return f"""Dict[{full_name(key_type)}, {full_name(value_type)}]"""
    elif origin in (Tuple, tuple, List, list, Sequence, collections.abc.Sequence):
        return f"""{_remove_prefix(str(origin))}[{", ".join(full_name(arg) for arg in args)}]"""
    elif origin == Union:
        # Special special case to handle optional types:
        if len(args) == 2 and args[-1] == type(None):
            return f"""Optional[{full_name(args[0])}]"""
        else:
            return f"""Union[{", ".join(full_name(arg) for arg in args)}]"""
    else:
        return _remove_prefix(f"{cla55.__module__}.{cla55.__name__}")
819133
def visit_Name(self, node):
        
        if node.id in self.symbols:
            symbol = path_to_node(self.symbols[node.id])
            if not getattr(symbol, 'isliteral', lambda: False)():
                parent = self.ancestors[node][-1]
                blacklist = (ast.Tuple,
                             ast.List,
                             ast.Set,
                             ast.Return)
                if isinstance(parent, blacklist):
                    raise PythranSyntaxError(
                        "Unsupported module identifier manipulation",
                        node)
            new_node = path_to_attr(self.symbols[node.id])
            new_node.ctx = node.ctx
            ast.copy_location(new_node, node)
            return new_node
        return node
257126
def normalize_full_name_false(decl):
    
    if decl.cache.normalized_full_name_false is None:
        decl.cache.normalized_full_name_false = normalize(
            declaration_utils.full_name(decl, with_defaults=False))
    return decl.cache.normalized_full_name_false
431893
def full_name(self):
        
        qid, quality_str, pretty_quality_str = self.quality
        custom_name = self.custom_name
        item_name = self.name
        english = (self._language == "en_US")
        rank = self.rank
        prefixed = self._schema_item.get("proper_name", False)
        prefix = ''
        suffix = ''
        pfinal = ''

        if item_name.startswith("The ") and prefixed:
            item_name = item_name[4:]

        if quality_str != "unique" and quality_str != "normal":
            pfinal = pretty_quality_str

        if english:
            if prefixed:
                if quality_str == "unique":
                    pfinal = "The"
            elif quality_str == "unique":
                pfinal = ''

        if rank and quality_str == "strange":
            pfinal = rank["name"]

        if english:
            prefix = pfinal
        elif pfinal:
            suffix = '(' + pfinal + ') ' + suffix

        return (prefix + " " + item_name + " " + suffix).strip()
199003
function (moduleNamePlusExt) {
              var ext,
                index = moduleNamePlusExt.lastIndexOf("."),
                segment = moduleNamePlusExt.split("/")[0],
                isRelative = segment === "." || segment === "..";

              //Have a file extension alias, and it is not the
              //dots from a relative path.
              if (index !== -1 && (!isRelative || index > 1)) {
                ext = moduleNamePlusExt.substring(
                  index,
                  moduleNamePlusExt.length
                );
                moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
              }

              return context.nameToUrl(
                normalize(moduleNamePlusExt, relMap && relMap.id, true),
                ext,
                true
              );
            }
733285
def _get_module_via_parent_enumeration(self, fullname):
        
        if fullname not in sys.modules:
            # Don't attempt this unless a module really exists in sys.modules,
            # else we could return junk.
            return

        pkgname, _, modname = str_rpartition(to_text(fullname), u'.')
        pkg = sys.modules.get(pkgname)
        if pkg is None or not hasattr(pkg, '__file__'):
            return

        pkg_path = os.path.dirname(pkg.__file__)
        try:
            fp, path, ext = imp.find_module(modname, [pkg_path])
            try:
                path = self._py_filename(path)
                if not path:
                    fp.close()
                    return

                source = fp.read()
            finally:
                if fp:
                    fp.close()

            if isinstance(source, mitogen.core.UnicodeType):
                # get_source() returns "string" according to PEP-302, which was
                # reinterpreted for Python 3 to mean a Unicode string.
                source = source.encode('utf-8')
            return path, source, False
        except ImportError:
            e = sys.exc_info()[1]
            LOG.debug('imp.find_module(%r, %r) -> %s', modname, [pkg_path], e)
87156
def _is_import_binding(node, name, package=None):
    

    if node.type == syms.import_name and not package:
        imp = node.children[1]
        if imp.type == syms.dotted_as_names:
            for child in imp.children:
                if child.type == syms.dotted_as_name:
                    if child.children[2].value == name:
                        return node
                elif child.type == token.NAME and child.value == name:
                    return node
        elif imp.type == syms.dotted_as_name:
            last = imp.children[-1]
            if last.type == token.NAME and last.value == name:
                return node
        elif imp.type == token.NAME and imp.value == name:
            return node
    elif node.type == syms.import_from:
        # unicode(...) is used to make life easier here, because
        # from a.b import parses to ['import', ['a', '.', 'b'], ...]
        if package and unicode(node.children[1]).strip() != package:
            return None
        n = node.children[3]
        if package and _find(u"as", n):
            # See test_from_import_as for explanation
            return None
        elif n.type == syms.import_as_names and _find(name, n):
            return node
        elif n.type == syms.import_as_name:
            child = n.children[2]
            if child.type == token.NAME and child.value == name:
                return node
        elif n.type == token.NAME and n.value == name:
            return node
        elif package and n.type == token.STAR:
            return node
    return None
530820
def _getFullPathName(self, containingNodes):
        
        assert isinstance(containingNodes, list)
        return [(self.options.fullPathNamespace, 'module')] + containingNodes
615569
def generate_import_from(module_, names):
        
        regular_names = [n for n in names if "::" not in n]
        as_names = [n for n in names if "::" in n]

        line = ""
        if len(regular_names) > 0:
            slots = {"m": module_, "n": ", ".join(sorted(regular_names))}
            line = "from %(m)s import %(n)s" % slots
            if len(line) > LINE_LENGTH_LIMIT:
                slots["n"] = INDENT + (",\n" + INDENT).join(sorted(regular_names)) + ","
                line = "from %(m)s import (\n%(n)s\n)" % slots
            if len(as_names) > 0:
                line += "\n"

        for as_name in as_names:
            a, n = as_name.split("::")
            line += "from %(m)s import %(n)s as %(a)s" % {"m": module_, "n": n, "a": a}
        return line
213034
def full_name(self):
        
        import ibis.expr.operations as ops

        return ops.DayOfWeekName(self.op().arg).to_expr()