Iterates over a generator looking for things that match.
(self, name, attrs, text, limit, generator, **kwargs)
| 331 | return r |
| 332 | |
| 333 | def _findAll(self, name, attrs, text, limit, generator, **kwargs): |
| 334 | "Iterates over a generator looking for things that match." |
| 335 | |
| 336 | if isinstance(name, SoupStrainer): |
| 337 | strainer = name |
| 338 | # (Possibly) special case some findAll*(...) searches |
| 339 | elif text is None and not limit and not attrs and not kwargs: |
| 340 | # findAll*(True) |
| 341 | if name is True: |
| 342 | return [element for element in generator() |
| 343 | if isinstance(element, Tag)] |
| 344 | # findAll*('tag-name') |
| 345 | elif isinstance(name, basestring): |
| 346 | return [element for element in generator() |
| 347 | if isinstance(element, Tag) and |
| 348 | element.name == name] |
| 349 | else: |
| 350 | strainer = SoupStrainer(name, attrs, text, **kwargs) |
| 351 | # Build a SoupStrainer |
| 352 | else: |
| 353 | strainer = SoupStrainer(name, attrs, text, **kwargs) |
| 354 | results = ResultSet(strainer) |
| 355 | g = generator() |
| 356 | while True: |
| 357 | try: |
| 358 | i = g.next() |
| 359 | except StopIteration: |
| 360 | break |
| 361 | if i: |
| 362 | found = strainer.search(i) |
| 363 | if found: |
| 364 | results.append(found) |
| 365 | if limit and len(results) >= limit: |
| 366 | break |
| 367 | return results |
| 368 | |
| 369 | #These Generators can be used to navigate starting from both |
| 370 | #NavigableStrings and Tags. |
no test coverage detected