commonmeta-py 0.59__py3-none-any.whl → 0.61__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 +3 -2
- commonmeta/cli.py +1 -2
- commonmeta/doi_utils.py +32 -3
- commonmeta/readers/crossref_reader.py +2 -0
- commonmeta/readers/csl_reader.py +2 -2
- commonmeta/readers/json_feed_reader.py +4 -2
- commonmeta/utils.py +0 -21
- {commonmeta_py-0.59.dist-info → commonmeta_py-0.61.dist-info}/METADATA +1 -1
- {commonmeta_py-0.59.dist-info → commonmeta_py-0.61.dist-info}/RECORD +12 -12
- {commonmeta_py-0.59.dist-info → commonmeta_py-0.61.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.59.dist-info → commonmeta_py-0.61.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.59.dist-info → commonmeta_py-0.61.dist-info}/entry_points.txt +0 -0
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.
|
13
|
+
__version__ = "0.61"
|
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,
|
commonmeta/cli.py
CHANGED
@@ -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
|
)
|
commonmeta/doi_utils.py
CHANGED
@@ -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",
|
295
|
+
"10.34732", # not managed by Front Matter
|
267
296
|
"10.53731",
|
268
297
|
"10.54900",
|
269
|
-
"10.57689",
|
270
|
-
"10.58079",
|
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",
|
@@ -339,6 +339,8 @@ def get_container(meta: dict, issn: str) -> dict:
|
|
339
339
|
)
|
340
340
|
isbn = isbn["value"] if isbn else None
|
341
341
|
container_title = parse_attributes(meta.get("container-title", None), first=True)
|
342
|
+
if not container_title and container_type in ["Periodical"]:
|
343
|
+
container_title = py_.get(meta, "institution.0.name")
|
342
344
|
volume = meta.get("volume", None)
|
343
345
|
issue = py_.get(meta, "journal-issue.issue")
|
344
346
|
if meta.get("page", None):
|
commonmeta/readers/csl_reader.py
CHANGED
@@ -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
|
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)]
|
commonmeta/utils.py
CHANGED
@@ -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,26 +1091,6 @@ def name_to_fos(name: str) -> Optional[dict]:
|
|
1092
1091
|
return {"subject": subject}
|
1093
1092
|
|
1094
1093
|
|
1095
|
-
def encode_doi(prefix, number: Optional[int]= None, checksum: bool = True) -> str:
|
1096
|
-
"""Generate a DOI using the DOI prefix and a random base32 suffix"""
|
1097
|
-
if isinstance(number, int):
|
1098
|
-
suffix = base32.encode(number, split_every=5, checksum=checksum)
|
1099
|
-
else:
|
1100
|
-
suffix = base32.generate(length=10, split_every=5, checksum=True)
|
1101
|
-
return f"https://doi.org/{prefix}/{suffix}"
|
1102
|
-
|
1103
|
-
|
1104
|
-
def decode_doi(doi: str, checksum: bool = True) -> int:
|
1105
|
-
"""Decode a DOI to a number"""
|
1106
|
-
try:
|
1107
|
-
suffix = doi.split("/", maxsplit=5)[-1]
|
1108
|
-
if checksum:
|
1109
|
-
return base32.decode(suffix, checksum=True)
|
1110
|
-
return base32.decode(suffix)
|
1111
|
-
except ValueError:
|
1112
|
-
return 0
|
1113
|
-
|
1114
|
-
|
1115
1094
|
def from_curie(id: Optional[str]) -> Optional[str]:
|
1116
1095
|
"""from CURIE"""
|
1117
1096
|
if id is None:
|
@@ -1,25 +1,25 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=mpMVDsuOZKg_uoM4S0GKd7huJDFJqyJmX4ER-SIp1wc,1795
|
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
|
-
commonmeta/cli.py,sha256=
|
5
|
+
commonmeta/cli.py,sha256=sOI9BJTePnljVcXcZ95N7TKXDT283XpjUaak7bMnbr0,6076
|
6
6
|
commonmeta/constants.py,sha256=VfjXLkwoV4A5uztH3vgDJ_qrt7PaWGO6QtHbAt4r03c,17501
|
7
7
|
commonmeta/crossref_utils.py,sha256=qJlTZtfKR2shAXQDm8VBYUujKFkTtZTUz19GuMUANaI,22198
|
8
8
|
commonmeta/date_utils.py,sha256=rJRV4YmWKQWU__iAV8www3cqwaefC0iRKyHwvxrr_XY,6316
|
9
|
-
commonmeta/doi_utils.py,sha256=
|
9
|
+
commonmeta/doi_utils.py,sha256=xlYQq-qkqhz07CLKpL_WfxZBT8maXgB9-TvQHlL2ZoY,9266
|
10
10
|
commonmeta/metadata.py,sha256=cjvCcxW1FMtKCbNKan0zXX0FN6z5orHFGPYsgkp6fSI,12480
|
11
11
|
commonmeta/readers/__init__.py,sha256=vOf7UsOKNoh_ZCuyexxhAmPMt8wjB-pF_CfpWRaN8pk,45
|
12
12
|
commonmeta/readers/bibtex_reader.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
commonmeta/readers/cff_reader.py,sha256=5HMFUvjE1zb-zfpQSNM8vtB0YunD0reom99hn8N0xKc,6144
|
14
14
|
commonmeta/readers/codemeta_reader.py,sha256=efv2V1WPfdrKLQNxgSvoripdWqS2M6CwXWSGiRuzRtU,3658
|
15
15
|
commonmeta/readers/commonmeta_reader.py,sha256=gNjdsJ-671-pXmBdzy1NybkQ29q9_qtorFoK2D-zStA,302
|
16
|
-
commonmeta/readers/crossref_reader.py,sha256=
|
16
|
+
commonmeta/readers/crossref_reader.py,sha256=zIMD81eYwpx9RlHaDwiZs2f9O4_kdasVzt3MkM7cEOc,12458
|
17
17
|
commonmeta/readers/crossref_xml_reader.py,sha256=QF1A-r3OJbykBTH9YMSxusT3-KSKmmz7d6Ch8S0OM0I,18619
|
18
|
-
commonmeta/readers/csl_reader.py,sha256=
|
18
|
+
commonmeta/readers/csl_reader.py,sha256=IO8uj-L_BzPFWgfRzYCF9VbK5rBPBzDqak7iBELgNNs,3164
|
19
19
|
commonmeta/readers/datacite_reader.py,sha256=CdOtxhthrakBoQMsLTdPx6sUCmqtEWo5ICYE6ZsWDdo,12026
|
20
20
|
commonmeta/readers/datacite_xml_reader.py,sha256=nhnO92fZihr1HZlbXjyem-HJXc9_DWLgJ2zeltuPMIg,13041
|
21
21
|
commonmeta/readers/inveniordm_reader.py,sha256=jzv0rXzT8OCdPD_MShBXTnlwD-F9tpTX7OKZGn8smzs,7480
|
22
|
-
commonmeta/readers/json_feed_reader.py,sha256=
|
22
|
+
commonmeta/readers/json_feed_reader.py,sha256=ctlASyxByjXDVgREzdeYOCZezn9aFFv3yKogDFd8WNs,14174
|
23
23
|
commonmeta/readers/kbase_reader.py,sha256=ehKXQsJyPCtaq2FmBxNb2Jb5Nktpx8pNscpmEM6N0A4,6763
|
24
24
|
commonmeta/readers/ris_reader.py,sha256=v6qOd-i2OcMTEFy5RGd3MlYthJcYSU6yzmZ5yHDzmII,3677
|
25
25
|
commonmeta/readers/schema_org_reader.py,sha256=xyWzO2XAWlI2pYVl2EbVRsUmfiWXEwP64CHRBQNRN-M,16835
|
@@ -58,7 +58,7 @@ commonmeta/resources/styles/modern-language-association.csl,sha256=HI2iU4krze1aH
|
|
58
58
|
commonmeta/resources/styles/vancouver.csl,sha256=lun3_i2oTilgsANk4LjFao2UDPQlGj_hgFgKAWC_DF8,12878
|
59
59
|
commonmeta/schema_utils.py,sha256=gg3l1jd_lFtRkQlO1DYGMVbC10nEmVTN4AWacxC4AAE,915
|
60
60
|
commonmeta/translators.py,sha256=RpGJtKNLjmz41VREZDY7KyyE2eXOi8j7m-da4jHmknI,1362
|
61
|
-
commonmeta/utils.py,sha256=
|
61
|
+
commonmeta/utils.py,sha256=0ky8xyDQWVND5nJWApPgyVhbjXdPPzfpx4fJpX9ivyw,43674
|
62
62
|
commonmeta/writers/__init__.py,sha256=47-snms6xBHkoEXKYV1DBtH1npAtlVtvY29Z4Zr45qI,45
|
63
63
|
commonmeta/writers/bibtex_writer.py,sha256=s3hIJIgWvSG7TAriZMRQEAyuitw6ebwWSI1YcYFQ-do,4971
|
64
64
|
commonmeta/writers/citation_writer.py,sha256=RjaNh9EALxq6gfODLRWVJxGxPArGd6ZiHUlkYnCT6MA,2355
|
@@ -69,8 +69,8 @@ commonmeta/writers/datacite_writer.py,sha256=G7Lr0aZ4sAEdbfXe3dG4Y6AyGUKA9UWr_ii
|
|
69
69
|
commonmeta/writers/inveniordm_writer.py,sha256=oVcXdHYtuugbfDgKO8JwTRXmP7AK2U96uK4YF0eKXAY,11399
|
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.
|
73
|
-
commonmeta_py-0.
|
74
|
-
commonmeta_py-0.
|
75
|
-
commonmeta_py-0.
|
76
|
-
commonmeta_py-0.
|
72
|
+
commonmeta_py-0.61.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
73
|
+
commonmeta_py-0.61.dist-info/METADATA,sha256=y-HIlL_4UrT-S2JKmeR88cqbEvQHkYA4petMmujIoCw,8279
|
74
|
+
commonmeta_py-0.61.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
75
|
+
commonmeta_py-0.61.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
76
|
+
commonmeta_py-0.61.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|