Skip to content

Commit

Permalink
fix publisher property with json_feed
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Oct 11, 2024
1 parent 09683dc commit 20fc587
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 351 deletions.
2 changes: 1 addition & 1 deletion commonmeta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

__title__ = "commonmeta-py"
__version__ = "0.29"
__version__ = "0.30"
__author__ = "Martin Fenner"
__license__ = "MIT"

Expand Down
2 changes: 1 addition & 1 deletion commonmeta/readers/inveniordm_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
"title": "Zenodo",
}
)
publisher = {"name": "Zenodo"}
else:
container = py_.get(meta, "custom_fields.journal:journal")
if container:
Expand All @@ -96,7 +97,6 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
)
if license_:
license_ = dict_to_spdx({"id": license_})
print(license_)
descriptions = format_descriptions(
[
py_.get(meta, "metadata.description"),
Expand Down
14 changes: 10 additions & 4 deletions commonmeta/readers/json_feed_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
if data is None:
return {"state": "not_found"}
meta = data
print(meta)
read_options = kwargs or {}

url = normalize_url(meta.get("url", None))
Expand All @@ -65,10 +66,6 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
title = parse_attributes(meta.get("title", None))
titles = [{"title": sanitize(title)}] if title else None

publisher = py_.get(meta, "blog.title", None)
if publisher is not None:
publisher = {"name": publisher}

date: dict = {}
date["published"] = (
get_date_from_unix_timestamp(meta.get("published_at", None))
Expand Down Expand Up @@ -98,6 +95,15 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
"identifierType": "ISSN" if issn else "URL",
}
)
publisher = (
{"name": "Front Matter"}
if is_rogue_scholar_doi(_id)
or (
container.get("identifierType", None) == "URL"
and furl(container.get("identifier", None)).host == "rogue-scholar.org"
)
else None
)

description = meta.get("summary", None)
if description is not None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name="commonmeta-py"
version="0.29"
version="0.30"
repository = "https://github.com/front-matter/commonmeta-py"
homepage = "https://python.commonmeta.org"
documentation = "https://python.commonmeta.org"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/test-inveniordm_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_software():
},
{"id": "https://doi.org/10.5281/zenodo.5785518", "type": "IsVersionOf"},
]
assert subject.publisher is None
assert subject.publisher == {"name": "Zenodo"}
assert subject.funding_references is None
assert (
subject.descriptions[0]
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_presentation():
assert subject.relations == [
{"id": "https://doi.org/10.5281/zenodo.8173302", "type": "IsVersionOf"},
]
assert subject.publisher is None
assert subject.publisher == {"name": "Zenodo"}
assert subject.funding_references is None
assert (
subject.descriptions[0]
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_publication():
assert subject.relations == [
{"id": "https://doi.org/10.5281/zenodo.5075887", "type": "IsVersionOf"},
]
assert subject.publisher is None
assert subject.publisher == {"name": "Zenodo"}
assert subject.funding_references is None
assert (
subject.descriptions[0]
Expand Down Expand Up @@ -231,7 +231,7 @@ def test_dataset():
{"id": "https://arxiv.org/abs/2004.03688", "type": "IsSupplementTo"},
{"id": "https://doi.org/10.5281/zenodo.3723939", "type": "IsVersionOf"},
]
assert subject.publisher is None
assert subject.publisher == {"name": "Zenodo"}
assert subject.funding_references is None
assert (
subject.descriptions[0]
Expand Down
2 changes: 1 addition & 1 deletion tests/test-inveniordm_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_publication():
py_.get(inveniordm, "metadata.title")
== "The Origins of SARS-CoV-2: A Critical Review"
)
assert py_.get(inveniordm, "metadata.publisher") is None
assert py_.get(inveniordm, "metadata.publisher") == "Zenodo"
assert py_.get(inveniordm, "metadata.publication_date") == "2021-08-18"
assert py_.get(inveniordm, "metadata.languages.0.id") is None
assert py_.get(inveniordm, "metadata.version") == "Authors' final version"
Expand Down
10 changes: 5 additions & 5 deletions tests/test-json_feed_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_wordpress_with_references():
"updated": "2023-06-09T21:54:23",
}
assert subject.publisher == {
"name": "Sauropod Vertebra Picture of the Week",
"name": "Front Matter",
}
assert len(subject.references) > 1
assert subject.references[0] == {
Expand Down Expand Up @@ -230,7 +230,7 @@ def test_post_with_funding():
"updated": "2023-12-07T19:29:37",
}
assert subject.publisher == {
"name": "Upstream",
"name": "Front Matter",
}
assert subject.references is None
assert subject.relations is None
Expand Down Expand Up @@ -320,7 +320,7 @@ def test_post_with_funding_ror():
"updated": "2024-04-28T18:31:57",
}
assert subject.publisher == {
"name": "Blog - Metadata Game Changers",
"name": "Front Matter",
}
assert subject.references is None
assert subject.relations is None
Expand Down Expand Up @@ -372,7 +372,7 @@ def test_ghost_with_institutional_author():
"updated": "2023-10-01T17:34:13",
}
assert subject.publisher == {
"name": "OA.Works Blog",
"name": "Front Matter",
}
assert subject.references is None
assert subject.relations is None
Expand Down Expand Up @@ -520,7 +520,7 @@ def test_ghost_with_personal_name_parsing():
"updated": "2024-05-08T19:10:39",
}
assert subject.publisher == {
"name": "I.D.E.A.S.",
"name": "Front Matter",
}
assert len(subject.references) == 2
assert subject.references[0] == {
Expand Down

0 comments on commit 20fc587

Please sign in to comment.