commonmeta-py 0.37__tar.gz → 0.38__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 (74) hide show
  1. {commonmeta_py-0.37 → commonmeta_py-0.38}/PKG-INFO +1 -1
  2. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/__init__.py +1 -1
  3. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/constants.py +11 -0
  4. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/utils.py +11 -1
  5. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/inveniordm_writer.py +127 -11
  6. {commonmeta_py-0.37 → commonmeta_py-0.38}/pyproject.toml +1 -1
  7. {commonmeta_py-0.37 → commonmeta_py-0.38}/LICENSE +0 -0
  8. {commonmeta_py-0.37 → commonmeta_py-0.38}/README.md +0 -0
  9. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/api_utils.py +0 -0
  10. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/author_utils.py +0 -0
  11. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/base_utils.py +0 -0
  12. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/cli.py +0 -0
  13. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/crossref_utils.py +0 -0
  14. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/date_utils.py +0 -0
  15. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/doi_utils.py +0 -0
  16. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/metadata.py +0 -0
  17. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/__init__.py +0 -0
  18. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/bibtex_reader.py +0 -0
  19. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/cff_reader.py +0 -0
  20. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/codemeta_reader.py +0 -0
  21. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/commonmeta_reader.py +0 -0
  22. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/crossref_reader.py +0 -0
  23. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/crossref_xml_reader.py +0 -0
  24. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/csl_reader.py +0 -0
  25. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/datacite_reader.py +0 -0
  26. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/datacite_xml_reader.py +0 -0
  27. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/inveniordm_reader.py +0 -0
  28. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/json_feed_reader.py +0 -0
  29. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/kbase_reader.py +0 -0
  30. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/ris_reader.py +0 -0
  31. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/readers/schema_org_reader.py +0 -0
  32. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/cff_v1.2.0.json +0 -0
  33. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/commonmeta_v0.12.json +0 -0
  34. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/commonmeta_v0.13.json +0 -0
  35. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/commonmeta_v0.14.json +0 -0
  36. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/AccessIndicators.xsd +0 -0
  37. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3-elements.xsd +0 -0
  38. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3.xsd +0 -0
  39. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/JATS-journalpublishing1-elements.xsd +0 -0
  40. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3-elements.xsd +0 -0
  41. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3.xsd +0 -0
  42. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/JATS-journalpublishing1.xsd +0 -0
  43. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/clinicaltrials.xsd +0 -0
  44. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/common5.3.1.xsd +0 -0
  45. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/crossref5.3.1.xsd +0 -0
  46. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/crossref_query_output3.0.xsd +0 -0
  47. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/fundref.xsd +0 -0
  48. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/module-ali.xsd +0 -0
  49. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref/relations.xsd +0 -0
  50. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/crossref-v0.2.json +0 -0
  51. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/csl-data.json +0 -0
  52. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/datacite-v4.5.json +0 -0
  53. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/datacite-v4.5pr.json +0 -0
  54. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/ietf-bcp-47.json +0 -0
  55. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/iso-8601.json +0 -0
  56. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/spdx/licenses.json +0 -0
  57. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/spdx-schema..json +0 -0
  58. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/styles/apa.csl +0 -0
  59. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/styles/chicago-author-date.csl +0 -0
  60. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/styles/harvard-cite-them-right.csl +0 -0
  61. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/styles/ieee.csl +0 -0
  62. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/styles/modern-language-association.csl +0 -0
  63. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/resources/styles/vancouver.csl +0 -0
  64. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/schema_utils.py +0 -0
  65. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/translators.py +0 -0
  66. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/__init__.py +0 -0
  67. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/bibtex_writer.py +0 -0
  68. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/citation_writer.py +0 -0
  69. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/commonmeta_writer.py +0 -0
  70. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/crossref_xml_writer.py +0 -0
  71. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/csl_writer.py +0 -0
  72. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/datacite_writer.py +0 -0
  73. {commonmeta_py-0.37 → commonmeta_py-0.38}/commonmeta/writers/ris_writer.py +0 -0
  74. {commonmeta_py-0.37 → commonmeta_py-0.38}/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.37
3
+ Version: 0.38
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.37"
13
+ __version__ = "0.38"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
@@ -612,3 +612,14 @@ INVENIORDM_IDENTIFIER_TYPES = {
612
612
  "W3ID": "w3id",
613
613
  "Other": "other",
614
614
  }
615
+
616
+
617
+ CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS = {
618
+ "https://doi.org/10.13039/100000001": "https://ror.org/021nxhr62",
619
+ "https://doi.org/10.13039/501100000780": "https://ror.org/00k4n6c32",
620
+ "https://doi.org/10.13039/501100007601": "https://ror.org/00k4n6c32",
621
+ "https://doi.org/10.13039/501100001659": "https://ror.org/018mejw64",
622
+ "https://doi.org/10.13039/501100006390": "https://ror.org/019whta54",
623
+ "https://doi.org/10.13039/501100001711": "https://ror.org/00yjd3n13",
624
+ "https://doi.org/10.13039/501100003043": "https://ror.org/04wfr2810",
625
+ }
@@ -1076,11 +1076,21 @@ def from_curie(id: Optional[str]) -> Optional[str]:
1076
1076
 
1077
1077
  def issn_as_url(issn: str) -> Optional[str]:
1078
1078
  """ISSN as URL"""
1079
- if issn is None:
1079
+ if normalize_issn(issn) is None:
1080
1080
  return None
1081
1081
  return f"https://portal.issn.org/resource/ISSN/{issn}"
1082
1082
 
1083
1083
 
1084
+ def issn_from_url(url: str) -> Optional[str]:
1085
+ """ISSN from URL"""
1086
+ if url is None:
1087
+ return None
1088
+ match = re.match(r"\Ahttps://portal.issn.org/resource/ISSN/(.+)\Z", url)
1089
+ if match is None:
1090
+ return None
1091
+ return match.group(1)
1092
+
1093
+
1084
1094
  def get_language(lang: str, format: str = "alpha_2") -> Optional[str]:
1085
1095
  """Provide a language string based on ISO 639, with either a name in English,
1086
1096
  ISO 639-1, or ISO 639-3 code as input. Optionally format as alpha_2 (defaul),
@@ -2,12 +2,23 @@
2
2
 
3
3
  import orjson as json
4
4
  from typing import Optional
5
+ from furl import furl
5
6
 
6
7
  from ..base_utils import compact, wrap, parse_attributes, presence
7
8
  from ..date_utils import get_iso8601_date
8
- from ..doi_utils import doi_from_url
9
- from ..constants import CM_TO_INVENIORDM_TRANSLATIONS, INVENIORDM_IDENTIFIER_TYPES
10
- from ..utils import get_language, validate_orcid, id_from_url, FOS_MAPPINGS
9
+ from ..doi_utils import doi_from_url, normalize_doi
10
+ from ..constants import (
11
+ CM_TO_INVENIORDM_TRANSLATIONS,
12
+ INVENIORDM_IDENTIFIER_TYPES,
13
+ CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS,
14
+ )
15
+ from ..utils import (
16
+ get_language,
17
+ validate_orcid,
18
+ id_from_url,
19
+ issn_from_url,
20
+ FOS_MAPPINGS,
21
+ )
11
22
 
12
23
 
13
24
  def write_inveniordm(metadata):
@@ -30,6 +41,26 @@ def write_inveniordm(metadata):
30
41
  for i in wrap(metadata.identifiers)
31
42
  if i.get("id", None) != metadata.id
32
43
  ]
44
+ print(metadata.references)
45
+ print(metadata.relations)
46
+ references = [
47
+ to_inveniordm_related_identifier(i)
48
+ for i in wrap(metadata.references)
49
+ if i.get("id", None)
50
+ ]
51
+ relations = [
52
+ to_inveniordm_related_identifier(i)
53
+ for i in wrap(metadata.relations)
54
+ if i.get("id", None) and i.get("type", None)
55
+ ]
56
+ related_identifiers = references + relations
57
+ funding = compact(
58
+ [
59
+ to_inveniordm_funding(i)
60
+ for i in wrap(metadata.funding_references)
61
+ if i.get("funderName", None)
62
+ ]
63
+ )
33
64
  container = metadata.container if metadata.container else {}
34
65
  journal = (
35
66
  container.get("title", None)
@@ -42,6 +73,14 @@ def write_inveniordm(metadata):
42
73
  if container.get("identifierType", None) == "ISSN"
43
74
  else None
44
75
  )
76
+ dates = []
77
+ if metadata.date.get("updated", None):
78
+ dates.append(
79
+ {
80
+ "date": metadata.date.get("updated"),
81
+ "type": {"id": "updated"},
82
+ }
83
+ )
45
84
 
46
85
  subjects = [to_inveniordm_subject(i) for i in wrap(metadata.subjects)]
47
86
  data = compact(
@@ -67,14 +106,7 @@ def write_inveniordm(metadata):
67
106
  "publication_date": get_iso8601_date(metadata.date.get("published"))
68
107
  if metadata.date.get("published", None)
69
108
  else None,
70
- "dates": [
71
- {
72
- "date": metadata.date.get("updated"),
73
- "type": {"id": "updated"},
74
- }
75
- ]
76
- if metadata.date.get("updated", None)
77
- else None,
109
+ "dates": presence(dates),
78
110
  "subjects": presence(subjects),
79
111
  "description": parse_attributes(
80
112
  metadata.descriptions, content="description", first=True
@@ -88,6 +120,8 @@ def write_inveniordm(metadata):
88
120
  if metadata.language
89
121
  else None,
90
122
  "identifiers": identifiers,
123
+ "related_identifiers": presence(related_identifiers),
124
+ "funding": presence(funding),
91
125
  "version": metadata.version,
92
126
  }
93
127
  ),
@@ -173,3 +207,85 @@ def to_inveniordm_affiliations(creator: dict) -> Optional[list]:
173
207
  return compact(
174
208
  [format_affiliation(i) for i in wrap(creator.get("affiliations", None))]
175
209
  )
210
+
211
+
212
+ def to_inveniordm_related_identifier(relation: dict) -> dict:
213
+ """Convert reference or relation to inveniordm related_identifier"""
214
+ if normalize_doi(relation.get("id", None)):
215
+ identifier = doi_from_url(relation.get("id", None))
216
+ scheme = "doi"
217
+ elif (
218
+ relation.get("type", None) == "IsPartOf"
219
+ and furl(relation.get("id", None)).host == "portal.issn.org"
220
+ ):
221
+ identifier = issn_from_url(relation.get("id", None))
222
+ scheme = "issn"
223
+ else:
224
+ identifier = relation.get("id", None)
225
+ scheme = "url"
226
+
227
+ # normalize relation types
228
+ if relation.get("type", None) is None:
229
+ relation["type"] = "References"
230
+ if relation.get("type") == "HasReview":
231
+ relation["type"] = "IsReviewedBy"
232
+ relation_type = relation.get("type").lower()
233
+ return compact(
234
+ {
235
+ "identifier": identifier,
236
+ "scheme": scheme,
237
+ "relation_type": {
238
+ "id": relation_type,
239
+ },
240
+ }
241
+ )
242
+
243
+
244
+ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
245
+ """Convert funding to inveniordm funding"""
246
+ if funding.get("funderIdentifierType", None) == "ROR":
247
+ funder_identifier = id_from_url(funder_identifier)
248
+ elif funding.get("funderIdentifierType", None) == "Crossref Funder ID":
249
+ # convert to ROR
250
+ funder_identifier = id_from_url(
251
+ CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS.get(
252
+ funding.get("funderIdentifier", None), None
253
+ )
254
+ )
255
+ else:
256
+ funder_identifier = None
257
+ award_title = funding.get("awardTitle", None)
258
+ if award_title:
259
+ award_title = {"title": {"en": award_title}}
260
+ if funding.get("awardUri", None):
261
+ award_identifiers = [
262
+ {
263
+ "scheme": "url",
264
+ "identifier": funding.get("awardUri", None),
265
+ },
266
+ ]
267
+ else:
268
+ award_identifiers = None
269
+ if funding.get("awardNumber", None) or award_title or award_identifiers:
270
+ award = (
271
+ compact(
272
+ {
273
+ "number": funding.get("awardNumber", None),
274
+ "title": award_title,
275
+ "identifiers": award_identifiers,
276
+ }
277
+ ),
278
+ )
279
+ else:
280
+ award = None
281
+ return compact(
282
+ {
283
+ "funder": compact(
284
+ {
285
+ "name": funding.get("funderName"),
286
+ "id": funder_identifier,
287
+ }
288
+ ),
289
+ "award": award,
290
+ }
291
+ )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name="commonmeta-py"
3
- version="0.37"
3
+ version="0.38"
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