commonmeta-py 0.136__tar.gz → 0.138__tar.gz

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.
Files changed (90) hide show
  1. {commonmeta_py-0.136 → commonmeta_py-0.138}/PKG-INFO +1 -1
  2. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/__init__.py +1 -1
  3. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/doi_utils.py +1 -0
  4. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/metadata.py +6 -2
  5. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/inveniordm_reader.py +74 -15
  6. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/jsonfeed_reader.py +7 -0
  7. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/utils.py +9 -0
  8. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/inveniordm_writer.py +8 -1
  9. {commonmeta_py-0.136 → commonmeta_py-0.138}/pyproject.toml +1 -1
  10. {commonmeta_py-0.136 → commonmeta_py-0.138}/.gitignore +0 -0
  11. {commonmeta_py-0.136 → commonmeta_py-0.138}/LICENSE +0 -0
  12. {commonmeta_py-0.136 → commonmeta_py-0.138}/README.md +0 -0
  13. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/api_utils.py +0 -0
  14. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/author_utils.py +0 -0
  15. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/base_utils.py +0 -0
  16. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/cli.py +0 -0
  17. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/constants.py +0 -0
  18. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/date_utils.py +0 -0
  19. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/file_utils.py +0 -0
  20. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/__init__.py +0 -0
  21. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/bibtex_reader.py +0 -0
  22. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/cff_reader.py +0 -0
  23. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/codemeta_reader.py +0 -0
  24. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/commonmeta_reader.py +0 -0
  25. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/crossref_reader.py +0 -0
  26. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/crossref_xml_reader.py +0 -0
  27. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/csl_reader.py +0 -0
  28. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/datacite_reader.py +0 -0
  29. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/datacite_xml_reader.py +0 -0
  30. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/kbase_reader.py +0 -0
  31. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/openalex_reader.py +0 -0
  32. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/ris_reader.py +0 -0
  33. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/readers/schema_org_reader.py +0 -0
  34. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/cff_v1.2.0.json +0 -0
  35. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/commonmeta_v0.12.json +0 -0
  36. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/commonmeta_v0.13.json +0 -0
  37. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/commonmeta_v0.14.json +0 -0
  38. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/commonmeta_v0.15.json +0 -0
  39. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/commonmeta_v0.16.json +0 -0
  40. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/AccessIndicators.xsd +0 -0
  41. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3-elements.xsd +0 -0
  42. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3.xsd +0 -0
  43. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/JATS-journalpublishing1-elements.xsd +0 -0
  44. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3-elements.xsd +0 -0
  45. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3.xsd +0 -0
  46. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/JATS-journalpublishing1.xsd +0 -0
  47. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/clinicaltrials.xsd +0 -0
  48. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/common5.4.0.xsd +0 -0
  49. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/crossref5.4.0.xsd +0 -0
  50. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/crossref_query_output3.0.xsd +0 -0
  51. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/doi_resources5.4.0.xsd +0 -0
  52. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/fundingdata5.4.0.xsd +0 -0
  53. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/fundref.xsd +0 -0
  54. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/languages5.4.0.xsd +0 -0
  55. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/mediatypes5.4.0.xsd +0 -0
  56. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/module-ali.xsd +0 -0
  57. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/relations.xsd +0 -0
  58. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/mathml3/mathml3-common.xsd +0 -0
  59. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/mathml3/mathml3-content.xsd +0 -0
  60. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/mathml3/mathml3-presentation.xsd +0 -0
  61. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/mathml3/mathml3-strict-content.xsd +0 -0
  62. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/mathml3/mathml3.xsd +0 -0
  63. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/mathml3/module-ali.xsd +0 -0
  64. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/module-ali.xsd +0 -0
  65. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/xlink.xsd +0 -0
  66. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/standard-modules/xml.xsd +0 -0
  67. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref/xml.xsd +0 -0
  68. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/crossref-v0.2.json +0 -0
  69. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/csl-data.json +0 -0
  70. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/datacite-v4.5.json +0 -0
  71. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/datacite-v4.5pr.json +0 -0
  72. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/spdx/licenses.json +0 -0
  73. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/spdx-schema.json +0 -0
  74. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/styles/apa.csl +0 -0
  75. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/styles/chicago-author-date.csl +0 -0
  76. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/styles/harvard-cite-them-right.csl +0 -0
  77. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/styles/ieee.csl +0 -0
  78. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/styles/modern-language-association.csl +0 -0
  79. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/resources/styles/vancouver.csl +0 -0
  80. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/schema_utils.py +0 -0
  81. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/translators.py +0 -0
  82. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/__init__.py +0 -0
  83. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/bibtex_writer.py +0 -0
  84. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/citation_writer.py +0 -0
  85. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/commonmeta_writer.py +0 -0
  86. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/crossref_xml_writer.py +0 -0
  87. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/csl_writer.py +0 -0
  88. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/datacite_writer.py +0 -0
  89. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/ris_writer.py +0 -0
  90. {commonmeta_py-0.136 → commonmeta_py-0.138}/commonmeta/writers/schema_org_writer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commonmeta-py
3
- Version: 0.136
3
+ Version: 0.138
4
4
  Summary: Library for conversions to/from the Commonmeta scholarly metadata format
5
5
  Project-URL: Homepage, https://python.commonmeta.org
6
6
  Project-URL: Repository, https://github.com/front-matter/commonmeta-py
@@ -10,7 +10,7 @@ commonmeta-py is a Python library to convert scholarly metadata
10
10
  """
11
11
 
12
12
  __title__ = "commonmeta-py"
13
- __version__ = "0.136"
13
+ __version__ = "0.138"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
@@ -315,6 +315,7 @@ def is_rogue_scholar_doi(doi: str, ra: str = "crossref") -> bool:
315
315
  "10.59350",
316
316
  "10.63485",
317
317
  "10.64000",
318
+ "10.64395",
318
319
  ]
319
320
  rogue_scholar_datacite_prefixes = [
320
321
  "10.5438",
@@ -355,13 +355,14 @@ class MetadataList:
355
355
  raise ValueError("No input found")
356
356
  if isinstance(dct, dict):
357
357
  meta = dct
358
+ elif isinstance(dct, list):
359
+ meta = {"items": dct}
358
360
  elif isinstance(dct, (str, bytes)):
359
361
  if path.exists(dct):
360
362
  with open(dct, encoding="utf-8") as file:
361
363
  dct = file.read()
362
364
  self.via = kwargs.get("via", None) or find_from_format(string=dct)
363
365
  meta = self.get_metadata_list(dct)
364
-
365
366
  self.id = meta.get("id", None)
366
367
  self.type = meta.get("type", None)
367
368
  self.title = meta.get("title", None)
@@ -392,12 +393,15 @@ class MetadataList:
392
393
  def get_metadata_list(self, string) -> list:
393
394
  if string is None or not isinstance(string, (str, bytes)):
394
395
  raise ValueError("No input found")
396
+ if self.via in [
397
+ "inveniordm",
398
+ ]:
399
+ return {"items": json.loads(string)}
395
400
  if self.via in [
396
401
  "commonmeta",
397
402
  "crossref",
398
403
  "csl",
399
404
  "datacite",
400
- "inveniordm",
401
405
  "jsonfeed",
402
406
  "openalex",
403
407
  "schema_org",
@@ -1,5 +1,7 @@
1
1
  """InvenioRDM reader for Commonmeta"""
2
2
 
3
+ from typing import Optional
4
+
3
5
  import requests
4
6
  from furl import furl
5
7
  from pydash import py_
@@ -12,8 +14,9 @@ from ..constants import (
12
14
  Commonmeta,
13
15
  )
14
16
  from ..date_utils import strip_milliseconds
15
- from ..doi_utils import doi_as_url, doi_from_url
17
+ from ..doi_utils import doi_as_url, doi_from_url, is_rogue_scholar_doi
16
18
  from ..utils import (
19
+ dict_to_fos,
17
20
  dict_to_spdx,
18
21
  from_inveniordm,
19
22
  get_language,
@@ -40,7 +43,15 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
40
43
  meta = data
41
44
  read_options = kwargs or {}
42
45
 
43
- url = normalize_url(py_.get(meta, "links.self_html"))
46
+ url = normalize_url(py_.get(meta, "links.self_html")) or next(
47
+ (
48
+ normalize_url(identifier.get("identifier"))
49
+ for identifier in wrap(py_.get(meta, "metadata.identifiers", []))
50
+ if identifier.get("scheme") == "url"
51
+ and identifier.get("identifier", None) is not None
52
+ ),
53
+ None,
54
+ )
44
55
  _id = (
45
56
  doi_as_url(meta.get("doi", None))
46
57
  or doi_as_url(py_.get(meta, "pids.doi.identifier"))
@@ -67,10 +78,22 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
67
78
  # titles += [{"title": sanitize("bla")} for i in wrap(additional_titles)]
68
79
 
69
80
  date: dict = {}
70
- date["published"] = py_.get(meta, ("metadata.publication_date"))
71
- if date["published"]:
72
- date["published"] = date["published"].split("/")[0]
73
- date["updated"] = strip_milliseconds(meta.get("updated", None))
81
+ date["published"] = next(
82
+ (
83
+ i.get("date")
84
+ for i in wrap(py_.get(meta, "metadata.dates", []))
85
+ if py_.get(i, "type.id") == "issued" and i.get("date", None) is not None
86
+ ),
87
+ None,
88
+ ) or py_.get(meta, ("metadata.publication_date"))
89
+ date["updated"] = next(
90
+ (
91
+ i.get("date")
92
+ for i in wrap(py_.get(meta, "metadata.dates", []))
93
+ if py_.get(i, "type.id") == "updated" and i.get("date", None) is not None
94
+ ),
95
+ None,
96
+ ) or strip_milliseconds(meta.get("updated", None))
74
97
  f = furl(url)
75
98
  if f.host == "zenodo.org":
76
99
  container = compact(
@@ -89,25 +112,31 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
89
112
  {
90
113
  "type": "Periodical",
91
114
  "title": container.get("title", None),
92
- "identifier": issn,
115
+ "identifier": issn if issn else None,
93
116
  "identifierType": "ISSN" if issn else None,
117
+ "platform": py_.get(meta, "custom_fields.rs:generator", None),
94
118
  }
95
119
  )
96
- license_ = py_.get(meta, "metadata.rights[0].id") or py_.get(
97
- meta, "metadata.license.id"
98
- )
99
- if license_:
100
- license_ = dict_to_spdx({"id": license_})
101
120
  descriptions = format_descriptions(
102
121
  [
103
122
  py_.get(meta, "metadata.description"),
104
123
  py_.get(meta, "metadata.notes"),
105
124
  ]
106
125
  )
126
+ identifiers = py_.compact(
127
+ [format_identifier(i) for i in wrap(py_.get(meta, "metadata.identifiers"))]
128
+ )
107
129
  language = py_.get(meta, "metadata.language") or py_.get(
108
130
  meta, "metadata.languages[0].id"
109
131
  )
110
- subjects = [name_to_fos(i) for i in wrap(py_.get(meta, "metadata.keywords"))]
132
+ license_ = py_.get(meta, "metadata.rights[0].id") or py_.get(
133
+ meta, "metadata.license.id"
134
+ )
135
+ if license_:
136
+ license_ = dict_to_spdx({"id": license_})
137
+ subjects = [dict_to_fos(i) for i in wrap(py_.get(meta, "metadata.subjects"))] or [
138
+ name_to_fos(i) for i in wrap(py_.get(meta, "metadata.keywords"))
139
+ ]
111
140
 
112
141
  references = get_references(wrap(py_.get(meta, "metadata.related_identifiers")))
113
142
  relations = get_relations(wrap(py_.get(meta, "metadata.related_identifiers")))
@@ -119,6 +148,9 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
119
148
  "type": "IsVersionOf",
120
149
  }
121
150
  )
151
+
152
+ content = py_.get(meta, "custom_fields.rs:content_html")
153
+ image = py_.get(meta, "custom_fields.rs:image")
122
154
  files = [get_file(i) for i in wrap(meta.get("files"))]
123
155
 
124
156
  return {
@@ -135,6 +167,7 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
135
167
  # recommended and optional properties
136
168
  # "additional_type": additional_type,
137
169
  "subjects": presence(subjects),
170
+ "identifiers": presence(identifiers),
138
171
  "language": get_language(language),
139
172
  "version": py_.get(meta, "metadata.version"),
140
173
  "license": presence(license_),
@@ -143,10 +176,12 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
143
176
  "fundingReferences": presence(funding_references),
144
177
  "references": presence(references),
145
178
  "relations": presence(relations),
179
+ "content": presence(content),
180
+ "image": presence(image),
181
+ "files": presence(files),
146
182
  # other properties
147
- "files": files,
148
183
  "container": container,
149
- "provider": "DataCite",
184
+ "provider": "Crossref" if is_rogue_scholar_doi(_id) else "Datacite",
150
185
  },
151
186
  **read_options,
152
187
  }
@@ -258,3 +293,27 @@ def format_descriptions(descriptions: list) -> list:
258
293
  for index, i in enumerate(descriptions)
259
294
  if i
260
295
  ]
296
+
297
+
298
+ def format_identifier(identifier: dict) -> Optional[dict]:
299
+ """format_identifier. scheme url is stored as url metadata."""
300
+ if (
301
+ identifier.get("identifier", None) is None
302
+ or identifier.get("scheme", None) is None
303
+ or identifier.get("scheme") == "url"
304
+ ):
305
+ return None
306
+
307
+ scheme = identifier.get("scheme")
308
+ if scheme == "doi":
309
+ identifier_type = "DOI"
310
+ elif scheme == "uuid":
311
+ identifier_type = "UUID"
312
+ elif scheme == "guid":
313
+ identifier_type = "GUID"
314
+ else:
315
+ identifier_type = None
316
+ return {
317
+ "identifier": identifier.get("identifier"),
318
+ "identifierType": identifier_type,
319
+ }
@@ -162,6 +162,13 @@ def read_jsonfeed(data: Optional[dict], **kwargs) -> Commonmeta:
162
162
  references = get_references(wrap(meta.get("reference", None)))
163
163
  funding_references = get_funding_references(meta)
164
164
  relations = get_relations(wrap(meta.get("relationships", None)))
165
+ if meta.get("blog_slug", None):
166
+ relations.append(
167
+ {
168
+ "id": f"https://rogue-scholar.org/api/communities/{meta.get('blog_slug')}",
169
+ "type": "IsPartOf",
170
+ }
171
+ )
165
172
  if issn is not None:
166
173
  relations.append(
167
174
  {
@@ -1367,6 +1367,15 @@ def name_to_fos(name: str) -> Optional[dict]:
1367
1367
  return {"subject": subject}
1368
1368
 
1369
1369
 
1370
+ def dict_to_fos(dct: dict) -> Optional[dict]:
1371
+ """Convert dict to Fields of Science (OECD) subject"""
1372
+ if not isinstance(dct, dict):
1373
+ return None
1374
+ if dct.get("subject", None) is not None:
1375
+ return name_to_fos(dct["subject"])
1376
+ return None
1377
+
1378
+
1370
1379
  def from_curie(id: Optional[str]) -> Optional[str]:
1371
1380
  """from CURIE"""
1372
1381
  if id is None:
@@ -382,9 +382,16 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
382
382
 
383
383
  def write_inveniordm_list(metalist):
384
384
  """Write InvenioRDM list"""
385
+
385
386
  if metalist is None:
386
387
  return None
387
- return [write_inveniordm(item) for item in metalist.items]
388
+
389
+ def write_item(item):
390
+ """write inveniordm item for inveniordm list"""
391
+
392
+ return write_inveniordm(item)
393
+
394
+ return [write_item(item) for item in metalist.items]
388
395
 
389
396
 
390
397
  def push_inveniordm(metadata: Commonmeta, host: str, token: str, **kwargs) -> Dict:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "commonmeta-py"
3
- version = "0.136"
3
+ version = "0.138"
4
4
  description = "Library for conversions to/from the Commonmeta scholarly metadata format"
5
5
  authors = [{ name = "Martin Fenner", email = "martin@front-matter.io" }]
6
6
  requires-python = ">=3.9,<4.0"
File without changes
File without changes
File without changes