forked from mirrors/bookwyrm
Merge pull request #1658 from bookwyrm-social/isni-check
More thoroughly checking if title is set to avoid error
This commit is contained in:
commit
9b0b771a40
1 changed files with 4 additions and 2 deletions
|
@ -104,12 +104,14 @@ def find_authors_by_name(name_string, description=False):
|
||||||
# otherwise just grab the first title listing
|
# otherwise just grab the first title listing
|
||||||
titles.append(element.find(".//title"))
|
titles.append(element.find(".//title"))
|
||||||
|
|
||||||
if titles is not None:
|
if titles:
|
||||||
# some of the "titles" in ISNI are a little ...iffy
|
# some of the "titles" in ISNI are a little ...iffy
|
||||||
# '@' is used by ISNI/OCLC to index the starting point ignoring stop words
|
# '@' is used by ISNI/OCLC to index the starting point ignoring stop words
|
||||||
# (e.g. "The @Government of no one")
|
# (e.g. "The @Government of no one")
|
||||||
title_elements = [
|
title_elements = [
|
||||||
e for e in titles if not e.text.replace("@", "").isnumeric()
|
e
|
||||||
|
for e in titles
|
||||||
|
if hasattr(e, "text") and not e.text.replace("@", "").isnumeric()
|
||||||
]
|
]
|
||||||
if len(title_elements):
|
if len(title_elements):
|
||||||
author.bio = title_elements[0].text.replace("@", "")
|
author.bio = title_elements[0].text.replace("@", "")
|
||||||
|
|
Loading…
Reference in a new issue