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 Dec 2, 2024
1 parent 807342f commit e97fcd0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
12 changes: 12 additions & 0 deletions openlibrary/i18n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3528,6 +3528,18 @@ msgstr ""
msgid "Links"
msgstr ""

#: books/edit.html
msgid "Work Identifiers"
msgstr ""

#: books/edit.html
msgid "Do you know any identifiers for this work?"
msgstr ""

#: books/edit.html
msgid "Like, Wikidata?"
msgstr ""

#: FulltextSearchSuggestionItem.html IABook.html SearchResultsWork.html
#: books/edition-sort.html jsdef/LazyWorkPreview.html lists/list_overview.html
#: lists/preview.html lists/snippet.html lists/widget.html
Expand Down
12 changes: 10 additions & 2 deletions openlibrary/plugins/upstream/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
borrow,
)
from openlibrary.plugins.upstream.table_of_contents import TableOfContents
from openlibrary.plugins.upstream.utils import MultiDict, get_edition_config, get_work_config
from openlibrary.plugins.upstream.utils import (
MultiDict,
get_edition_config,
get_work_config,
)
from openlibrary.plugins.worksearch.code import works_by_author
from openlibrary.plugins.worksearch.search import get_solr
from openlibrary.utils import dateutil # noqa: F401 side effects may be needed
Expand Down Expand Up @@ -789,14 +793,17 @@ def process(name, value):
if not isinstance(value, list):
value = [value]

id = id_map.get(name) or web.storage(name=name, label=name, url_format=None)
id = id_map.get(name) or web.storage(
name=name, label=name, url_format=None
)
for v in value:
d[id.name] = web.storage(
name=id.name,
label=id.label,
value=v,
url=id.get('url') and id.url.replace('@@@', v.replace(' ', '')),
)

for name in names:
process(name, self[name])

Expand All @@ -805,6 +812,7 @@ def process(name, value):

return d


class Subject(client.Thing):
pass

Expand Down
6 changes: 3 additions & 3 deletions openlibrary/plugins/upstream/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,19 +1218,19 @@ def _get_edition_config():
classifications=classifications, identifiers=identifiers, roles=roles
)


@public
def get_work_config() -> Storage:
return _get_work_config()


@web.memoize
def _get_work_config() -> Storage:
"""
Pulls the list of all work identifiers from the identifiers.yml file
and inserts them into a Storage object?
"""
with open(
'openlibrary/plugins/openlibrary/config/work/identifiers.yml'
) as in_file:
with open('openlibrary/plugins/openlibrary/config/work/identifiers.yml') as in_file:
id_config = yaml.safe_load(in_file)
identifiers = [
Storage(id) for id in id_config.get('identifiers', []) if 'name' in id
Expand Down

0 comments on commit e97fcd0

Please sign in to comment.