commonmeta-py 0.25__py3-none-any.whl → 0.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commonmeta/__init__.py +1 -1
- commonmeta/author_utils.py +0 -1
- commonmeta/constants.py +1 -1
- commonmeta/readers/inveniordm_reader.py +35 -20
- commonmeta/writers/inveniordm_writer.py +27 -5
- {commonmeta_py-0.25.dist-info → commonmeta_py-0.27.dist-info}/METADATA +2 -2
- {commonmeta_py-0.25.dist-info → commonmeta_py-0.27.dist-info}/RECORD +10 -10
- {commonmeta_py-0.25.dist-info → commonmeta_py-0.27.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.25.dist-info → commonmeta_py-0.27.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.25.dist-info → commonmeta_py-0.27.dist-info}/entry_points.txt +0 -0
commonmeta/__init__.py
CHANGED
commonmeta/author_utils.py
CHANGED
commonmeta/constants.py
CHANGED
@@ -238,9 +238,9 @@ INVENIORDM_TO_CM_TRANSLATIONS = {
|
|
238
238
|
"book": "Book",
|
239
239
|
"section": "BookChapter",
|
240
240
|
"conferencepaper": "ProceedingsArticle",
|
241
|
-
"article": "JournalArticle",
|
242
241
|
"patent": "Patent",
|
243
242
|
"publication": "JournalArticle",
|
243
|
+
"publication-preprint": "Article",
|
244
244
|
"report": "Report",
|
245
245
|
"softwaredocumentation": "Software",
|
246
246
|
"thesis": "Dissertation",
|
@@ -1,4 +1,5 @@
|
|
1
1
|
"""InvenioRDM reader for Commonmeta"""
|
2
|
+
|
2
3
|
import httpx
|
3
4
|
from pydash import py_
|
4
5
|
from furl import furl
|
@@ -40,19 +41,24 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
|
|
40
41
|
read_options = kwargs or {}
|
41
42
|
|
42
43
|
url = normalize_url(py_.get(meta, "links.self_html"))
|
43
|
-
_id =
|
44
|
-
|
45
|
-
|
44
|
+
_id = (
|
45
|
+
doi_as_url(meta.get("doi", None))
|
46
|
+
or doi_as_url(py_.get(meta, "pids.doi.identifier"))
|
47
|
+
or url
|
48
|
+
)
|
49
|
+
resource_type = py_.get(meta, "metadata.resource_type.type") or py_.get(
|
50
|
+
meta, "metadata.resource_type.id"
|
51
|
+
)
|
52
|
+
print(resource_type)
|
46
53
|
_type = INVENIORDM_TO_CM_TRANSLATIONS.get(resource_type, "Other")
|
47
|
-
|
54
|
+
|
48
55
|
contributors = py_.get(meta, "metadata.creators")
|
49
|
-
print(contributors)
|
50
|
-
|
51
56
|
contributors = get_authors(
|
52
57
|
from_inveniordm(wrap(contributors)),
|
53
58
|
)
|
54
|
-
publisher =
|
55
|
-
|
59
|
+
publisher = meta.get("publisher", None) or py_.get(meta, "metadata.publisher")
|
60
|
+
if publisher:
|
61
|
+
publisher = {"name": publisher}
|
56
62
|
title = py_.get(meta, "metadata.title")
|
57
63
|
titles = [{"title": sanitize(title)}] if title else None
|
58
64
|
additional_titles = py_.get(meta, "metadata.additional_titles")
|
@@ -73,26 +79,33 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
|
|
73
79
|
"title": "Zenodo",
|
74
80
|
}
|
75
81
|
)
|
76
|
-
elif f.host in ["rogue-scholar.org", "beta.rogue-scholar.org", "demo.front-matter.io"]:
|
77
|
-
container = compact(
|
78
|
-
{
|
79
|
-
"type": "Repository",
|
80
|
-
"title": "Rogue Scholar",
|
81
|
-
}
|
82
|
-
)
|
83
82
|
else:
|
84
|
-
container =
|
85
|
-
|
83
|
+
container = py_.get(meta, "custom_fields.journal:journal")
|
84
|
+
if container:
|
85
|
+
issn = py_.get(meta, "custom_fields.journal:journal.issn")
|
86
|
+
container = compact(
|
87
|
+
{
|
88
|
+
"type": "Periodical",
|
89
|
+
"title": container.get("title", None),
|
90
|
+
"identifier": issn,
|
91
|
+
"identifierType": "ISSN" if issn else None,
|
92
|
+
}
|
93
|
+
)
|
94
|
+
license_ = py_.get(meta, "metadata.rights[0].id") or py_.get(
|
95
|
+
meta, "metadata.license.id"
|
96
|
+
)
|
86
97
|
if license_:
|
87
98
|
license_ = dict_to_spdx({"id": license_})
|
88
|
-
|
99
|
+
print(license_)
|
89
100
|
descriptions = format_descriptions(
|
90
101
|
[
|
91
102
|
py_.get(meta, "metadata.description"),
|
92
103
|
py_.get(meta, "metadata.notes"),
|
93
104
|
]
|
94
105
|
)
|
95
|
-
language = py_.get(meta, "metadata.language") or py_.get(
|
106
|
+
language = py_.get(meta, "metadata.language") or py_.get(
|
107
|
+
meta, "metadata.languages[0].id"
|
108
|
+
)
|
96
109
|
subjects = [name_to_fos(i) for i in wrap(py_.get(meta, "metadata.keywords"))]
|
97
110
|
|
98
111
|
references = get_references(wrap(py_.get(meta, "metadata.related_identifiers")))
|
@@ -188,7 +201,9 @@ def get_relations(relations: list) -> list:
|
|
188
201
|
"""map_relation"""
|
189
202
|
identifier = relation.get("identifier", None)
|
190
203
|
scheme = relation.get("scheme", None)
|
191
|
-
relation_type = relation.get("relation", None) or relation.get(
|
204
|
+
relation_type = relation.get("relation", None) or relation.get(
|
205
|
+
"relation_type", None
|
206
|
+
)
|
192
207
|
if scheme == "doi":
|
193
208
|
identifier = doi_as_url(identifier)
|
194
209
|
else:
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""InvenioRDM writer for commonmeta-py"""
|
2
2
|
|
3
3
|
import orjson as json
|
4
|
+
import pydash as py_
|
4
5
|
|
5
6
|
from ..utils import to_inveniordm
|
6
7
|
from ..base_utils import compact, wrap, presence, parse_attributes
|
@@ -27,26 +28,44 @@ def write_inveniordm(metadata):
|
|
27
28
|
for i in wrap(metadata.identifiers)
|
28
29
|
if i.get("id", None) != metadata.id
|
29
30
|
]
|
30
|
-
|
31
|
+
container = metadata.container if metadata.container else {}
|
32
|
+
journal = (
|
33
|
+
container.get("title", None)
|
34
|
+
if _type not in ["inbook", "inproceedings"]
|
35
|
+
and container.get("type") in ["Journal", "Periodical"]
|
36
|
+
else None
|
37
|
+
)
|
38
|
+
issn = (
|
39
|
+
container.get("identifier", None)
|
40
|
+
if container.get("identifierType", None) == "ISSN"
|
41
|
+
else None
|
42
|
+
)
|
31
43
|
data = compact(
|
32
44
|
{
|
45
|
+
"pids": {
|
46
|
+
"doi": {
|
47
|
+
"identifier": doi_from_url(metadata.id),
|
48
|
+
"provider": "external",
|
49
|
+
},
|
50
|
+
},
|
51
|
+
"access": {"record": "public", "files": "public"},
|
52
|
+
"files": {"enabled": True},
|
33
53
|
"metadata": {
|
34
54
|
"resource_type": {"id": _type},
|
35
|
-
"doi": doi_from_url(metadata.id),
|
36
55
|
"creators": creators,
|
37
56
|
"title": parse_attributes(metadata.titles, content="title", first=True),
|
38
|
-
"publisher": publisher.get("name", None),
|
57
|
+
"publisher": metadata.publisher.get("name", None) if metadata.publisher else None,
|
39
58
|
"publication_date": metadata.date.get("published")
|
40
59
|
if metadata.date.get("published", None)
|
41
60
|
else None,
|
61
|
+
"dates": [{"date": metadata.date.get("updated"), "type": "updated"}],
|
42
62
|
"subjects": parse_attributes(
|
43
63
|
wrap(metadata.subjects), content="subject", first=False
|
44
64
|
),
|
45
|
-
"contributors": to_inveniordm(wrap(metadata.contributors)),
|
46
65
|
"description": parse_attributes(
|
47
66
|
metadata.descriptions, content="description", first=True
|
48
67
|
),
|
49
|
-
"
|
68
|
+
"rights": [{"id": metadata.license.get("id", None)}]
|
50
69
|
if metadata.license
|
51
70
|
else None,
|
52
71
|
"languages": [{"id": get_language(metadata.language, format="alpha_3")}]
|
@@ -55,6 +74,9 @@ def write_inveniordm(metadata):
|
|
55
74
|
"identifiers": identifiers,
|
56
75
|
"version": metadata.version,
|
57
76
|
},
|
77
|
+
"custom_fields": {
|
78
|
+
"journal:journal": compact({"title": journal, "issn": issn}),
|
79
|
+
},
|
58
80
|
}
|
59
81
|
)
|
60
82
|
return json.dumps(data)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: commonmeta-py
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.27
|
4
4
|
Summary: Library for conversions to/from the Commonmeta scholarly metadata format
|
5
5
|
Home-page: https://python.commonmeta.org
|
6
6
|
License: MIT
|
@@ -102,7 +102,7 @@ Commometa-py reads and/or writes these metadata formats:
|
|
102
102
|
| [CSV](ttps://en.wikipedia.org/wiki/Comma-separated_values) | csv | text/csv | no | later |
|
103
103
|
| [BibTex](http://en.wikipedia.org/wiki/BibTeX) | bibtex | application/x-bibtex | later | yes |
|
104
104
|
| [RIS](http://en.wikipedia.org/wiki/RIS_(file_format)) | ris | application/x-research-info-systems | yes | yes |
|
105
|
-
| [InvenioRDM](https://inveniordm.docs.cern.ch/reference/metadata/) | inveniordm | application/vnd.inveniordm.v1+json |
|
105
|
+
| [InvenioRDM](https://inveniordm.docs.cern.ch/reference/metadata/) | inveniordm | application/vnd.inveniordm.v1+json | yes | yes |
|
106
106
|
| [JSON Feed](https://www.jsonfeed.org/) | json_feed_item | application/feed+json | yes | later |
|
107
107
|
|
108
108
|
_commonmeta_: the Commonmeta format is the native format for the library and used internally.
|
@@ -1,9 +1,9 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=_iH5WihLf4sQNUkDVnMlVNm0CabhZKxSYHa6b0Qd93A,1779
|
2
2
|
commonmeta/api_utils.py,sha256=-ZHGVZZhJqnjnsLtp4-PoeHYbDqL0cQme7W70BEjo4U,2677
|
3
|
-
commonmeta/author_utils.py,sha256=
|
3
|
+
commonmeta/author_utils.py,sha256=zBIPTgP5n7Zx57xomJ2h7x0dvC0AV8gJ2gPoYeDy5Lo,8348
|
4
4
|
commonmeta/base_utils.py,sha256=0t6fr9XGeeTBoMlKSAMI7p_EmKsA6wYRW0roEBXVcc8,3722
|
5
5
|
commonmeta/cli.py,sha256=0IJF1SQ1sKPg7M0Gb8fpX2nBps-G0L13o01__M6c5Z0,6104
|
6
|
-
commonmeta/constants.py,sha256=
|
6
|
+
commonmeta/constants.py,sha256=L9WeJL6e5G_PlSmmjYFBCILGfVeLlLrkujGBH-Yy-rA,15885
|
7
7
|
commonmeta/crossref_utils.py,sha256=uffkjbs3732yCzD7hEA5lZ9ZZ648Mftl_n0GGcnEPHc,21918
|
8
8
|
commonmeta/date_utils.py,sha256=amF3E0ZJlh8yY5eY3aVXQyAO1x2WuZHJXw-ajOEcdUQ,5808
|
9
9
|
commonmeta/doi_utils.py,sha256=Dt6K9ADD2ga2WNsOzfX9f29gnubhn7xqeKL7U5pEpBs,8209
|
@@ -18,7 +18,7 @@ commonmeta/readers/crossref_xml_reader.py,sha256=QF1A-r3OJbykBTH9YMSxusT3-KSKmmz
|
|
18
18
|
commonmeta/readers/csl_reader.py,sha256=5V_sHSJwcAWJmhB8SYk199nB96BWYX1Sq9vkQ3iEmAY,3164
|
19
19
|
commonmeta/readers/datacite_reader.py,sha256=CdOtxhthrakBoQMsLTdPx6sUCmqtEWo5ICYE6ZsWDdo,12026
|
20
20
|
commonmeta/readers/datacite_xml_reader.py,sha256=nhnO92fZihr1HZlbXjyem-HJXc9_DWLgJ2zeltuPMIg,13041
|
21
|
-
commonmeta/readers/inveniordm_reader.py,sha256=
|
21
|
+
commonmeta/readers/inveniordm_reader.py,sha256=Itm8HfN5PnNw0PMiw3FImmthpcCI_tCKpgHCstGKvb8,7502
|
22
22
|
commonmeta/readers/json_feed_reader.py,sha256=Ke-J_xZJk6DltFMPrdFBF8iGhs_3EMzpBbDg7wcw678,13773
|
23
23
|
commonmeta/readers/kbase_reader.py,sha256=NpIK-_fh5QFN4Q_ArqcrnH4tS5zR1gqbPew6VEjrUbs,6764
|
24
24
|
commonmeta/readers/ris_reader.py,sha256=v6qOd-i2OcMTEFy5RGd3MlYthJcYSU6yzmZ5yHDzmII,3677
|
@@ -65,11 +65,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=2qlttCfYpGhfVjrYkjzbIra7AywssRLT3
|
|
65
65
|
commonmeta/writers/crossref_xml_writer.py,sha256=0Ds494RnXfdfjWw5CLX1kwV2zP7gqffdVqO-X74Uc6c,492
|
66
66
|
commonmeta/writers/csl_writer.py,sha256=rlCeShkvC6ui9By0yVfNCMay_JfaZ4AooUPOPg-g-2M,2819
|
67
67
|
commonmeta/writers/datacite_writer.py,sha256=G7Lr0aZ4sAEdbfXe3dG4Y6AyGUKA9UWr_iiaQRDnV24,6233
|
68
|
-
commonmeta/writers/inveniordm_writer.py,sha256=
|
68
|
+
commonmeta/writers/inveniordm_writer.py,sha256=wEQV2L4F3cCCw2i72g-1ClfOwuRjpfsM0fTAszBmWKM,4137
|
69
69
|
commonmeta/writers/ris_writer.py,sha256=AcnCszS3WY9lF594NbFBtLylsA8ownnYp_XLQJ84Ios,2093
|
70
70
|
commonmeta/writers/schema_org_writer.py,sha256=5j002uCNLdlScZMNQmPjodcVWqaBh2z38zL1H4lo2hY,5741
|
71
|
-
commonmeta_py-0.
|
72
|
-
commonmeta_py-0.
|
73
|
-
commonmeta_py-0.
|
74
|
-
commonmeta_py-0.
|
75
|
-
commonmeta_py-0.
|
71
|
+
commonmeta_py-0.27.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
72
|
+
commonmeta_py-0.27.dist-info/METADATA,sha256=4AaRJYyOpBiWd2_niOGGC_LJqBbJsVV223gy-LuqOZk,8331
|
73
|
+
commonmeta_py-0.27.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
74
|
+
commonmeta_py-0.27.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
75
|
+
commonmeta_py-0.27.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|