commonmeta-py 0.119__py3-none-any.whl → 0.120__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/metadata.py +1 -1
- commonmeta/writers/crossref_xml_writer.py +29 -18
- commonmeta/writers/inveniordm_writer.py +3 -3
- {commonmeta_py-0.119.dist-info → commonmeta_py-0.120.dist-info}/METADATA +1 -2
- {commonmeta_py-0.119.dist-info → commonmeta_py-0.120.dist-info}/RECORD +9 -9
- {commonmeta_py-0.119.dist-info → commonmeta_py-0.120.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.119.dist-info → commonmeta_py-0.120.dist-info}/entry_points.txt +0 -0
- {commonmeta_py-0.119.dist-info → commonmeta_py-0.120.dist-info}/licenses/LICENSE +0 -0
commonmeta/__init__.py
CHANGED
commonmeta/metadata.py
CHANGED
@@ -484,7 +484,7 @@ class MetadataList:
|
|
484
484
|
|
485
485
|
if to == "crossref_xml":
|
486
486
|
response = push_crossref_xml_list(
|
487
|
-
self, login_id=self.login_id, login_passwd=self.login_passwd
|
487
|
+
self, login_id=self.login_id, login_passwd=self.login_passwd, legacy_key=self.legacy_key
|
488
488
|
)
|
489
489
|
return response
|
490
490
|
elif to == "datacite":
|
@@ -16,8 +16,9 @@ from requests_toolbelt.multipart.encoder import MultipartEncoder
|
|
16
16
|
|
17
17
|
from ..base_utils import compact, parse_xml, unparse_xml, unparse_xml_list, wrap
|
18
18
|
from ..constants import Commonmeta
|
19
|
-
from ..doi_utils import doi_from_url, validate_doi
|
19
|
+
from ..doi_utils import doi_from_url, is_rogue_scholar_doi, validate_doi
|
20
20
|
from ..utils import validate_url
|
21
|
+
from .inveniordm_writer import update_legacy_record
|
21
22
|
|
22
23
|
logger = logging.getLogger(__name__)
|
23
24
|
|
@@ -384,7 +385,7 @@ def write_crossref_xml_list(metalist) -> Optional[str]:
|
|
384
385
|
return unparse_xml_list(crossref_xml_list, dialect="crossref", head=head)
|
385
386
|
|
386
387
|
|
387
|
-
def push_crossref_xml_list(metalist, login_id: str, login_passwd: str) -> bytes:
|
388
|
+
def push_crossref_xml_list(metalist, login_id: str, login_passwd: str, legacy_key:str=None) -> bytes:
|
388
389
|
"""Push crossref_xml list to Crossref API, returns the API response."""
|
389
390
|
|
390
391
|
input = write_crossref_xml_list(metalist)
|
@@ -416,24 +417,34 @@ def push_crossref_xml_list(metalist, login_id: str, login_passwd: str) -> bytes:
|
|
416
417
|
# Parse the response
|
417
418
|
response = parse_xml(resp.content)
|
418
419
|
status = py_.get(response, "html.body.h2")
|
419
|
-
if status
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
420
|
+
if status != "SUCCESS":
|
421
|
+
# Handle error response
|
422
|
+
message = py_.get(response, "html.body.p")
|
423
|
+
logger.error(f"Crossref API error: {message}")
|
424
|
+
return "{}"
|
425
|
+
|
426
|
+
items = []
|
427
|
+
for item in metalist.items:
|
428
|
+
record = {
|
429
|
+
"doi": item.id,
|
430
|
+
"updated": datetime.now().isoformat("T", "seconds"),
|
431
|
+
"status": "submitted",
|
432
|
+
}
|
433
|
+
|
434
|
+
# update rogue-scholar legacy record if legacy_key is provided
|
435
|
+
if is_rogue_scholar_doi(item.id, ra="crossref") and legacy_key is not None:
|
436
|
+
record = update_legacy_record(record, legacy_key=legacy_key, field="doi")
|
437
|
+
items.append(record)
|
438
|
+
|
439
|
+
# Return JSON response
|
440
|
+
return json.dumps(items, option=json.OPT_INDENT_2)
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
429
446
|
|
430
|
-
# Return JSON response
|
431
|
-
return json.dumps(items, option=json.OPT_INDENT_2)
|
432
447
|
|
433
|
-
# Handle error response
|
434
|
-
message = py_.get(response, "html.body.p")
|
435
|
-
logger.error(f"Crossref API error: {message}")
|
436
|
-
return "{}"
|
437
448
|
|
438
449
|
|
439
450
|
def get_attributes(obj, **kwargs) -> dict:
|
@@ -484,7 +484,7 @@ def push_inveniordm(
|
|
484
484
|
|
485
485
|
# optionally update rogue-scholar legacy record
|
486
486
|
if host == "rogue-scholar.org" and legacy_key is not None:
|
487
|
-
record = update_legacy_record(record, legacy_key)
|
487
|
+
record = update_legacy_record(record, legacy_key=legacy_key, field="rid")
|
488
488
|
except Exception as e:
|
489
489
|
logger.error(f"Unexpected error in push_inveniordm: {str(e)}", exc_info=True, extra={
|
490
490
|
"host": host,
|
@@ -651,7 +651,7 @@ def add_record_to_community(record, host, token, community_id):
|
|
651
651
|
return record
|
652
652
|
|
653
653
|
|
654
|
-
def update_legacy_record(record, legacy_key: str):
|
654
|
+
def update_legacy_record(record, legacy_key: str, field:str=None) -> dict:
|
655
655
|
"""Update corresponding record in Rogue Scholar legacy database."""
|
656
656
|
|
657
657
|
legacy_host = "bosczcmeodcrajtcaddf.supabase.co"
|
@@ -662,7 +662,7 @@ def update_legacy_record(record, legacy_key: str):
|
|
662
662
|
raise ValueError("no UUID provided")
|
663
663
|
|
664
664
|
now = f"{int(time())}"
|
665
|
-
if record.get("id", None) is not None:
|
665
|
+
if field == "rid" and record.get("id", None) is not None:
|
666
666
|
output = {
|
667
667
|
"rid": record.get("id"),
|
668
668
|
"indexed_at": now,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: commonmeta-py
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.120
|
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
|
@@ -36,7 +36,6 @@ Requires-Dist: pyyaml>=5.4
|
|
36
36
|
Requires-Dist: requests-toolbelt>=1.0.0
|
37
37
|
Requires-Dist: requests>=2.31.0
|
38
38
|
Requires-Dist: requests>=2.32.3
|
39
|
-
Requires-Dist: setuptools<81,>=70.3.0
|
40
39
|
Requires-Dist: simplejson~=3.18
|
41
40
|
Requires-Dist: types-beautifulsoup4<5,>=4.11
|
42
41
|
Requires-Dist: types-dateparser~=1.1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=rWmoYjzULmmEdcjXnYZxNQk0qJ2tGwxTycmYxXoH65A,2098
|
2
2
|
commonmeta/api_utils.py,sha256=y5KLfIOWOjde7LXZ36u-eneQJ-Q53yXUZg3hWpCBS2E,2685
|
3
3
|
commonmeta/author_utils.py,sha256=3lYW5s1rOUWNTKs1FP6XLfEUY3yCLOe_3L_VdJTDMp0,8585
|
4
4
|
commonmeta/base_utils.py,sha256=-MGy9q2uTiJEkPWQUYOJMdq-3tRpNnvBwlLjvllQ5g8,11164
|
@@ -7,7 +7,7 @@ commonmeta/constants.py,sha256=wSTEUiHeRdXLwjXEQD9AU2hxFyEKi5OTX2iHOKO6nF0,19844
|
|
7
7
|
commonmeta/date_utils.py,sha256=H2cCobX0JREIUOT_cCigGd3MG7prGiQpXk1m4ZNrFwU,6318
|
8
8
|
commonmeta/doi_utils.py,sha256=cOogLatKg6qea2jgMd3yLALSTfaTNUgr-IkBXIK4xZw,11498
|
9
9
|
commonmeta/file_utils.py,sha256=eFYDWyR8Gr722nvFmp542hCm-TGmO_q4ciZ85IPHpjA,2893
|
10
|
-
commonmeta/metadata.py,sha256=
|
10
|
+
commonmeta/metadata.py,sha256=m9UtE95t9awrlo9w9qZtwF7Y9sRfABpA5JKUZdyz5b4,18921
|
11
11
|
commonmeta/schema_utils.py,sha256=WGpmMj9cfNMg_55hhgwY9qpO0A1HSvTLQC2equjBftI,1770
|
12
12
|
commonmeta/translators.py,sha256=CBMK4jrXRmGZiAhCh6wsJjhbDJWbcsda8UvXFXxccAw,1363
|
13
13
|
commonmeta/utils.py,sha256=pJnh3EzOU1E2nutnAZsopY_NsUX6zYmxoj5bIYqqWvE,50574
|
@@ -77,14 +77,14 @@ commonmeta/writers/__init__.py,sha256=47-snms6xBHkoEXKYV1DBtH1npAtlVtvY29Z4Zr45q
|
|
77
77
|
commonmeta/writers/bibtex_writer.py,sha256=doAdyl1NEp60mPkHPo3GMH8B-HA6MzLAdlyNsIecTzU,4972
|
78
78
|
commonmeta/writers/citation_writer.py,sha256=qs_4X3BjrSqHexmJFPvPDTp0mRIqzb0F70_Wuc7S9x0,2343
|
79
79
|
commonmeta/writers/commonmeta_writer.py,sha256=QpfyhG__7o_XpsOTCPWxGymO7YKwZi2LQh8Zic44bdc,1365
|
80
|
-
commonmeta/writers/crossref_xml_writer.py,sha256=
|
80
|
+
commonmeta/writers/crossref_xml_writer.py,sha256=Z5vhtWH-uz5WcBz1W_KOxyrvB5OQ2nTixV6EOhjOBnc,33859
|
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=eLllddYulFqg8qfRIScpYpnAJ82NCHXotCFJb09mHX8,25739
|
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.120.dist-info/METADATA,sha256=BxKd_hZcarnoQQUklRQ0leX_vAUu3hxYP1KGSTpH89E,7618
|
87
|
+
commonmeta_py-0.120.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
88
|
+
commonmeta_py-0.120.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
|
89
|
+
commonmeta_py-0.120.dist-info/licenses/LICENSE,sha256=wsIvxF9Q9GC9vA_s79zTWP3BkXJdfUNRmALlU8GbW1s,1074
|
90
|
+
commonmeta_py-0.120.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|