commonmeta-py 0.49__py3-none-any.whl → 0.51__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.49"
13
+ __version__ = "0.51"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
commonmeta/date_utils.py CHANGED
@@ -3,6 +3,8 @@ import datetime
3
3
  from datetime import datetime as dt
4
4
  from typing import Optional, Union
5
5
  import dateparser
6
+ from edtf import parse_edtf, DateAndTime, Date
7
+ from edtf.parser.edtf_exceptions import EDTFParseException
6
8
  import pydash as py_
7
9
 
8
10
  from .base_utils import compact
@@ -191,3 +193,17 @@ def normalize_date_dict(data: dict) -> dict:
191
193
  "withdrawn": data.get("Withdrawn", None),
192
194
  }
193
195
  )
196
+
197
+
198
+ def validate_edtf(iso8601_time: Optional[str]) -> Optional[str]:
199
+ """Validate EDTF string using edtf. Return None if invalid"""
200
+ if iso8601_time is None:
201
+ return None
202
+ try:
203
+ edtf = parse_edtf(iso8601_time)
204
+ except EDTFParseException as e:
205
+ print(e)
206
+ return None
207
+ if not isinstance(edtf, (DateAndTime, Date)):
208
+ return None
209
+ return edtf.isoformat()
@@ -2,10 +2,9 @@
2
2
 
3
3
  import orjson as json
4
4
  from typing import Optional
5
- from furl import furl
6
5
 
7
6
  from ..base_utils import compact, wrap, parse_attributes, presence
8
- from ..date_utils import get_iso8601_date
7
+ from ..date_utils import get_iso8601_date, validate_edtf
9
8
  from ..doi_utils import doi_from_url, normalize_doi
10
9
  from ..constants import (
11
10
  CM_TO_INVENIORDM_TRANSLATIONS,
@@ -78,12 +77,15 @@ def write_inveniordm(metadata):
78
77
  )
79
78
  dates = []
80
79
  if metadata.date.get("updated", None):
81
- dates.append(
82
- {
83
- "date": metadata.date.get("updated"),
84
- "type": {"id": "updated"},
85
- }
86
- )
80
+ # workaround for InvenioRDM issue parsing some iso8601 strings
81
+ date_updated = validate_edtf(metadata.date.get("updated"))
82
+ if date_updated:
83
+ dates.append(
84
+ {
85
+ "date": metadata.date.get("updated"),
86
+ "type": {"id": "updated"},
87
+ }
88
+ )
87
89
 
88
90
  subjects = [to_inveniordm_subject(i) for i in wrap(metadata.subjects)]
89
91
  data = compact(
@@ -305,3 +307,5 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
305
307
  ),
306
308
  }
307
309
  )
310
+
311
+
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: commonmeta-py
3
- Version: 0.49
3
+ Version: 0.51
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
7
7
  Keywords: science,metadata,commonmeta,bibtex,csl,crossref,datacite
8
8
  Author: Martin Fenner
9
9
  Author-email: martin@front-matter.io
10
- Requires-Python: >=3.9,<4.0.0
10
+ Requires-Python: >=3.9,<3.13
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.9
@@ -27,11 +27,10 @@ Requires-Dist: click (>=8.1.7,<9.0.0)
27
27
  Requires-Dist: datacite (>=1.1,<2.0)
28
28
  Requires-Dist: dateparser (>=1.1.7,<2.0.0)
29
29
  Requires-Dist: docutils (>=0.19,<0.20)
30
+ Requires-Dist: edtf (>=4.0.1,<5.0.0)
30
31
  Requires-Dist: furl (>=2.1.3,<3.0.0)
31
32
  Requires-Dist: httpx (>=0.27,<0.28)
32
33
  Requires-Dist: jsonschema (>=4.21,<5.0)
33
- Requires-Dist: jupyterlab (>=4.0.9,<5.0.0)
34
- Requires-Dist: jupyterlab-quarto (>=0.2.8,<0.3.0)
35
34
  Requires-Dist: lxml (>=4.8)
36
35
  Requires-Dist: nameparser (>=1.1.2,<2.0.0)
37
36
  Requires-Dist: nbstripout (>=0.6,<0.7)
@@ -43,7 +42,6 @@ Requires-Dist: pycountry (>=23.12.11,<24.0.0)
43
42
  Requires-Dist: pydash (>=7.0,<8.0)
44
43
  Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
45
44
  Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
46
- Requires-Dist: quartodoc (>=0.7.1,<0.8.0)
47
45
  Requires-Dist: setuptools (>=70.0,<71.0)
48
46
  Requires-Dist: simplejson (>=3.18,<4.0)
49
47
  Requires-Dist: sphinx-autodoc-typehints (>=1.19,<2.0)
@@ -1,11 +1,11 @@
1
- commonmeta/__init__.py,sha256=Kx4b9TU_BjS3DqrXMtx7y5hGIjdt3pwv6BgYkZWZHr8,1779
1
+ commonmeta/__init__.py,sha256=2IjFYKV3lYxGb467A96saENnrKUVd-CUR785uUOJf9U,1779
2
2
  commonmeta/api_utils.py,sha256=-ZHGVZZhJqnjnsLtp4-PoeHYbDqL0cQme7W70BEjo4U,2677
3
3
  commonmeta/author_utils.py,sha256=zBIPTgP5n7Zx57xomJ2h7x0dvC0AV8gJ2gPoYeDy5Lo,8348
4
4
  commonmeta/base_utils.py,sha256=AsUElA5kT2fw_Osy7Uaj2F6MKeq9yB7d5f2V-h2lh7c,3750
5
5
  commonmeta/cli.py,sha256=0IJF1SQ1sKPg7M0Gb8fpX2nBps-G0L13o01__M6c5Z0,6104
6
6
  commonmeta/constants.py,sha256=VfjXLkwoV4A5uztH3vgDJ_qrt7PaWGO6QtHbAt4r03c,17501
7
7
  commonmeta/crossref_utils.py,sha256=qJlTZtfKR2shAXQDm8VBYUujKFkTtZTUz19GuMUANaI,22198
8
- commonmeta/date_utils.py,sha256=amF3E0ZJlh8yY5eY3aVXQyAO1x2WuZHJXw-ajOEcdUQ,5808
8
+ commonmeta/date_utils.py,sha256=rJRV4YmWKQWU__iAV8www3cqwaefC0iRKyHwvxrr_XY,6316
9
9
  commonmeta/doi_utils.py,sha256=Dt6K9ADD2ga2WNsOzfX9f29gnubhn7xqeKL7U5pEpBs,8209
10
10
  commonmeta/metadata.py,sha256=cjvCcxW1FMtKCbNKan0zXX0FN6z5orHFGPYsgkp6fSI,12480
11
11
  commonmeta/readers/__init__.py,sha256=vOf7UsOKNoh_ZCuyexxhAmPMt8wjB-pF_CfpWRaN8pk,45
@@ -66,11 +66,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=2qlttCfYpGhfVjrYkjzbIra7AywssRLT3
66
66
  commonmeta/writers/crossref_xml_writer.py,sha256=0Ds494RnXfdfjWw5CLX1kwV2zP7gqffdVqO-X74Uc6c,492
67
67
  commonmeta/writers/csl_writer.py,sha256=rlCeShkvC6ui9By0yVfNCMay_JfaZ4AooUPOPg-g-2M,2819
68
68
  commonmeta/writers/datacite_writer.py,sha256=G7Lr0aZ4sAEdbfXe3dG4Y6AyGUKA9UWr_iiaQRDnV24,6233
69
- commonmeta/writers/inveniordm_writer.py,sha256=L79kjpcV4s6poWfAoxHipxQ2Fb9MlUdK-dA-xqLb2kU,9812
69
+ commonmeta/writers/inveniordm_writer.py,sha256=UMFjUC_uvF8Bkm-Le5mR_nDolagqr9M6XTUH-x2sxYc,9994
70
70
  commonmeta/writers/ris_writer.py,sha256=AcnCszS3WY9lF594NbFBtLylsA8ownnYp_XLQJ84Ios,2093
71
71
  commonmeta/writers/schema_org_writer.py,sha256=5j002uCNLdlScZMNQmPjodcVWqaBh2z38zL1H4lo2hY,5741
72
- commonmeta_py-0.49.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
73
- commonmeta_py-0.49.dist-info/METADATA,sha256=B6Tdzmp8Sp69PMFnUeYFuToBU1sPt9pLZ2ksDAeu3Ko,8331
74
- commonmeta_py-0.49.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
75
- commonmeta_py-0.49.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
76
- commonmeta_py-0.49.dist-info/RECORD,,
72
+ commonmeta_py-0.51.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
73
+ commonmeta_py-0.51.dist-info/METADATA,sha256=WokZ3me1CLd4fkL8Pc6DJON2SjCDbe9kVMtP4gRRyPM,8232
74
+ commonmeta_py-0.51.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
75
+ commonmeta_py-0.51.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
76
+ commonmeta_py-0.51.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 1.9.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any