Generate a 3-tuple `(partname, blob, srels)` for each of the parts in
        *phys_reader* by walking the relationship graph rooted at srels.
541542
def _walk_phys_parts(phys_reader, srels, visited_partnames=None):
        
        if visited_partnames is None:
            visited_partnames = []
        for srel in srels:
            if srel.is_external:
                continue
            partname = srel.target_partname
            if partname in visited_partnames:
                continue
            visited_partnames.append(partname)
            part_srels = PackageReader._srels_for(phys_reader, partname)
            blob = phys_reader.blob_for(partname)
            yield (partname, blob, part_srels)
            for partname, blob, srels in PackageReader._walk_phys_parts(
                    phys_reader, part_srels, visited_partnames):
                yield (partname, blob, srels)
559371
def gen_etree(self):
        """"""
        relations_elem = self.gen_relations()
        header = E('header')
        header.append(relations_elem)

        self.gen_body()

        tree = E('rst')
        tree.append(header)

        # The <body> contains both <segment>, as well as <group> elements.
        # While the order of the elements should theoretically be irrelevant,
        # rs3 files usually list the segments before the groups.
        body = E('body')
        for segment in self.body['segments']:
            body.append(segment)
        for group in self.body['groups']:
            body.append(group)

        tree.append(body)
        return tree
213082
def partition_loci(self,verbose=False):
    
    self.g.merge_cycles()
    #sys.stderr.write(self.g.get_report()+"\n")
    gs = self.g.partition_graph(verbose=verbose)
    tls = [] # makea list of transcript loci
    for g in gs:
      tl = TranscriptLoci()
      tl.merge_rules = self.merge_rules
      ns = g.get_nodes()
      for n in [x.payload for x in ns]:
        for tx in n:
          tl.add_transcript(tx)
      if len(tl.g.get_nodes()) > 0:
        tls.append(tl)
    #print '-----------------------' 
    #names = []
    #for tl in tls:
    #  for tx in tl.get_transcripts():
    #    names.append(tx.get_gene_name())
    #for name in sorted(names):
    #  print name
    #print '--------------------------'
    return tls
513387
def _init_edges_relationships(rel2src2dsts, rel2dst2srcs):
        """"""
        edge_rel2fromto = {}
        relationships = set(rel2src2dsts).union(rel2dst2srcs)
        for reltype in relationships:
            edge_from_to = []
            if reltype in rel2src2dsts:
                for parent, children in rel2src2dsts[reltype].items():
                    for child in children:
                        edge_from_to.append((child, parent))
            if reltype in rel2dst2srcs:
                for parent, children in rel2dst2srcs[reltype].items():
                    for child in children:
                        edge_from_to.append((child, parent))
            edge_rel2fromto[reltype] = edge_from_to
        return edge_rel2fromto
663533
def gen_part_from_iterables(iterables: Iterable[Any],
                            part_index: int) -> Generator[Any, None, None]:
    

    """
    # RST: make part of word bold/italic:
    # https://stackoverflow.com/questions/12771480/part-of-a-word-bold-in-restructuredtext  # noqa
    for iterable in iterables:
        yield iterable[part_index]
1207217
public static Tuple3<List<Point2D_F64>,List<Point2D_F64>,List<Point2D_F64>> split3(List<AssociatedTriple> input )
	{
		List<Point2D_F64> list1 = new ArrayList<>();
		List<Point2D_F64> list2 = new ArrayList<>();
		List<Point2D_F64> list3 = new ArrayList<>();

		for (int i = 0; i < input.size(); i++) {
			list1.add( input.get(i).p1 );
			list2.add( input.get(i).p2 );
			list3.add( input.get(i).p3 );
		}

		return new Tuple3<>(list1,list2,list3);
	}
723815
def GenerateFileData(self):
    """"""
    # Handle chunked encoding:
    # https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1
    while 1:
      line = self.rfile.readline()
      # We do not support chunked extensions, just ignore them.
      chunk_size = int(line.split(";")[0], 16)
      if chunk_size == 0:
        break

      for chunk in self._GenerateChunk(chunk_size):
        yield chunk

      # Chunk is followed by \r\n.
      lf = self.rfile.read(2)
      if lf != "\r\n":
        raise IOError("Unable to parse chunk.")

    # Skip entity headers.
    for header in self.rfile.readline():
      if not header:
        break
420645
def _buildGraph(self):
        
        for n in self.namespaces:
            self.rdflib_graph.bind(n[0], rdflib.Namespace(n[1]))
        if self.triples:
            for terzetto in self.triples:
                self.rdflib_graph.add(terzetto)
489911
def _data_flow_chain(self):
        
        if self.data_producer is None:
            return []

        res = []
        ds = self.data_producer
        while not ds.is_reader:
            res.append(ds)
            ds = ds.data_producer
        res.append(ds)
        res = res[::-1]
        return res
713459
private Tuple3<ReadOnlyStyledDocument<PS, SEG, S>, RichTextChange<PS, SEG, S>, MaterializedListModification<Paragraph<PS, SEG, S>>> replace(
            BiIndex start, BiIndex end, UnaryOperator<ReadOnlyStyledDocument<PS, SEG, S>> f) {
        int pos = tree.getSummaryBetween(0, start.major).map(s -> s.length() + 1).orElse(0) + start.minor;

        List<Paragraph<PS, SEG, S>> removedPars =
                getParagraphs().subList(start.major, end.major + 1);

        return end.map(this::split).map((l0, r) -> {
            return start.map(l0::split).map((l, removed) -> {
                ReadOnlyStyledDocument<PS, SEG, S> replacement = f.apply(removed);
                ReadOnlyStyledDocument<PS, SEG, S> doc = l.concatR(replacement).concat(r);
                RichTextChange<PS, SEG, S> change = new RichTextChange<>(pos, removed, replacement);
                List<Paragraph<PS, SEG, S>> addedPars = doc.getParagraphs().subList(start.major, start.major + replacement.getParagraphCount());
                MaterializedListModification<Paragraph<PS, SEG, S>> parChange =
                        MaterializedListModification.create(start.major, removedPars, addedPars);
                return t(doc, change, parChange);
            });
        });
    }
58359
async def _load_tuple(self, reader, elem_type, params=None, elem=None):
        

        c_len = await load_uvarint(reader)
        if elem and c_len != len(elem):
            raise ValueError("Size mismatch")
        if c_len != len(elem_type.f_specs()):
            raise ValueError("Tuple size mismatch")

        elem_fields = params[0] if params else None
        if elem_fields is None:
            elem_fields = elem_type.f_specs()

        res = elem if elem else []
        for i in range(c_len):
            try:
                self.tracker.push_index(i)
                fvalue = await self.load_field(
                    reader,
                    elem_fields[i],
                    params[1:] if params else None,
                    eref(res, i) if elem else None,
                )
                self.tracker.pop()
            except Exception as e:
                raise helpers.ArchiveException(e, tracker=self.tracker) from e

            if not elem:
                res.append(fvalue)
        return res
217544
function (combinations, parts, backboneSrc) {
    var src = '';
    var allCombinations = [];

    parts.forEach(function (part) {
      allCombinations.push(combinations[_.str.capitalize(part.toLowerCase())]);
    });

    var neededParts = _.union.apply(_, allCombinations);
    var backboneParts = getBackboneParts(backboneSrc);
    var finalCombination = _.intersection(combinations.All, neededParts);

    finalCombination.forEach(function (part) {
      src += backboneParts[_.str.capitalize(part.toLowerCase())];

      if (part.toLowerCase() === 'view') {
        src = src.replace('Model.extend = Collection.extend = Router.extend = View.extend = extend;', '');
      }
    });

    var extender = '';
    if(!_.contains(finalCombination, 'View') && !_.contains(finalCombination, 'view')) {
      extender += '  var extend = function (protoProps, classProps) {\n';
      extender += '    var child = inherits(this, protoProps, classProps)\n';
      extender += '    child.extend = this.extend;\n';
      extender += '    return child;\n';
      extender += '  };\n\n';
    }

    // add the extend chain
    finalCombination.forEach(function (extendo) {
      var lowerEx = extendo.toLowerCase();
      if (lowerEx === 'model') {
        extender += 'Model.extend = ';
      }

      if (lowerEx === 'collection') {
        extender += 'Collection.extend = ';
      }

      if (lowerEx === 'router') {
        extender += 'Router.extend = ';
      }

      if (lowerEx === 'view') {
        extender += 'View.extend = ';
      }
    });

    extender += 'extend;';

    src = src.replace('// Helpers', extender + '\n\n  // Helpers');

    return src;
  }
742298
def add_percolator_to_mzidtsv(mzidfn, tsvfn, multipsm, oldheader):
    
    namespace = readers.get_mzid_namespace(mzidfn)
    try:
        xmlns = '{%s}' % namespace['xmlns']
    except TypeError:
        xmlns = ''
    specfnids = readers.get_mzid_specfile_ids(mzidfn, namespace)
    mzidpepmap = {}
    for peptide in readers.generate_mzid_peptides(mzidfn, namespace):
        pep_id, seq = readers.get_mzid_peptidedata(peptide, xmlns)
        mzidpepmap[pep_id] = seq
    mzidpercomap = {}
    for specid_data in readers.generate_mzid_spec_id_items(mzidfn, namespace,
                                                           xmlns, specfnids):
        scan, fn, pepid, spec_id = specid_data
        percodata = readers.get_specidentitem_percolator_data(spec_id, xmlns)
        try:
            mzidpercomap[fn][scan][mzidpepmap[pepid]] = percodata
        except KeyError:
            try:
                mzidpercomap[fn][scan] = {mzidpepmap[pepid]: percodata}
            except KeyError:
                mzidpercomap[fn] = {scan: {mzidpepmap[pepid]: percodata}}
    for line in tsvreader.generate_tsv_psms(tsvfn, oldheader):
        outline = {k: v for k, v in line.items()}
        fn = line[mzidtsvdata.HEADER_SPECFILE]
        scan = line[mzidtsvdata.HEADER_SCANNR]
        seq = line[mzidtsvdata.HEADER_PEPTIDE]
        outline.update(mzidpercomap[fn][scan][seq])
        yield outline
365511
def partition_2(T: RDFGraph) -> List[Tuple[RDFGraph, RDFGraph]]:
    
    for p in partition_t(T, 2):
        yield p
1068945
def _to_bel_lines_footer(graph) -> Iterable[str]:
    
    unqualified_edges_to_serialize = [
        (u, v, d)
        for u, v, d in graph.edges(data=True)
        if d[RELATION] in UNQUALIFIED_EDGES and EVIDENCE not in d
    ]

    isolated_nodes_to_serialize = [
        node
        for node in graph
        if not graph.pred[node] and not graph.succ[node]
    ]

    if unqualified_edges_to_serialize or isolated_nodes_to_serialize:
        yield '###############################################\n'
        yield 'SET Citation = {"PubMed","Added by PyBEL","29048466"}'
        yield 'SET SupportingText = "{}"'.format(PYBEL_AUTOEVIDENCE)

        for u, v, data in unqualified_edges_to_serialize:
            yield '{} {} {}'.format(u.as_bel(), data[RELATION], v.as_bel())

        for node in isolated_nodes_to_serialize:
            yield node.as_bel()

        yield 'UNSET SupportingText'
        yield 'UNSET Citation'
1356764
def iter_tokens(cls, blob):
    
    readline_func = io.StringIO(blob.decode('utf-8')).readline
    return tokenize.generate_tokens(readline_func)
1226758
def flow_tuple(data):
    """"""
    src = net_utils.inet_to_str(data['packet'].get('src')) if data['packet'].get('src') else None
    dst = net_utils.inet_to_str(data['packet'].get('dst')) if data['packet'].get('dst') else None
    sport = data['transport'].get('sport') if data.get('transport') else None
    dport = data['transport'].get('dport') if data.get('transport') else None
    proto = data['transport'].get('type') if data.get('transport') else data['packet']['type']
    return (src, dst, sport, dport, proto)