commonmeta-py 0.56__tar.gz → 0.58__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 (75) hide show
  1. {commonmeta_py-0.56 → commonmeta_py-0.58}/PKG-INFO +1 -1
  2. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/__init__.py +1 -1
  3. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/json_feed_reader.py +7 -1
  4. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/utils.py +1 -0
  5. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/inveniordm_writer.py +56 -14
  6. {commonmeta_py-0.56 → commonmeta_py-0.58}/pyproject.toml +1 -1
  7. {commonmeta_py-0.56 → commonmeta_py-0.58}/LICENSE +0 -0
  8. {commonmeta_py-0.56 → commonmeta_py-0.58}/README.md +0 -0
  9. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/api_utils.py +0 -0
  10. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/author_utils.py +0 -0
  11. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/base_utils.py +0 -0
  12. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/cli.py +0 -0
  13. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/constants.py +0 -0
  14. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/crossref_utils.py +0 -0
  15. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/date_utils.py +0 -0
  16. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/doi_utils.py +0 -0
  17. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/metadata.py +0 -0
  18. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/__init__.py +0 -0
  19. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/bibtex_reader.py +0 -0
  20. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/cff_reader.py +0 -0
  21. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/codemeta_reader.py +0 -0
  22. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/commonmeta_reader.py +0 -0
  23. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/crossref_reader.py +0 -0
  24. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/crossref_xml_reader.py +0 -0
  25. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/csl_reader.py +0 -0
  26. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/datacite_reader.py +0 -0
  27. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/datacite_xml_reader.py +0 -0
  28. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/inveniordm_reader.py +0 -0
  29. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/kbase_reader.py +0 -0
  30. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/ris_reader.py +0 -0
  31. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/readers/schema_org_reader.py +0 -0
  32. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/cff_v1.2.0.json +0 -0
  33. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/commonmeta_v0.12.json +0 -0
  34. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/commonmeta_v0.13.json +0 -0
  35. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/commonmeta_v0.14.json +0 -0
  36. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/commonmeta_v0.15.json +0 -0
  37. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/AccessIndicators.xsd +0 -0
  38. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3-elements.xsd +0 -0
  39. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3.xsd +0 -0
  40. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/JATS-journalpublishing1-elements.xsd +0 -0
  41. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3-elements.xsd +0 -0
  42. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3.xsd +0 -0
  43. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/JATS-journalpublishing1.xsd +0 -0
  44. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/clinicaltrials.xsd +0 -0
  45. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/common5.3.1.xsd +0 -0
  46. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/crossref5.3.1.xsd +0 -0
  47. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/crossref_query_output3.0.xsd +0 -0
  48. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/fundref.xsd +0 -0
  49. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/module-ali.xsd +0 -0
  50. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref/relations.xsd +0 -0
  51. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/crossref-v0.2.json +0 -0
  52. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/csl-data.json +0 -0
  53. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/datacite-v4.5.json +0 -0
  54. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/datacite-v4.5pr.json +0 -0
  55. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/ietf-bcp-47.json +0 -0
  56. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/iso-8601.json +0 -0
  57. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/spdx/licenses.json +0 -0
  58. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/spdx-schema.json +0 -0
  59. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/styles/apa.csl +0 -0
  60. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/styles/chicago-author-date.csl +0 -0
  61. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/styles/harvard-cite-them-right.csl +0 -0
  62. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/styles/ieee.csl +0 -0
  63. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/styles/modern-language-association.csl +0 -0
  64. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/resources/styles/vancouver.csl +0 -0
  65. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/schema_utils.py +0 -0
  66. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/translators.py +0 -0
  67. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/__init__.py +0 -0
  68. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/bibtex_writer.py +0 -0
  69. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/citation_writer.py +0 -0
  70. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/commonmeta_writer.py +0 -0
  71. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/crossref_xml_writer.py +0 -0
  72. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/csl_writer.py +0 -0
  73. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/datacite_writer.py +0 -0
  74. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/ris_writer.py +0 -0
  75. {commonmeta_py-0.56 → commonmeta_py-0.58}/commonmeta/writers/schema_org_writer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: commonmeta-py
3
- Version: 0.56
3
+ Version: 0.58
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
@@ -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.56"
13
+ __version__ = "0.58"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
@@ -50,7 +50,9 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
50
50
  url = None
51
51
  if py_.get(meta, "blog.status", None) == "active":
52
52
  url = normalize_url(meta.get("url", None))
53
- elif py_.get(meta, "blog.status", None) == "archived":
53
+ elif py_.get(meta, "blog.status", None) == "archived" and meta.get(
54
+ "archive_url", None
55
+ ):
54
56
  url = normalize_url(meta.get("archive_url", None))
55
57
  _id = normalize_doi(read_options.get("doi", None) or meta.get("doi", None)) or url
56
58
  _type = "Article"
@@ -183,6 +185,7 @@ def get_references(references: list) -> list:
183
185
  return compact(
184
186
  {
185
187
  "id": id_,
188
+ "key": reference.get("key", None),
186
189
  "title": reference.get("title", None),
187
190
  "publicationYear": reference.get("publicationYear", None),
188
191
  }
@@ -195,6 +198,9 @@ def get_references(references: list) -> list:
195
198
  return compact(
196
199
  {
197
200
  "id": id_,
201
+ "key": reference.get("key", None),
202
+ "title": reference.get("title", None),
203
+ "publicationYear": reference.get("publicationYear", None),
198
204
  }
199
205
  )
200
206
 
@@ -111,6 +111,7 @@ FOS_MAPPINGS = {
111
111
  "Agricultural biotechnology": "http://www.oecd.org/science/inno/38235147",
112
112
  "Other agricultural sciences": "http://www.oecd.org/science/inno/38235147",
113
113
  "Social science": "http://www.oecd.org/science/inno/38235147.pdf?5",
114
+ "Social sciences": "http://www.oecd.org/science/inno/38235147.pdf?5",
114
115
  "Psychology": "http://www.oecd.org/science/inno/38235147.pdf?5.1",
115
116
  "Economics and business": "http://www.oecd.org/science/inno/38235147.pdf?5.2",
116
117
  "Educational sciences": "http://www.oecd.org/science/inno/38235147.pdf?5.3",
@@ -15,6 +15,7 @@ from ..utils import (
15
15
  get_language,
16
16
  validate_orcid,
17
17
  id_from_url,
18
+ normalize_url,
18
19
  FOS_MAPPINGS,
19
20
  )
20
21
 
@@ -45,17 +46,12 @@ def write_inveniordm(metadata):
45
46
  "scheme": "url",
46
47
  }
47
48
  )
48
- references = [
49
- to_inveniordm_related_identifier(i)
50
- for i in wrap(metadata.references)
51
- if i.get("id", None)
52
- ]
53
- relations = [
49
+ references = [to_inveniordm_reference(i) for i in wrap(metadata.references)]
50
+ related_identifiers = [
54
51
  to_inveniordm_related_identifier(i)
55
52
  for i in wrap(metadata.relations)
56
53
  if i.get("id", None) and i.get("type", None) != "IsPartOf"
57
54
  ]
58
- related_identifiers = references + relations
59
55
  funding = compact(
60
56
  [
61
57
  to_inveniordm_funding(i)
@@ -129,6 +125,7 @@ def write_inveniordm(metadata):
129
125
  if metadata.language
130
126
  else None,
131
127
  "identifiers": identifiers,
128
+ "references": presence(references),
132
129
  "related_identifiers": presence(related_identifiers),
133
130
  "funding": presence(funding),
134
131
  "version": metadata.version,
@@ -223,19 +220,19 @@ def to_inveniordm_affiliations(creator: dict) -> Optional[list]:
223
220
 
224
221
 
225
222
  def to_inveniordm_related_identifier(relation: dict) -> dict:
226
- """Convert reference or relation to inveniordm related_identifier"""
223
+ """Convert relation to inveniordm related_identifier"""
227
224
  if normalize_doi(relation.get("id", None)):
228
225
  identifier = doi_from_url(relation.get("id", None))
229
226
  scheme = "doi"
230
- else:
227
+ elif normalize_url(relation.get("id", None)):
231
228
  identifier = relation.get("id", None)
232
229
  scheme = "url"
230
+ else:
231
+ return None
233
232
 
234
233
  # normalize relation types
235
234
  relation_type = relation.get("type")
236
- if relation.get("type", None) is None:
237
- relation_type = "References"
238
- elif relation.get("type") == "HasReview":
235
+ if relation.get("type") == "HasReview":
239
236
  relation_type = "IsReviewedBy"
240
237
  elif relation.get("type") == "IsPreprintOf":
241
238
  relation_type = "IsPreviousVersionOf"
@@ -251,6 +248,53 @@ def to_inveniordm_related_identifier(relation: dict) -> dict:
251
248
  )
252
249
 
253
250
 
251
+ def to_inveniordm_reference(reference: dict) -> dict:
252
+ """Convert reference to inveniordm reference"""
253
+ if normalize_doi(reference.get("id", None)):
254
+ identifier = doi_from_url(reference.get("id", None))
255
+ scheme = "doi"
256
+ elif normalize_url(reference.get("id", None)):
257
+ identifier = reference.get("id", None)
258
+ scheme = "url"
259
+ else:
260
+ return None
261
+
262
+ if reference.get("unstructured", None) is None:
263
+ # use title as unstructured reference
264
+ if reference.get("title", None):
265
+ unstructured = reference.get("title")
266
+ else:
267
+ unstructured = "Unknown title"
268
+
269
+ if reference.get("publicationYear", None):
270
+ unstructured += " (" + reference.get("publicationYear") + ")."
271
+
272
+ return compact(
273
+ {
274
+ "reference": unstructured,
275
+ "scheme": scheme,
276
+ "identifier": identifier,
277
+ }
278
+ )
279
+ else:
280
+ unstructured = reference.get("unstructured")
281
+
282
+ # remove optional trailing period
283
+ unstructured = unstructured.rstrip(" .")
284
+
285
+ if reference.get("id", None):
286
+ # remove duplicate ID from unstructured reference
287
+ unstructured = unstructured.replace(reference.get("id"), "")
288
+
289
+ return compact(
290
+ {
291
+ "reference": unstructured,
292
+ "scheme": scheme,
293
+ "identifier": identifier,
294
+ }
295
+ )
296
+
297
+
254
298
  def to_inveniordm_funding(funding: dict) -> Optional[dict]:
255
299
  """Convert funding to inveniordm funding"""
256
300
  if funding.get("funderIdentifierType", None) == "ROR":
@@ -311,5 +355,3 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
311
355
  ),
312
356
  }
313
357
  )
314
-
315
-
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name="commonmeta-py"
3
- version="0.56"
3
+ version="0.58"
4
4
  repository = "https://github.com/front-matter/commonmeta-py"
5
5
  homepage = "https://python.commonmeta.org"
6
6
  documentation = "https://python.commonmeta.org"
File without changes
File without changes