diff options
author | Wolfgang Müller | 2024-11-14 22:05:05 +0100 |
---|---|---|
committer | Wolfgang Müller | 2024-11-14 22:05:05 +0100 |
commit | 47d464fbfc1dd4174c4f0ab39268297c14b972a3 (patch) | |
tree | 7e302077861d05741df0e9d4f327f93e8f2632b9 /src | |
parent | e3b667cfac8344e0582740774024cf03ece1445b (diff) | |
download | hircine-47d464fbfc1dd4174c4f0ab39268297c14b972a3.tar.gz |
backend/scraper: Have collect() ignore None results
If a parser function returned None we yield it regardless, even though
it won't have any impact further down the line. Instead clean up the
collect() stream as early as possible.
Diffstat (limited to 'src')
-rw-r--r-- | src/hircine/scraper/__init__.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/hircine/scraper/__init__.py b/src/hircine/scraper/__init__.py index bc83436..4606f4a 100644 --- a/src/hircine/scraper/__init__.py +++ b/src/hircine/scraper/__init__.py @@ -86,13 +86,16 @@ class Scraper(ABC): transformers = [] def generator(): - for result in self.scrape(): - if callable(result): + for item in self.scrape(): + if callable(item): try: - yield result() + result = item() except ScrapeWarning as e: self.log_warning(e) else: + result = item + + if result is not None: yield result gen = generator() |