Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 26, 2024
1 parent 555aa5a commit 3171df3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions openlibrary/catalog/marc/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def read_location(rec: MarcBase) -> list[str] | None:
return remove_duplicates(found) if fields else None


def read_contributions(rec: MarcBase, authors: list=[]) -> dict[str, Any]:
def read_contributions(rec: MarcBase, authors: list = []) -> dict[str, Any]:

Check failure on line 575 in openlibrary/catalog/marc/parse.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (B006)

openlibrary/catalog/marc/parse.py:575:55: B006 Do not use mutable data structures for argument defaults
"""
Reads contributors from a MARC record
and use values in 7xx fields to set 'authors'
Expand All @@ -582,15 +582,16 @@ def read_contributions(rec: MarcBase, authors: list=[]) -> dict[str, Any]:
:param (MarcBinary | MarcXml) rec:
:rtype: dict
"""

def form_name(values: list) -> str:
name = [v.strip(' /,;:') for v in values]
return remove_trailing_dot(' '.join(name))

want = { # Added Entries --
'700': 'abcdeq', # Personal Name
'710': 'ab', # Corporate Name
'711': 'acdn', # Meeting Name
'720': 'a', # Uncontrolled Name
'710': 'ab', # Corporate Name
'711': 'acdn', # Meeting Name
'720': 'a', # Uncontrolled Name
}
ret: dict[str, Any] = {}
skip_authors = set()
Expand All @@ -614,9 +615,7 @@ def form_name(values: list) -> str:
break
name = form_name(f.get_subfield_values(want[tag]))
if tag == '710':
ret['authors'] = [
{'entity_type': 'org', 'name': name}
]
ret['authors'] = [{'entity_type': 'org', 'name': name}]
skip_authors.add(name)
break
elif tag == '711':
Expand Down Expand Up @@ -645,7 +644,9 @@ def form_name(values: list) -> str:
if basicname in skip_authors or name in skip_authors:
continue
cur = tuple(f.get_subfields(want[tag]))
contributer_name = remove_trailing_dot(' '.join(strip_foc(i[1]) for i in cur).strip(','))
contributer_name = remove_trailing_dot(
' '.join(strip_foc(i[1]) for i in cur).strip(',')
)
ret.setdefault('contributions', []).append(contributer_name)
return ret

Expand Down

0 comments on commit 3171df3

Please sign in to comment.