commonmeta-py 0.87__py3-none-any.whl → 0.89__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 CHANGED
@@ -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.87"
13
+ __version__ = "0.89"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
@@ -11,6 +11,7 @@ from ..utils import (
11
11
  name_to_fos,
12
12
  from_inveniordm,
13
13
  get_language,
14
+ validate_ror,
14
15
  )
15
16
  from ..base_utils import compact, wrap, presence, sanitize
16
17
  from ..author_utils import get_authors
@@ -111,6 +112,7 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
111
112
 
112
113
  references = get_references(wrap(py_.get(meta, "metadata.related_identifiers")))
113
114
  relations = get_relations(wrap(py_.get(meta, "metadata.related_identifiers")))
115
+ funding_references = get_funding_references(wrap(py_.get(meta, "metadata.funding")))
114
116
  if meta.get("conceptdoi", None):
115
117
  relations.append(
116
118
  {
@@ -138,7 +140,7 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
138
140
  "license": presence(license_),
139
141
  "descriptions": descriptions,
140
142
  "geoLocations": None,
141
- # "funding_references": presence(meta.get("fundingReferences", None)),
143
+ "fundingReferences": presence(funding_references),
142
144
  "references": presence(references),
143
145
  "relations": presence(relations),
144
146
  # other properties
@@ -180,6 +182,23 @@ def get_references(references: list) -> list:
180
182
  return [map_reference(i) for i in references if is_reference(i)]
181
183
 
182
184
 
185
+ def get_funding_references(funding_references: list) -> list:
186
+ """get_funding_references"""
187
+
188
+ def map_funding(funding: dict) -> dict:
189
+ """map_funding"""
190
+
191
+ return compact({
192
+ "funderName": py_.get(funding, "funder.name"),
193
+ "funderIdentifier": py_.get(funding, "funder.id"),
194
+ "funderIdentifierType": "ROR" if validate_ror(py_.get(funding, "funder.id")) else None,
195
+ "awardTitle": py_.get(funding, "award.title.en"),
196
+ "awardNumber": py_.get(funding, "award.number"),
197
+ "awardUri": py_.get(funding, "award.identifiers[0].identifier"),
198
+ })
199
+
200
+ return [map_funding(i) for i in funding_references]
201
+
183
202
  def get_file(file: dict) -> str:
184
203
  """get_file"""
185
204
  _type = file.get("type", None)
@@ -205,7 +205,7 @@ def get_funding_references(meta: Optional[dict]) -> Optional[list]:
205
205
 
206
206
  if meta is None or not isinstance(meta, dict):
207
207
  return None
208
-
208
+
209
209
  def format_funding(urls: list) -> list:
210
210
  """format funding. URLs can either be a list of grant IDs or a funder identifier
211
211
  (Open Funder Registry ID or ROR), followed by a grant URL"""
@@ -286,19 +286,11 @@ def get_funding_references(meta: Optional[dict]) -> Optional[list]:
286
286
  if i.get("type", None) == "HasAward"
287
287
  ]
288
288
  )
289
- funding = py_.get(meta, "blog.funding")
290
- if funding is not None:
291
- awards += [
292
- {
293
- "funderName": funding.get("funder_name", None),
294
- "funderIdentifier": funding.get("funder_id", None),
295
- "funderIdentifierType": "Crossref Funder ID",
296
- "awardNumber": funding.get("award_number", None),
297
- }
298
- ]
299
289
  funding_references = py_.get(meta, "funding_references")
300
290
  if funding_references is not None:
301
291
  awards += [compact(i) for i in funding_references]
292
+
293
+ awards += wrap(py_.get(meta, "blog.funding"))
302
294
  return awards
303
295
 
304
296
 
@@ -14,6 +14,7 @@ from ..constants import (
14
14
  from ..utils import (
15
15
  get_language,
16
16
  validate_orcid,
17
+ validate_ror,
17
18
  id_from_url,
18
19
  normalize_url,
19
20
  FOS_MAPPINGS,
@@ -299,9 +300,7 @@ def to_inveniordm_reference(reference: dict) -> dict:
299
300
 
300
301
  def to_inveniordm_funding(funding: dict) -> Optional[dict]:
301
302
  """Convert funding to inveniordm funding"""
302
- if funding.get("funderIdentifierType", None) == "ROR":
303
- funder_identifier = id_from_url(funding.get("funderIdentifier", None))
304
- elif funding.get("funderIdentifierType", None) == "Crossref Funder ID":
303
+ if funding.get("funderIdentifierType", None) == "Crossref Funder ID":
305
304
  # convert to ROR
306
305
  funder_identifier = id_from_url(
307
306
  CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS.get(
@@ -309,11 +308,11 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
309
308
  )
310
309
  )
311
310
  else:
312
- funder_identifier = None
311
+ funder_identifier = validate_ror(funding.get("funderIdentifier", None))
313
312
  award_number = funding.get("awardNumber", None)
314
313
  award_title = funding.get("awardTitle", None)
315
314
  if award_title:
316
- award_title = {"title": {"en": award_title}}
315
+ award_title = {"en": award_title}
317
316
  if funding.get("awardUri", None):
318
317
  award_identifier = funding.get("awardUri", None)
319
318
  scheme = "doi" if normalize_doi(award_identifier) else "url"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commonmeta-py
3
- Version: 0.87
3
+ Version: 0.89
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
@@ -1,4 +1,4 @@
1
- commonmeta/__init__.py,sha256=ToXvSGATGxDBN50c9wETUrtKhpMS0J7cUJ7d5_-sA4U,1911
1
+ commonmeta/__init__.py,sha256=UmlY6KWhmga2K4KGz6RomP17GxZSv1leFctEt3jMM8w,1911
2
2
  commonmeta/api_utils.py,sha256=-ZHGVZZhJqnjnsLtp4-PoeHYbDqL0cQme7W70BEjo4U,2677
3
3
  commonmeta/author_utils.py,sha256=1oQQfxaq7aMQI3rLt8XMufksuBeC8Zht96aJ8vz09Ug,8459
4
4
  commonmeta/base_utils.py,sha256=AsUElA5kT2fw_Osy7Uaj2F6MKeq9yB7d5f2V-h2lh7c,3750
@@ -21,8 +21,8 @@ commonmeta/readers/crossref_xml_reader.py,sha256=yZOh66_4tVS5i0TdEyOa48ckpl7_cj6
21
21
  commonmeta/readers/csl_reader.py,sha256=ynqJeqK9TlHFsmgMREPmKGlcj6tVycpnqDN0N0LjIpw,3201
22
22
  commonmeta/readers/datacite_reader.py,sha256=CdOtxhthrakBoQMsLTdPx6sUCmqtEWo5ICYE6ZsWDdo,12026
23
23
  commonmeta/readers/datacite_xml_reader.py,sha256=nhnO92fZihr1HZlbXjyem-HJXc9_DWLgJ2zeltuPMIg,13041
24
- commonmeta/readers/inveniordm_reader.py,sha256=uS92St68UkO4Adh3PsCu9ox81aO0kek3Y0vneBSDkts,7584
25
- commonmeta/readers/json_feed_reader.py,sha256=yMwLDBe0SUJT0hHSEIHTPLXVpstYqZ_m8E8oKEZJf0A,13596
24
+ commonmeta/readers/inveniordm_reader.py,sha256=F0syoLZ3amzkrEk8efb9WxwhMDY8QM8ctOH32E3fGqM,8358
25
+ commonmeta/readers/json_feed_reader.py,sha256=vzT3RpPhmPuJHLQWk3HajIuCTzut83L0ZfLR__ErP0g,13265
26
26
  commonmeta/readers/kbase_reader.py,sha256=ehKXQsJyPCtaq2FmBxNb2Jb5Nktpx8pNscpmEM6N0A4,6763
27
27
  commonmeta/readers/ris_reader.py,sha256=v6qOd-i2OcMTEFy5RGd3MlYthJcYSU6yzmZ5yHDzmII,3677
28
28
  commonmeta/readers/schema_org_reader.py,sha256=78vYWCZqrYevZsSbx7oVVLm3mlNzi323WNW5E_PL9o0,17234
@@ -67,11 +67,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=mu-yXQvQs_xdYM4MxbTTxxYB5n0lJA5Bq
67
67
  commonmeta/writers/crossref_xml_writer.py,sha256=0Ds494RnXfdfjWw5CLX1kwV2zP7gqffdVqO-X74Uc6c,492
68
68
  commonmeta/writers/csl_writer.py,sha256=W3lryCg4TwXEoBuNhEc2GdU6fe1OrDZ37s1-0h1IGzc,2807
69
69
  commonmeta/writers/datacite_writer.py,sha256=UpDp4Brg5xrmS5T3QYoNi6PPXKdRxAo254eTqnlmNyQ,6304
70
- commonmeta/writers/inveniordm_writer.py,sha256=yWDMYorsJJ4vFNHOmjU8d1_uAfqMwkBxzeV7jtBoC1Q,11515
70
+ commonmeta/writers/inveniordm_writer.py,sha256=-GsTcVMPlbbB9kSTmHP00ZJ1aHIbA21K0LkcuPWBMm8,11429
71
71
  commonmeta/writers/ris_writer.py,sha256=AcnCszS3WY9lF594NbFBtLylsA8ownnYp_XLQJ84Ios,2093
72
72
  commonmeta/writers/schema_org_writer.py,sha256=5j002uCNLdlScZMNQmPjodcVWqaBh2z38zL1H4lo2hY,5741
73
- commonmeta_py-0.87.dist-info/METADATA,sha256=aBKlcvfgtgTUgW5-Z7QbncVPnyMkCkeuH0-SEBLhoxI,7429
74
- commonmeta_py-0.87.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
75
- commonmeta_py-0.87.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
76
- commonmeta_py-0.87.dist-info/licenses/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
77
- commonmeta_py-0.87.dist-info/RECORD,,
73
+ commonmeta_py-0.89.dist-info/METADATA,sha256=M2Wjppi09_3V2op_xctTMRyJmcicLzVksMmp-LKxvaQ,7429
74
+ commonmeta_py-0.89.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
75
+ commonmeta_py-0.89.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
76
+ commonmeta_py-0.89.dist-info/licenses/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
77
+ commonmeta_py-0.89.dist-info/RECORD,,