commonmeta-py 0.58__tar.gz → 0.60__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.58 → commonmeta_py-0.60}/PKG-INFO +2 -2
  2. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/__init__.py +3 -2
  3. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/cli.py +1 -2
  4. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/doi_utils.py +32 -3
  5. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/csl_reader.py +2 -2
  6. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/json_feed_reader.py +4 -2
  7. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/utils.py +0 -13
  8. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/inveniordm_writer.py +1 -1
  9. {commonmeta_py-0.58 → commonmeta_py-0.60}/pyproject.toml +2 -2
  10. {commonmeta_py-0.58 → commonmeta_py-0.60}/LICENSE +0 -0
  11. {commonmeta_py-0.58 → commonmeta_py-0.60}/README.md +0 -0
  12. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/api_utils.py +0 -0
  13. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/author_utils.py +0 -0
  14. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/base_utils.py +0 -0
  15. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/constants.py +0 -0
  16. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/crossref_utils.py +0 -0
  17. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/date_utils.py +0 -0
  18. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/metadata.py +0 -0
  19. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/__init__.py +0 -0
  20. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/bibtex_reader.py +0 -0
  21. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/cff_reader.py +0 -0
  22. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/codemeta_reader.py +0 -0
  23. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/commonmeta_reader.py +0 -0
  24. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/crossref_reader.py +0 -0
  25. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/crossref_xml_reader.py +0 -0
  26. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/datacite_reader.py +0 -0
  27. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/datacite_xml_reader.py +0 -0
  28. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/inveniordm_reader.py +0 -0
  29. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/kbase_reader.py +0 -0
  30. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/ris_reader.py +0 -0
  31. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/readers/schema_org_reader.py +0 -0
  32. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/cff_v1.2.0.json +0 -0
  33. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/commonmeta_v0.12.json +0 -0
  34. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/commonmeta_v0.13.json +0 -0
  35. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/commonmeta_v0.14.json +0 -0
  36. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/commonmeta_v0.15.json +0 -0
  37. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/AccessIndicators.xsd +0 -0
  38. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3-elements.xsd +0 -0
  39. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3.xsd +0 -0
  40. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/JATS-journalpublishing1-elements.xsd +0 -0
  41. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3-elements.xsd +0 -0
  42. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/JATS-journalpublishing1-mathml3.xsd +0 -0
  43. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/JATS-journalpublishing1.xsd +0 -0
  44. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/clinicaltrials.xsd +0 -0
  45. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/common5.3.1.xsd +0 -0
  46. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/crossref5.3.1.xsd +0 -0
  47. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/crossref_query_output3.0.xsd +0 -0
  48. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/fundref.xsd +0 -0
  49. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/module-ali.xsd +0 -0
  50. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref/relations.xsd +0 -0
  51. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/crossref-v0.2.json +0 -0
  52. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/csl-data.json +0 -0
  53. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/datacite-v4.5.json +0 -0
  54. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/datacite-v4.5pr.json +0 -0
  55. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/ietf-bcp-47.json +0 -0
  56. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/iso-8601.json +0 -0
  57. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/spdx/licenses.json +0 -0
  58. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/spdx-schema.json +0 -0
  59. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/styles/apa.csl +0 -0
  60. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/styles/chicago-author-date.csl +0 -0
  61. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/styles/harvard-cite-them-right.csl +0 -0
  62. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/styles/ieee.csl +0 -0
  63. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/styles/modern-language-association.csl +0 -0
  64. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/resources/styles/vancouver.csl +0 -0
  65. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/schema_utils.py +0 -0
  66. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/translators.py +0 -0
  67. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/__init__.py +0 -0
  68. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/bibtex_writer.py +0 -0
  69. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/citation_writer.py +0 -0
  70. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/commonmeta_writer.py +0 -0
  71. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/crossref_xml_writer.py +0 -0
  72. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/csl_writer.py +0 -0
  73. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/datacite_writer.py +0 -0
  74. {commonmeta_py-0.58 → commonmeta_py-0.60}/commonmeta/writers/ris_writer.py +0 -0
  75. {commonmeta_py-0.58 → commonmeta_py-0.60}/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.58
3
+ Version: 0.60
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
@@ -38,7 +38,7 @@ Requires-Dist: nbstripout (>=0.6,<0.7)
38
38
  Requires-Dist: nh3 (>=0.2.14,<0.3.0)
39
39
  Requires-Dist: orjson (>=3.9.14,<4.0.0)
40
40
  Requires-Dist: orjsonl (>=1.0.0,<2.0.0)
41
- Requires-Dist: pikepdf (>=8.14.0,<9.0.0)
41
+ Requires-Dist: pikepdf (>=8.14,<10.0)
42
42
  Requires-Dist: pycountry (>=23.12.11,<24.0.0)
43
43
  Requires-Dist: pydash (>=7.0,<8.0)
44
44
  Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
@@ -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.58"
13
+ __version__ = "0.60"
14
14
  __author__ = "Martin Fenner"
15
15
  __license__ = "MIT"
16
16
 
@@ -54,7 +54,6 @@ from .utils import (
54
54
  validate_orcid,
55
55
  validate_url,
56
56
  get_language,
57
- encode_doi,
58
57
  name_to_fos,
59
58
  from_json_feed,
60
59
  )
@@ -88,6 +87,8 @@ from .doi_utils import (
88
87
  doi_from_url,
89
88
  doi_as_url,
90
89
  doi_resolver,
90
+ decode_doi,
91
+ encode_doi,
91
92
  datacite_api_url,
92
93
  get_doi_ra,
93
94
  normalize_doi,
@@ -5,8 +5,7 @@ import orjson as json
5
5
 
6
6
  from commonmeta import Metadata, MetadataList # __version__
7
7
  from commonmeta.api_utils import update_ghost_post_via_api
8
- from commonmeta.doi_utils import validate_prefix
9
- from commonmeta.utils import encode_doi, decode_doi
8
+ from commonmeta.doi_utils import validate_prefix, encode_doi, decode_doi
10
9
  from commonmeta.readers.json_feed_reader import (
11
10
  get_json_feed_item_uuid,
12
11
  )
@@ -4,6 +4,7 @@ import re
4
4
  from typing import Optional
5
5
  import httpx
6
6
  from furl import furl
7
+ import base32_lib as base32
7
8
 
8
9
  from .base_utils import compact
9
10
 
@@ -131,6 +132,34 @@ def get_doi_ra(doi) -> Optional[str]:
131
132
  return response.json()[0].get("RA", None)
132
133
 
133
134
 
135
+ def encode_doi(prefix, number: Optional[int] = None, checksum: bool = True) -> str:
136
+ """Generate a DOI using the DOI prefix and a random base32 suffix"""
137
+ if isinstance(number, int):
138
+ suffix = base32.encode(number, split_every=5, checksum=checksum)
139
+ else:
140
+ suffix = base32.generate(length=10, split_every=5, checksum=True)
141
+ print("s", suffix)
142
+ return f"https://doi.org/{prefix}/{suffix}"
143
+
144
+
145
+ def decode_doi(doi: str, checksum: bool = True) -> int:
146
+ """Decode a DOI to a number"""
147
+ try:
148
+ doi = validate_doi(doi)
149
+ if doi is None:
150
+ return 0
151
+ suffix = doi.split("/", maxsplit=1)[1]
152
+ print(suffix, checksum)
153
+ if checksum:
154
+ number = base32.decode(suffix, checksum=True)
155
+ print("n", number)
156
+ number = base32.decode(suffix)
157
+ print("nn", number)
158
+ return number
159
+ except ValueError:
160
+ return 0
161
+
162
+
134
163
  def get_crossref_member(member_id) -> Optional[dict]:
135
164
  """Return the Crossref member for a given member_id"""
136
165
  response = httpx.get("https://api.crossref.org/members/" + member_id, timeout=10)
@@ -263,11 +292,11 @@ def is_rogue_scholar_doi(doi: str) -> bool:
263
292
  """Return True if DOI is from Rogue Scholar"""
264
293
  prefix = validate_prefix(doi)
265
294
  return prefix in [
266
- "10.34732", # not managed by Front Matter
295
+ "10.34732", # not managed by Front Matter
267
296
  "10.53731",
268
297
  "10.54900",
269
- "10.57689", # not managed by Front Matter
270
- "10.58079", # not managed by Front Matter
298
+ "10.57689", # not managed by Front Matter
299
+ "10.58079", # not managed by Front Matter
271
300
  "10.59348",
272
301
  "10.59349",
273
302
  "10.59350",
@@ -1,9 +1,9 @@
1
1
  """CSL-JSON reader for commonmeta-py"""
2
- from ..utils import dict_to_spdx, from_csl, normalize_id, name_to_fos, encode_doi
2
+ from ..utils import dict_to_spdx, from_csl, normalize_id, name_to_fos
3
3
  from ..base_utils import wrap, compact, sanitize, presence
4
4
  from ..author_utils import get_authors
5
5
  from ..date_utils import get_date_from_date_parts
6
- from ..doi_utils import get_doi_ra, doi_from_url
6
+ from ..doi_utils import get_doi_ra, doi_from_url, encode_doi
7
7
  from ..constants import (
8
8
  CSL_TO_CM_TRANSLATIONS,
9
9
  Commonmeta,
@@ -14,7 +14,6 @@ from ..utils import (
14
14
  name_to_fos,
15
15
  validate_url,
16
16
  validate_ror,
17
- encode_doi,
18
17
  issn_as_url,
19
18
  )
20
19
  from ..author_utils import get_authors
@@ -26,6 +25,7 @@ from ..doi_utils import (
26
25
  validate_doi,
27
26
  doi_from_url,
28
27
  is_rogue_scholar_doi,
28
+ encode_doi,
29
29
  )
30
30
  from ..constants import Commonmeta
31
31
 
@@ -188,6 +188,7 @@ def get_references(references: list) -> list:
188
188
  "key": reference.get("key", None),
189
189
  "title": reference.get("title", None),
190
190
  "publicationYear": reference.get("publicationYear", None),
191
+ "unstructured": reference.get("unstructured", None),
191
192
  }
192
193
  )
193
194
 
@@ -201,12 +202,13 @@ def get_references(references: list) -> list:
201
202
  "key": reference.get("key", None),
202
203
  "title": reference.get("title", None),
203
204
  "publicationYear": reference.get("publicationYear", None),
205
+ "unstructured": reference.get("unstructured", None),
204
206
  }
205
207
  )
206
208
 
207
209
  def number_reference(reference: dict, index: int) -> dict:
208
210
  """number reference"""
209
- reference["key"] = f"ref{index +1}"
211
+ reference["key"] = f"ref{index + 1}"
210
212
  return reference
211
213
 
212
214
  references = [get_reference(i) for i in references if i.get("id", None)]
@@ -11,7 +11,6 @@ from furl import furl
11
11
  import bibtexparser
12
12
  from bs4 import BeautifulSoup
13
13
  from pydash import py_
14
- import base32_lib as base32
15
14
  import pycountry
16
15
 
17
16
  from .base_utils import wrap, compact, parse_attributes
@@ -1092,18 +1091,6 @@ def name_to_fos(name: str) -> Optional[dict]:
1092
1091
  return {"subject": subject}
1093
1092
 
1094
1093
 
1095
- def encode_doi(prefix):
1096
- """Generate a DOI using the DOI prefix and a random base32 suffix"""
1097
- suffix = base32.generate(length=10, split_every=5, checksum=True)
1098
- return f"https://doi.org/{prefix}/{suffix}"
1099
-
1100
-
1101
- def decode_doi(doi: str) -> int:
1102
- """Decode a DOI to a number"""
1103
- suffix = doi.split("/", maxsplit=5)[-1]
1104
- return base32.decode(suffix)
1105
-
1106
-
1107
1094
  def from_curie(id: Optional[str]) -> Optional[str]:
1108
1095
  """from CURIE"""
1109
1096
  if id is None:
@@ -38,7 +38,7 @@ def write_inveniordm(metadata):
38
38
  ),
39
39
  }
40
40
  for i in wrap(metadata.identifiers)
41
- if i.get("identifier", None) != metadata.id
41
+ if i.get("identifierType", None) != "DOI"
42
42
  ]
43
43
  identifiers.append(
44
44
  {
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name="commonmeta-py"
3
- version="0.58"
3
+ version="0.60"
4
4
  repository = "https://github.com/front-matter/commonmeta-py"
5
5
  homepage = "https://python.commonmeta.org"
6
6
  documentation = "https://python.commonmeta.org"
@@ -48,7 +48,7 @@ asyncclick = "^8.1.7.1"
48
48
  anyio = "^4.2.0"
49
49
  orjson = "^3.9.14"
50
50
  orjsonl = "^1.0.0"
51
- pikepdf = "^8.14.0"
51
+ pikepdf = ">=8.14,<10.0"
52
52
  edtf = "^5.0.0"
53
53
 
54
54
  [tool.poetry.group.docs]
File without changes
File without changes