WARNING: Only call from top level! THIS DOES NOT RESET NAMES in an embeded IPython!!!
        Remove any local names that have already been defined.
356519
def resetLocalNames(g=None):
    
    if g is None:
        g = inspect.stack(0)[1][0].f_locals  #  get globals of calling scope
    for k in list(graphBase.LocalNames.keys()):
        try:
            g.pop(k)
        except KeyError:
            raise KeyError('%s not in globals, are you calling resetLocalNames from a local scope?' % k)
        graphBase.LocalNames.pop(k)
850608
def handle_aliases_in_calls(name, import_alias_mapping):
    
    for key, val in import_alias_mapping.items():
        # e.g. Foo == Foo
        # e.g. Foo.Bar startswith Foo.
        if name == key or \
                name.startswith(key + '.'):

            # Replace key with val in name
            # e.g. StarbucksVisitor.Tea -> Eataly.Tea because
            #   "from .nested_folder import StarbucksVisitor as Eataly"
            return name.replace(key, val)
    return None
663258
def can_rename(self):
        # type: (LocalSourcePaths) -> bool
        
        return len(self._paths) == 1 and (
            self._paths[0].is_file() or
            blobxfer.models.upload.LocalSourcePath.is_stdin(
                str(self._paths[0]))
        )
257340
def name(self):
        """"""
        # pylint:disable=E1101
        return next((self.names.get(x) for x in self._locales if x in
                     self.names), None)
1297720
def _sanitize_instance_name(name, max_length):
    
    name = str(name).lower()                # make all letters lowercase
    name = re.sub(r'[^-a-z0-9]', '', name)  # remove invalid characters
    # remove non-lowercase letters from the beginning
    name = re.sub(r'^[^a-z]+', '', name)
    name = name[:max_length]
    name = re.sub(r'-+$', '', name)         # remove hyphens from the end
    return name
519272
def remove_allocated_node_name(self, name):
        

        if name in self._allocated_node_names:
            self._allocated_node_names.remove(name)
99088
def remove_stacktrace_locals(client, event):
    
    func = lambda frame: frame.pop("vars", None)
    return _process_stack_frames(event, func)
556669
private void maybeUpdateTopLevelName(NodeTraversal t, Node nameNode) {
    String name = nameNode.getString();
    if (!currentScript.isModule || !currentScript.topLevelNames.contains(name)) {
      return;
    }
    Var var = t.getScope().getVar(name);
    // If the name refers to a var that is not from the top level scope.
    if (var == null || var.getScope().getRootNode() != currentScript.rootNode) {
      // Then it shouldn't be renamed.
      return;
    }

    // If the name is part of a destructuring import, the import rewriting will take care of it
    if (var.getNameNode() == nameNode
        && nameNode.getParent().isStringKey()
        && nameNode.getGrandparent().isObjectPattern()) {
      Node destructuringLhsNode = nameNode.getGrandparent().getParent();
      if (isCallTo(destructuringLhsNode.getLastChild(), GOOG_REQUIRE)
          || isCallTo(destructuringLhsNode.getLastChild(), GOOG_REQUIRETYPE)) {
        return;
      }
    }

    // If the name is an alias for an imported namespace rewrite from
    // "new Foo;" to "new module$exports$Foo;"
    boolean nameIsAnAlias = currentScript.namesToInlineByAlias.containsKey(name);
    if (nameIsAnAlias && var.getNode() != nameNode) {
      maybeAddAliasToSymbolTable(nameNode, currentScript.legacyNamespace);

      String namespaceToInline = currentScript.namesToInlineByAlias.get(name);
      if (namespaceToInline.equals(currentScript.getBinaryNamespace())) {
        currentScript.hasCreatedExportObject = true;
      }
      safeSetMaybeQualifiedString(nameNode, namespaceToInline);

      // Make sure this action won't shadow a local variable.
      if (namespaceToInline.indexOf('.') != -1) {
        String firstQualifiedName = namespaceToInline.substring(0, namespaceToInline.indexOf('.'));
        Var shadowedVar = t.getScope().getVar(firstQualifiedName);
        if (shadowedVar == null
            || shadowedVar.isGlobal()
            || shadowedVar.getScope().isModuleScope()) {
          return;
        }
        t.report(
            shadowedVar.getNode(),
            IMPORT_INLINING_SHADOWS_VAR,
            shadowedVar.getName(),
            namespaceToInline);
      }
      return;
    }

    // For non-import alias names rewrite from
    // "var foo; console.log(foo);" to
    // "var module$contents$Foo_foo; console.log(module$contents$Foo_foo);"
    safeSetString(nameNode, currentScript.contentsPrefix + name);
  }
1317344
def checkCalledInside(classname, stack):
    
    ok = False
    for s in stack[1:]:
        cc = s.code_context[0]
        if 'class' in cc:
            if '(' in cc:
                bases = [b.strip() for b in cc.split('(')[1].split(')')[0].split(',')]
                for base_name in bases:
                    if base_name in s.frame.f_globals:
                        base = s.frame.f_globals[base_name]
                        for cls in base.__class__.mro(base):
                            if cls.__name__ == classname:
                                ok = True
                                break
                        if ok:
                            break
                if ok:
                    break
    if not ok:
        name = stack[0].function
        raise SyntaxError('%s not called inside a class inheriting from LocalNameManager' % name)
27481
def finalize(self):
        

        self.global_scope.close()
        name_generator = NameGenerator(skip=self.reserved_keywords)
        self.global_scope.build_remap_symbols(
            name_generator,
            children_only=not self.obfuscate_globals,
        )
939532
def free_param_names(self):
        
        p = CombinedBounds(self.k.free_param_names, self.noise_k.free_param_names)
        if self.mu is not None:
            p = CombinedBounds(p, self.mu.free_param_names)
        return p
216178
def pull_locals(self, frame):
        """"""
        for name in frame.identifiers.undeclared:
            self.writeline('l_%s = context.resolve(%r)' % (name, name))
6397
def alt_names(names: str) -> Callable[..., Any]:
    
    names_split = names.split()

    def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
        func.alt_names = names_split  # type: ignore
        return func
    return decorator
266453
def strip_toplevel_name(filelist):
    
    if not filelist:
        return filelist
    prefix = filelist[0]
    if '/' in prefix:
        prefix = prefix.partition('/')[0] + '/'
        names = filelist
    else:
        prefix = prefix + '/'
        names = filelist[1:]
    for name in names:
        if not name.startswith(prefix):
            raise Failure("File doesn't have the common prefix (%s): %s"
                          % (name, prefix))
    return [name[len(prefix):] for name in names]
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
1226420
def add_from_names_to_locals(self, node):
        
        _key_func = lambda node: node.fromlineno

        def sort_locals(my_list):
            my_list.sort(key=_key_func)

        for (name, asname) in node.names:
            if name == "*":
                try:
                    imported = node.do_import_module()
                except exceptions.AstroidBuildingError:
                    continue
                for name in imported.public_names():
                    node.parent.set_local(name, node)
                    sort_locals(node.parent.scope().locals[name])
            else:
                node.parent.set_local(asname or name, node)
                sort_locals(node.parent.scope().locals[asname or name])
34754
def remove_headers(headers, name):
    
    i = 0
    name = name.lower()
    for j in range(len(headers)):
        if headers[j][0].lower() != name:
            if i != j:
                headers[i] = headers[j]
            i += 1
    del headers[i:]
    return headers