Generate each subtotal having matching *anchor*.
771843
def iter_for_anchor(self, anchor):
        """"""
        return (subtotal for subtotal in self._subtotals if subtotal.anchor == anchor)
891917
def all_substrings(s):
    '''  '''
    join = ''.join
    for i in range(1, len(s) + 1):
        for sub in window(s, i):
            yield join(sub)
106959
def items(self):
        
        for anchor_id in self:
            try:
                anchor = self[anchor_id]
            except KeyError:
                assert False, 'Trying to load from missing file or something'

            yield (anchor_id, anchor)
109982
def links(self):
        """"""
        for match in self._href_re.finditer(self.content):
            url = match.group(1) or match.group(2) or match.group(3)
            url = self.clean_link(urlparse.urljoin(self.base_url, url))
            yield Link(url, self)
848515
def anchor_idx(self):
        
        anchor = self.anchor
        if anchor in ["top", "bottom"]:
            return anchor
        return self.valid_elements.get_by_id(anchor).index_in_valids
1146048
function createSubset(keywords, doc) {

    if (!keywords || Object.prototype.toString.call(keywords) !== '[object Array]') {
      return doc;
    }

    var lookup = createLookUp(keywords);

    return traverseThroughObject(lookup, doc);

  }
1143543
def subtree(self, matcher, create = False):
        '''
        
        '''
        if matcher is None:
            return self
        current = self
        for i in range(self.depth, len(matcher.indices)):
            ind = matcher.indices[i]
            if ind is None:
                # match Any
                if hasattr(current, 'any'):
                    current = current.any
                else:
                    if create:
                        cany = MatchTree(current)
                        cany.parentIndex = None
                        current.any = cany
                        current = cany
                    else:
                        return None
            else:
                current2 = current.index.get(ind)
                if current2 is None:
                    if create:
                        cind = MatchTree(current)
                        cind.parentIndex = ind 
                        current.index[ind] = cind
                        current = cind
                    else:
                        return None
                else:
                    current = current2
        return current
149022
def subat(orig, index, replace):
    
    return "".join([(orig[x] if x != index else replace) for x in range(len(orig))])
1160165
def links(self) -> _Links:
        """"""

        def gen():
            for link in self.find('a'):

                try:
                    href = link.attrs['href'].strip()
                    if href and not (href.startswith('#') and self.skip_anchors) and not href.startswith(('javascript:', 'mailto:')):
                        yield href
                except KeyError:
                    pass

        return set(gen())
690463
def match_subselectors(self, el, selectors):
        """"""

        match = True
        for sel in selectors:
            if not self.match_selectors(el, sel):
                match = False
        return match
657658
def subn_filter(s, find, replace, count=0):
    """"""
    return re.gsub(find, replace, count, s)
118563
def select_each(conn, query: str, parameter_groups, name=None):
    """"""

    with conn:
        with conn.cursor(name=name) as cursor:
            for parameters in parameter_groups:
                cursor.execute(query, parameters)
                yield cursor.fetchone()
182560
function getNextRange(ranges, anchor) {
	for (let i = 0; i < ranges.length; i++) {
		if (anchor.isEqual(ranges[i])) {
			// NB may return `undefined`, which is totally fine and means that
			// we should move to next element
			return ranges[i + 1];
		}
	}

	// Keep ranges which are not on the left of given selection
	ranges = ranges.filter(r => anchor.end.isLessThanOrEqual(r.start));

	return ranges[0];
}
492553
def _links(self):
        """"""
        total = 0.0
        for value in self.link.values():
            total += value
        return total
306189
def iflatten(L):
    """"""
    for sublist in L:
        if hasattr(sublist, '__iter__'):
            for item in iflatten(sublist): yield item
        else: yield sublist
1080395
def combine(self, a, b):
        """"""

        for l in (a, b):
            for x in l:
                yield x
47261
def calcRandomAnchors(args, inworld=True):
    
    anchors = []
    rng = (args.patchRadius, args.worldSize - args.patchRadius)
    if not inworld:
        rng = (0, args.worldSize)
    for i in range(args.nPatches):
        anchors.append((random.randrange(rng[0], rng[1]),
                        random.randrange(rng[0], rng[1])))

    return anchors