Skip to content

Commit c552f60

Browse files
authored
Merge pull request #335 from flairNLP/various_bug_fixes
Various bug fixes
2 parents 999a43d + a28981d commit c552f60

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

scripts/generate_parser_test_files.py

-2
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,3 @@ def get_test_article(enum: PublisherEnum) -> Optional[Article]:
100100
test_data_file.write(test_data)
101101
bar.update()
102102
subprocess.call(["git", "add", test_data_file.path], stdout=subprocess.PIPE)
103-
104-
bar.update()

src/fundus/parser/base_parser.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,13 @@ def __call__(self, crawl_date: Optional[Union[datetime, date]] = None) -> BasePa
276276

277277
parsed_date = crawl_date.date() if isinstance(crawl_date, datetime) else crawl_date
278278
parser_cache: _ParserCache
279-
_, parser_cache = next(itertools.dropwhile(lambda x: x[0] < parsed_date, self._parser_mapping.items()))
279+
try:
280+
_, parser_cache = next(itertools.dropwhile(lambda x: x[0] < parsed_date, self._parser_mapping.items()))
281+
except StopIteration:
282+
raise ValueError(
283+
f"Couldn't find a fitting parser valid at date {parsed_date}. "
284+
f"Last valid date is {self._get_latest_cache()().VALID_UNTIL}"
285+
)
280286
return parser_cache()
281287

282288
def __iter__(self) -> Iterator[Type[BaseParser]]:

0 commit comments

Comments
 (0)