Skip to content

Commit

Permalink
enhance the text format lookup results
Browse files Browse the repository at this point in the history
  • Loading branch information
wenh06 committed Aug 24, 2024
1 parent cac8286 commit cac12e2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions bib_lookup/bib_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,17 @@ def __call__(

res = self._handle_network_error(res)

if res not in self.lookup_errors and format in ["bibtex", "bibentry"]:
try:
res = self._to_bib_item(res, idtf, align, ignore_fields, label)
self.__cached_lookup_results[identifier] = res
if len(self.__cached_lookup_results) > self.__cache_limit:
self.__cached_lookup_results.popitem(last=False)
except Exception:
res = self.default_err
if res not in self.lookup_errors:
if format in ["bibtex", "bibentry"]:
try:
res = self._to_bib_item(res, idtf, align, ignore_fields, label)
self.__cached_lookup_results[identifier] = res
if len(self.__cached_lookup_results) > self.__cache_limit:
self.__cached_lookup_results.popitem(last=False)
except Exception:
res = self.default_err
elif format == "text":
res = BeautifulSoup(res, "html.parser").get_text()

if self.verbose >= 1:
if res in self.lookup_errors:
Expand Down

0 comments on commit cac12e2

Please sign in to comment.