Iterates over a generator looking for things that match.
542377
def _findAll(self, name, attrs, text, limit, generator, **kwargs):
        ""

        if isinstance(name, SoupStrainer):
            strainer = name
        # (Possibly) special case some findAll*(...) searches
        elif text is None and not limit and not attrs and not kwargs:
            # findAll*(True)
            if name is True:
                return [element for element in generator()
                        if isinstance(element, Tag)]
            # findAll*('tag-name')
            elif isinstance(name, basestring):
                return [element for element in generator()
                        if isinstance(element, Tag) and
                        element.name == name]
            else:
                strainer = SoupStrainer(name, attrs, text, **kwargs)
        # Build a SoupStrainer
        else:
            strainer = SoupStrainer(name, attrs, text, **kwargs)
        results = ResultSet(strainer)
        g = generator()
        while True:
            try:
                i = g.next()
            except StopIteration:
                break
            if i:
                found = strainer.search(i)
                if found:
                    results.append(found)
                    if limit and len(results) >= limit:
                        break
        return results
565088
def match_indices(match):
    """"""
    a, b, size = match
    for i in range(size):
        yield a + i, b + i
306189
def iflatten(L):
    """"""
    for sublist in L:
        if hasattr(sublist, '__iter__'):
            for item in iflatten(sublist): yield item
        else: yield sublist
445547
def fnmatch_multiple(candidates, pattern):
    '''
    
    '''
    # Make sure that candidates is iterable to avoid a TypeError when we try to
    # iterate over its items.
    try:
        candidates_iter = iter(candidates)
    except TypeError:
        return None

    for candidate in candidates_iter:
        try:
            if fnmatch.fnmatch(candidate, pattern):
                return candidate
        except TypeError:
            pass
    return None
117329
def iter_islast(iterable):
    
    it = iter(iterable)
    prev = next(it)
    for item in it:
        yield prev, False
        prev = item
    yield prev, True
140822
def iter(self):
        """"""
        if self.patterns:
            patterns = list(self.patterns)
            for pattern in patterns:
                yield pattern
240371
def list_of(*generators):
    

    class ListOfGenerators(ArbitraryInterface):
        """
        A closure class around the generators specified above, which
        generates a list of the generators.
        """

        @classmethod
        def arbitrary(cls):
            """
            Generate a list of the enclosed generators.
            """
            arbitrary_list = []
            for generator in generators:
                arbitrary_list += [
                    arbitrary(generator)
                    # max_length / len(generators):
                    for _ in range(arbitrary(int) % 100)
                ]
            return arbitrary_list

    ListOfGenerators.__name__ = ''.join([
        'list_of(', ', '.join(generator.__name__ for generator in generators),
        ')'
    ])
    return ListOfGenerators
1105680
def iteritems(self, multi=False):
        """"""
        for key, values in dict.iteritems(self):
            if multi:
                for value in values:
                    yield key, value
            else:
                yield key, values[0]
50241
def _iter(self):
        
        keys = self.keys()
        while keys:
            key = keys[0]
            yield key
            keys = keys[1:]
463307
def peekiter(iterable):
    """"""
    it = iter(iterable)
    one = next(it)

    def gen():
        """Generator that returns first and proxy other items from source"""
        yield one
        while True:
            yield next(it)
    return (one, gen())
75582
def isgenerator(obj):
    '''  '''
    return isinstance(obj, GeneratorType) or (hasattr(obj, 'iterable') and
           isinstance(getattr(obj, 'iterable'), GeneratorType))
391616
def get_by_flags(self, flags):
        """"""
        for reg in self._reg_infos:
            if reg.flags & flags == flags:
                yield reg
1373422
def set_of(*generators):
    

    class SetOfGenerators(ArbitraryInterface):
        """
        A closure class around the generators specified above, which
        generates a set of the generators.
        """

        @classmethod
        def arbitrary(cls):
            """
            Generate a set of the enclosed generators.
            """
            arbitrary_set = set()
            for generator in generators:
                arbitrary_set |= {
                    arbitrary(generator)
                    # max_size / len(generators):
                    for _ in range(arbitrary(int) % 100)
                }
            return arbitrary_set

    SetOfGenerators.__name__ = ''.join([
        'set_of(', ', '.join(generator.__name__ for generator in generators),
        ')'
    ])
    return SetOfGenerators
1232107
def each_match(regex, type, default = nil)
			real_hash.each_key() { |key|
				if (matchinfo = regex.match(key))
					value = fetch(key, type, default)
					if (!value.nil?)
						yield(matchinfo, value)
					end
				end
			}
		end
961968
def iterator(self):
        

        for item in self.query.results():
            obj = self.resource(**item)

            yield obj
300434
def get_current_generator(self):
        """"""
        int_index=int(len(self.generators)*wrap(0,1.0,self.inspect_value('index')))
        return self.generators[int_index]
1124215
def get(self):
        ''
        # If you attempt to use a generator comprehension below, it will
        # consume the StopIteration exception and just return an empty tuple,
        # instead of stopping iteration normally
        return tuple([(x.name(), x.get()) for x in self._generators])