Content-Length: 264128 | pFad | http://github.com/Freso/openlibrary/commit/c854d54922d6410d6d77d3bf0583fe5b920f90a8

5F Read Work identifiers from file · Freso/openlibrary@c854d54 · GitHub
Skip to content

Commit

Permalink
Read Work identifiers from file
Browse files Browse the repository at this point in the history
This is taking the same steps applied to editions[1] and authors[2] and
applying it to works. `get_work_config()` is currently not used for
anything, probably because we’re still waiting for an actual interface
to edit the Work identifiers[3], so this is more a preliminary step to
ensure that Works will be handled in the same way that Editions and
Authors are. (And to allow for PRs to add Work identifiers while waiting
for that UI.)

[1] internetarchive#9234
    internetarchive#9483
[2] internetarchive#9666
    internetarchive#9769
[3] internetarchive#3430
  • Loading branch information
Freso committed Aug 26, 2024
1 parent 4471420 commit c854d54
Showing 2 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions openlibrary/plugins/openlibrary/config/work/identifiers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
identifiers:
- label: BookBrainz
name: bookbrainz
url: https://bookbrainz.org/work/@@@
website: https://bookbrainz.org
- label: Книга Файнфиков
name: ficbook
notes: ''
url: https://ficbook.net/readfic/@@@
- label: MusicBrainz
name: musicbrainz
url: https://musicbrainz.org/work/@@@
website: https://musicbrainz.org
- label: MyAnimeList
name: myanimelist
notes: ''
url: https://myanimelist.net/manga/@@@
- label: Wikidata
name: wikidata
notes: ''
url: https://www.wikidata.org/wiki/@@@
website: https://wikidata.org
26 changes: 26 additions & 0 deletions openlibrary/plugins/upstream/utils.py
Original file line number Diff line number Diff line change
@@ -1261,6 +1261,32 @@ def _get_edition_config():
)


@public
def get_work_config() -> Storage:
"""Returns the work config.
This just calls _get_work_config(). See that
function's documentation for further details.
"""
return _get_work_config()


@web.memoize
def _get_work_config() -> Storage:
"""Returns the work config.
The results are cached on the first invocation.
The /config/work page currently has no unique options so we
don't load/fetch it here currently.
"""
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
]
return Storage(identifiers=identifiers)


from openlibrary.core.olmarkdown import OLMarkdown


0 comments on commit c854d54

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/Freso/openlibrary/commit/c854d54922d6410d6d77d3bf0583fe5b920f90a8

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy