embed ref2names into commdct
492716
def ref2names2commdct(ref2names, commdct):
    """"""
    for comm in commdct:
        for cdct in comm:
            try:
                refs = cdct['object-list'][0]
                validobjects = ref2names[refs]
                cdct.update({'validobjects':validobjects})
            except KeyError as e:
                continue
    return commdct
277612
def p_const_ref(self, p):
        ''''''
        p[0] = ast.ConstReference(p[1], lineno=p.lineno(1))
727037
def _initialize_references(model_class, name, bases, attrs):
    """"""
    model_class._references = {}
    h = {}
    deferred = []
    for k, v in attrs.iteritems():
        if isinstance(v, ReferenceField):
            model_class._references[k] = v
            v.name = v.name or k
            att = Attribute(name=v.attname)
            h[v.attname] = att
            setattr(model_class, v.attname, att)
            refd = _initialize_referenced(model_class, v)
            if refd:
                deferred.append(refd)
    attrs.update(h)
    return deferred
663806
def format_struct(struct_def):
    '''
    '''
    text = []
    text.append('cdef struct {}:'.format(struct_def.tp_name))
    text.extend(
        ['{}{}'.format(tab, format_variable(var))
         for var in struct_def.members]
    )

    for name in struct_def.names:
        text.append('ctypedef {} {}'.format(struct_def.tp_name, name))

    return text
804513
def embedgroupdata(extract_func, fname, debug):
    """"""
    
    astr = _readfname(fname)
    
    # fname is exhausted by the above read
    # reconstitute fname as a StringIO
    fname = StringIO(astr)

    try:
        astr = astr.decode('ISO-8859-2')
    except Exception as e:
        pass # for python 3
    glist = iddgroups.iddtxt2grouplist(astr)
    
    
    blocklst, commlst, commdct = extract_func(fname)
    # add group information to commlst and commdct
    # glist = getglist(fname)
    commlst = iddgroups.group2commlst(commlst, glist)
    commdct = iddgroups.group2commdct(commdct, glist)
    return blocklst, commlst, commdct
755307
def flatten_component_refs(
        container: ast.Class,
        expression: ast.Union[ast.ConnectClause, ast.AssignmentStatement, ast.ForStatement, ast.Symbol],
        instance_prefix: str) -> ast.Union[ast.ConnectClause, ast.AssignmentStatement, ast.ForStatement, ast.Symbol]:
    

    expression_copy = copy.deepcopy(expression)

    w = TreeWalker()
    w.walk(ComponentRefFlattener(container, instance_prefix), expression_copy)

    return expression_copy
1074004
def salt_refs(data):
    '''
    
    '''
    proto = 'salt://'
    ret = []
    if isinstance(data, six.string_types):
        if data.startswith(proto):
            return [data]
    if isinstance(data, list):
        for comp in data:
            if isinstance(comp, six.string_types):
                if comp.startswith(proto):
                    ret.append(comp)
    return ret
1332097
def addobject(bunchdt, data, commdct, key, theidf, aname=None, **kwargs):
    """"""
    obj = newrawobject(data, commdct, key)
    abunch = obj2bunch(data, commdct, obj)
    if aname:
        namebunch(abunch, aname)
    data.dt[key].append(obj)
    bunchdt[key].append(abunch)
    for key, value in list(kwargs.items()):
        abunch[key] = value
    return abunch
311966
def _do_names(names, fun, path=None):
    '''
    
    '''
    ret = {}
    hosts = find_guests(names, path=path)
    if not hosts:
        return False

    client = salt.client.get_local_client(__opts__['conf_file'])
    for host, sub_names in six.iteritems(hosts):
        cmds = []
        for name in sub_names:
            cmds.append(client.cmd_iter(
                    host,
                    'lxc.{0}'.format(fun),
                    [name],
                    kwarg={'path': path},
                    timeout=60))
        for cmd in cmds:
            data = next(cmd)
            data = data.get(host, {}).get('ret', None)
            if data:
                ret.update({host: data})
    return ret
137076
def _refs(obj, named, *ats, **kwds):
    '''
    '''
    if named:
        for a in ats:  # cf. inspect.getmembers()
            if hasattr(obj, a):
                yield _NamedRef(a, getattr(obj, a))
        if kwds:  # kwds are _dir2() args
            for a, o in _dir2(obj, **kwds):
                yield _NamedRef(a, o)
    else:
        for a in ats:  # cf. inspect.getmembers()
            if hasattr(obj, a):
                yield getattr(obj, a)
        if kwds:  # kwds are _dir2() args
            for _, o in _dir2(obj, **kwds):
                yield o
477416
def resolve_ref(cls, domain, env, fromdocname, builder, typ, target, node,
                    contnode):
        
        # indexes appear to be automatically generated at doc DOMAIN-NAME
        todocname = "bb-%s" % target

        node = nodes.reference('', '', internal=True)
        node['refuri'] = builder.get_relative_uri(fromdocname, todocname)
        node['reftitle'] = cls.localname
        node.append(nodes.emphasis(cls.localname, cls.localname))
        return node
1026727
def p_dynamic_class_name_reference(p):
    ''''''
    if len(p) == 5:
        name, dims = p[3]
        p[0] = ast.ObjectProperty(p[1], name, lineno=p.lineno(2))
        for class_, dim, lineno in dims:
            p[0] = class_(p[0], dim, lineno=lineno)
        for name, dims in p[4]:
            p[0] = ast.ObjectProperty(p[0], name, lineno=p.lineno(2))
            for class_, dim, lineno in dims:
                p[0] = class_(p[0], dim, lineno=lineno)
    else:
        p[0] = p[1]
642411
def _print_refs(self, refs, total, prefix='    ',
                    level=1, minsize=0, minpct=0.1):
        
        lrefs = list(refs)
        lrefs.sort(key=lambda x: x.size)
        lrefs.reverse()
        for ref in lrefs:
            if ref.size > minsize and (ref.size*100.0/total) > minpct:
                self.stream.write('%-50s %-14s %3d%% [%d]\n' % (
                    trunc(prefix+str(ref.name), 50),
                    pp(ref.size),
                    int(ref.size*100.0/total),
                    level
                ))
                self._print_refs(ref.refs, total, prefix=prefix+'  ',
                                 level=level+1)
777282
def normalize_name(decl):
    
    if decl.cache.normalized_name is None:
        decl.cache.normalized_name = normalize(decl.name)
    return decl.cache.normalized_name
864884
def makeref2namesdct(name2refdct):
    """"""
    ref2namesdct = {}
    for key, values in name2refdct.items():
        for value in values:
            ref2namesdct.setdefault(value, set()).add(key)
    return ref2namesdct
130734
function readPackedRef(gitFolder, refName) {
	var packedRefs, i, each, match

	try {
		packedRefs = fs.readFileSync(path.join(gitFolder, 'packed-refs'), 'utf8').split(/\r?\n/)
	} catch (e) {
		return ''
	}

	for (i = 0; i < packedRefs.length; i++) {
		each = packedRefs[i].trim()

		// Look for lines like:
		// 1d6f5f98a254578e19b5eb163077170d45448c26 refs/heads/master
		match = each.match(/^(.{40}) (.*)$/)
		if (match && match[2] === refName && isSHA1(match[1])) {
			return match[1]
		}
	}
	return ''
}
262082
def parseFunctionSignatures(self):
        """"""
        # Keys: string refid of either namespace or file nodes
        # Values: list of function objects that should be defined there
        parent_to_func = {}
        for func in self.functions:
            # Case 1: it is a function inside a namespace, the function information
            # is in the namespace's XML file.
            if func.parent:
                parent_refid = None
                if func.parent.kind == "namespace":
                    parent_refid = func.parent.refid
                else:
                    raise RuntimeError(textwrap.dedent('''
                        Function [{0}] with refid=[{1}] had a parent of kind '{2}':
                        Parent name=[{3}], refid=[{4}].

                        Functions may only have namespace parents.  Please report this
                        issue online, Exhale has a parsing error.
                    '''.format(func.name, func.refid, func.parent.name, func.parent.refid)))
            # Case 2: top-level function, it's information is in the file node's XML.
            elif func.def_in_file:
                parent_refid = func.def_in_file.refid
            else:
                utils.verbose_log(utils.critical(
                    "Cannot parse function [{0}] signature, refid=[{2}], no parent/def_in_file found!".format(
                        func.name, func.refid
                    )
                ))

            # If we found a suitable parent refid, gather in parent_to_func.
            if parent_refid:
                if parent_refid not in parent_to_func:
                    parent_to_func[parent_refid] = []
                parent_to_func[parent_refid].append(func)

        # Now we have a mapping of all defining elements to where the function
        # signatures _should_ live.
        # TODO: setwise comparison / report when children vs parent_to_func[refid] differ?
        for refid in parent_to_func:
            parent = self.node_by_refid[refid]
            parent_contents = utils.nodeCompoundXMLContents(parent)
            if not parent_contents:
                continue  ############flake8efphase: TODO: error, log?

            try:
                parent_soup = BeautifulSoup(parent_contents, "lxml-xml")
            except:
                continue

            cdef = parent_soup.doxygen.compounddef
            func_section = None
            for section in cdef.find_all("sectiondef", recursive=False):
                if "kind" in section.attrs and section.attrs["kind"] == "func":
                    func_section = section
                    break

            if not func_section:
                continue############flake8efphase: TODO: error, log?

            functions = parent_to_func[refid]
            for memberdef in func_section.find_all("memberdef", recursive=False):
                if "kind" not in memberdef.attrs or memberdef.attrs["kind"] != "function":
                    continue

                func_refid = memberdef.attrs["id"]
                func = None
                for candidate in functions:
                    if candidate.refid == func_refid:
                        func = candidate
                        break

                if not func:
                    continue ############flake8efphase: TODO: error, log?
                functions.remove(func)

                # At last, we can actually parse the function signature
                # 1. The function return type.
                func.return_type = utils.sanitize(
                    memberdef.find("type", recursive=False).text
                )
                # 2. The function parameter list.
                parameters = []
                for param in memberdef.find_all("param", recursive=False):
                    parameters.append(param.type.text)
                func.parameters = utils.sanitize_all(parameters)
                # 3. The template parameter list.
                templateparamlist = memberdef.templateparamlist
                if templateparamlist:
                    template = []
                    for param in templateparamlist.find_all("param", recursive=False):
                        template.append(param.type.text)
                    func.template = utils.sanitize_all(template)