commonmeta-py 0.127__py3-none-any.whl → 0.129__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 +1 -1
- commonmeta/doi_utils.py +3 -5
- commonmeta/readers/jsonfeed_reader.py +4 -1
- commonmeta/utils.py +12 -17
- commonmeta/writers/inveniordm_writer.py +2 -7
- {commonmeta_py-0.127.dist-info → commonmeta_py-0.129.dist-info}/METADATA +1 -1
- {commonmeta_py-0.127.dist-info → commonmeta_py-0.129.dist-info}/RECORD +10 -10
- {commonmeta_py-0.127.dist-info → commonmeta_py-0.129.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.127.dist-info → commonmeta_py-0.129.dist-info}/entry_points.txt +0 -0
- {commonmeta_py-0.127.dist-info → commonmeta_py-0.129.dist-info}/licenses/LICENSE +0 -0
commonmeta/__init__.py
CHANGED
commonmeta/doi_utils.py
CHANGED
@@ -356,7 +356,7 @@ def generate_wordpress_doi(prefix: str, slug: str, guid: str) -> str:
|
|
356
356
|
return doi
|
357
357
|
|
358
358
|
|
359
|
-
def generate_doi_from_guid(prefix: str, guid: str) -> str:
|
359
|
+
def generate_doi_from_guid(prefix: str, guid: str, checksum=True) -> Optional[str]:
|
360
360
|
"""Validates a GUID that is a DOI"""
|
361
361
|
import base32_lib as base32
|
362
362
|
|
@@ -374,13 +374,11 @@ def generate_doi_from_guid(prefix: str, guid: str) -> str:
|
|
374
374
|
suffix = doi.split("/")[-1]
|
375
375
|
|
376
376
|
try:
|
377
|
-
number = base32.decode(suffix, checksum
|
377
|
+
number = base32.decode(suffix, checksum)
|
378
378
|
if number != 0:
|
379
379
|
return doi
|
380
380
|
except (ValueError, IndexError):
|
381
|
-
|
382
|
-
|
383
|
-
return ""
|
381
|
+
return None
|
384
382
|
|
385
383
|
|
386
384
|
def generate_substack_doi(prefix: str, guid: str) -> str:
|
@@ -75,7 +75,10 @@ def read_jsonfeed(data: Optional[dict], **kwargs) -> Commonmeta:
|
|
75
75
|
elif generator == "Substack" and prefix and guid:
|
76
76
|
_id = generate_substack_doi(prefix, guid)
|
77
77
|
elif prefix and guid:
|
78
|
-
|
78
|
+
# don't use checksum as some legacy GUIDs (generated with commonmeta Go between May 2024
|
79
|
+
# and April 2025) don't have valued checksum
|
80
|
+
guid = guid[:-2] # remove checksum
|
81
|
+
_id = generate_doi_from_guid(prefix, guid, checksum=False)
|
79
82
|
|
80
83
|
# If still no DOI but prefix provided and not registered for DOI generation
|
81
84
|
elif py_.get(meta, "blog.prefix") and not py_.get(meta, "blog.doi_reg", False):
|
commonmeta/utils.py
CHANGED
@@ -1325,24 +1325,19 @@ def subjects_as_string(subjects):
|
|
1325
1325
|
return ", ".join(keywords)
|
1326
1326
|
|
1327
1327
|
|
1328
|
-
def string_to_slug(text):
|
1329
|
-
"""
|
1330
|
-
|
1328
|
+
def string_to_slug(text: str) -> str:
|
1329
|
+
"""Makes a string lowercase and removes non-alphanumeric characters"""
|
1330
|
+
|
1331
|
+
# Remove optional FOS (Fields of Science) prefix
|
1331
1332
|
text = text.removeprefix("FOS: ")
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
slug = re.sub(r"[^a-z0-9-]", "", slug)
|
1341
|
-
# Remove multiple consecutive hyphens
|
1342
|
-
slug = re.sub(r"-+", "-", slug)
|
1343
|
-
# Remove leading and trailing hyphens
|
1344
|
-
slug = slug.strip("-")
|
1345
|
-
return slug
|
1333
|
+
|
1334
|
+
# Convert to lowercase and keep only letters and numbers
|
1335
|
+
result = ""
|
1336
|
+
for char in text:
|
1337
|
+
if char.isalnum():
|
1338
|
+
result += char.lower()
|
1339
|
+
|
1340
|
+
return result
|
1346
1341
|
|
1347
1342
|
|
1348
1343
|
# def reverse():
|
@@ -7,7 +7,6 @@ from typing import Dict, Optional
|
|
7
7
|
import orjson as json
|
8
8
|
import pydash as py_
|
9
9
|
import requests
|
10
|
-
from urllib3._collections import HTTPHeaderDict
|
11
10
|
|
12
11
|
from ..base_utils import compact, parse_attributes, presence, wrap
|
13
12
|
from ..constants import (
|
@@ -760,17 +759,13 @@ def update_legacy_record(record, legacy_key: str, field: str = None) -> dict:
|
|
760
759
|
return record
|
761
760
|
|
762
761
|
|
763
|
-
def search_by_slug(slug: str,
|
762
|
+
def search_by_slug(slug: str, type: str, host: str, token: str) -> Optional[str]:
|
764
763
|
"""Search for a community by slug in InvenioRDM"""
|
765
764
|
headers = {
|
766
765
|
"Authorization": f"Bearer {token}",
|
767
766
|
"Content-Type": "application/json",
|
768
767
|
}
|
769
|
-
params =
|
770
|
-
params.add("q", f"slug:{slug}")
|
771
|
-
params.add("type", type_value)
|
772
|
-
params.add("type", "subject")
|
773
|
-
params.add("size", 1)
|
768
|
+
params = [("q", f"slug:{slug}"), ("type", type), ("type", "subject"), ("size", 1)]
|
774
769
|
try:
|
775
770
|
response = requests.get(
|
776
771
|
f"https://{host}/api/communities", headers=headers, params=params
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: commonmeta-py
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.129
|
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,16 +1,16 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=nPzfcuE2fYAyGTTViV59VAGrNY25hfNfaouB6J9OXY0,2118
|
2
2
|
commonmeta/api_utils.py,sha256=P8LMHHYiF4OTi97_5k4KstcBreooMkOAKZ4ebxsAv4o,2691
|
3
3
|
commonmeta/author_utils.py,sha256=3lYW5s1rOUWNTKs1FP6XLfEUY3yCLOe_3L_VdJTDMp0,8585
|
4
4
|
commonmeta/base_utils.py,sha256=-MGy9q2uTiJEkPWQUYOJMdq-3tRpNnvBwlLjvllQ5g8,11164
|
5
5
|
commonmeta/cli.py,sha256=pdBpBosLNq3RS9buO-Voqawc9Ay1eSt-xP5O97iOft4,8480
|
6
6
|
commonmeta/constants.py,sha256=wSTEUiHeRdXLwjXEQD9AU2hxFyEKi5OTX2iHOKO6nF0,19844
|
7
7
|
commonmeta/date_utils.py,sha256=H2cCobX0JREIUOT_cCigGd3MG7prGiQpXk1m4ZNrFwU,6318
|
8
|
-
commonmeta/doi_utils.py,sha256=
|
8
|
+
commonmeta/doi_utils.py,sha256=WCERy6sJ8C7KRxYU-ZGnvmFe6YIdl_jtYO4lQ23aeYA,11510
|
9
9
|
commonmeta/file_utils.py,sha256=eFYDWyR8Gr722nvFmp542hCm-TGmO_q4ciZ85IPHpjA,2893
|
10
10
|
commonmeta/metadata.py,sha256=90aTe47d071wHxwcNsOqU5lSVPKP8wAPnPHhddj3Fuo,18443
|
11
11
|
commonmeta/schema_utils.py,sha256=zn3gqAHciUOQmrw9okR68weFs-yqPPyORFt-Zl1D3Lw,1924
|
12
12
|
commonmeta/translators.py,sha256=CBMK4jrXRmGZiAhCh6wsJjhbDJWbcsda8UvXFXxccAw,1363
|
13
|
-
commonmeta/utils.py,sha256=
|
13
|
+
commonmeta/utils.py,sha256=1Q6vh1mhQRTcPsEEymAPPJxBgDfNOR1ZXF_UaaW9ZoM,53612
|
14
14
|
commonmeta/readers/__init__.py,sha256=vOf7UsOKNoh_ZCuyexxhAmPMt8wjB-pF_CfpWRaN8pk,45
|
15
15
|
commonmeta/readers/bibtex_reader.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
16
|
commonmeta/readers/cff_reader.py,sha256=HMFK6QIg_XIlhmYIWL4EfIyuidYl5L_0TAwyG78XPlU,6244
|
@@ -22,7 +22,7 @@ commonmeta/readers/csl_reader.py,sha256=OxzC2AZKfv43BCah4XGYvlK_LUK-5mxXFcjdzB5v
|
|
22
22
|
commonmeta/readers/datacite_reader.py,sha256=4b_AP8m_aOUNVnVB0nU9j4-a8WTpmYJA8QPr5v35qyw,12219
|
23
23
|
commonmeta/readers/datacite_xml_reader.py,sha256=nsPc7JBbIKgx6Yaauq8vmhUE-o6K0t_MAuExv6FO2AU,13205
|
24
24
|
commonmeta/readers/inveniordm_reader.py,sha256=DtSloEZDu8bL-QLQAqAW1aDsS6ESTDZyhme379IekjY,8502
|
25
|
-
commonmeta/readers/jsonfeed_reader.py,sha256=
|
25
|
+
commonmeta/readers/jsonfeed_reader.py,sha256=sLwQwoFuOJ5yVqSi-EQVHSCo0VkwY_l6WxLGURP8yPo,15889
|
26
26
|
commonmeta/readers/kbase_reader.py,sha256=0Y9cHRNs_7kHyocN4IESXbgmXJiq4TXoxvGeUYGml1s,6896
|
27
27
|
commonmeta/readers/openalex_reader.py,sha256=4HUkBsut_iUjhUcC5c1GHgxnKsYQc-fgY43QILgVZEg,12826
|
28
28
|
commonmeta/readers/ris_reader.py,sha256=nwK8Eux0wPjwKqXFWS4Cfd6FAY7Id4Mi_hgkTwPntHs,3766
|
@@ -80,11 +80,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=QpfyhG__7o_XpsOTCPWxGymO7YKwZi2LQ
|
|
80
80
|
commonmeta/writers/crossref_xml_writer.py,sha256=rcPOfrGxU4mX7_fFywYWDW2FFUoKW9wD-JzW8nX1ipI,33915
|
81
81
|
commonmeta/writers/csl_writer.py,sha256=4gDYs1EzK4_L2UIRTfs25wgHmYRwdRP2zmfxF9387oU,2779
|
82
82
|
commonmeta/writers/datacite_writer.py,sha256=bcinpwhq7XnVthKHH8-sdXA34dSlvFH4ImYH768iaQU,6428
|
83
|
-
commonmeta/writers/inveniordm_writer.py,sha256=
|
83
|
+
commonmeta/writers/inveniordm_writer.py,sha256=tiuq9JEkz02l615yVe9wUcJQqiIPJLUqNDyofEE8Aus,26726
|
84
84
|
commonmeta/writers/ris_writer.py,sha256=3SdyEvMRaPRP1SV1MB-MXBlunE7x6og7RF1zuWtetPc,2094
|
85
85
|
commonmeta/writers/schema_org_writer.py,sha256=s18_x0ReXwAGBoEAwp2q-HCgFQ-h5qRg6JyAlqCoSFE,5871
|
86
|
-
commonmeta_py-0.
|
87
|
-
commonmeta_py-0.
|
88
|
-
commonmeta_py-0.
|
89
|
-
commonmeta_py-0.
|
90
|
-
commonmeta_py-0.
|
86
|
+
commonmeta_py-0.129.dist-info/METADATA,sha256=cza-xH9MAPp1KGy_yyrDnXHaN63rR_6_YFeajR1blyI,7656
|
87
|
+
commonmeta_py-0.129.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
88
|
+
commonmeta_py-0.129.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
|
89
|
+
commonmeta_py-0.129.dist-info/licenses/LICENSE,sha256=wsIvxF9Q9GC9vA_s79zTWP3BkXJdfUNRmALlU8GbW1s,1074
|
90
|
+
commonmeta_py-0.129.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|