commonmeta-py 0.113__py3-none-any.whl → 0.115__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/writers/inveniordm_writer.py +28 -16
- {commonmeta_py-0.113.dist-info → commonmeta_py-0.115.dist-info}/METADATA +1 -1
- {commonmeta_py-0.113.dist-info → commonmeta_py-0.115.dist-info}/RECORD +7 -7
- {commonmeta_py-0.113.dist-info → commonmeta_py-0.115.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.113.dist-info → commonmeta_py-0.115.dist-info}/entry_points.txt +0 -0
- {commonmeta_py-0.113.dist-info → commonmeta_py-0.115.dist-info}/licenses/LICENSE +0 -0
commonmeta/__init__.py
CHANGED
@@ -476,7 +476,6 @@ def push_inveniordm(metadata, host: str, token: str, legacy_key: str):
|
|
476
476
|
# optionally update rogue-scholar legacy record
|
477
477
|
if host == "rogue-scholar.org" and legacy_key is not None:
|
478
478
|
record = update_legacy_record(record, legacy_key)
|
479
|
-
print("g", record)
|
480
479
|
except Exception as e:
|
481
480
|
raise InvenioRDMError(f"Unexpected error: {str(e)}")
|
482
481
|
|
@@ -522,14 +521,19 @@ def create_draft_record(record, host, token, input):
|
|
522
521
|
response = requests.post(
|
523
522
|
f"https://{host}/api/records", headers=headers, json=input
|
524
523
|
)
|
525
|
-
response.
|
524
|
+
if response.status_code == 429:
|
525
|
+
record["status"] = "failed_rate_limited"
|
526
|
+
return record
|
527
|
+
if response.status_code != 201:
|
528
|
+
print(response.json())
|
529
|
+
record["status"] = "failed_create_draft"
|
530
|
+
return record
|
526
531
|
data = response.json()
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
}
|
532
|
+
record["id"]: data.get("id", None)
|
533
|
+
record["created"] = data.get("created", None)
|
534
|
+
record["updated"] = data.get("updated", None)
|
535
|
+
record["status"] = "draft"
|
536
|
+
return record
|
533
537
|
except requests.exceptions.RequestException as e:
|
534
538
|
raise InvenioRDMError(f"Error creating draft record: {str(e)}")
|
535
539
|
|
@@ -546,8 +550,6 @@ def edit_published_record(record, host, token):
|
|
546
550
|
)
|
547
551
|
response.raise_for_status()
|
548
552
|
data = response.json()
|
549
|
-
record["doi"] = py_.get(data, "pids.doi.identifier")
|
550
|
-
record["created"] = data.get("created", None)
|
551
553
|
record["updated"] = data.get("updated", None)
|
552
554
|
record["status"] = "edited"
|
553
555
|
return record
|
@@ -583,12 +585,20 @@ def publish_draft_record(record, host, token):
|
|
583
585
|
"Authorization": f"Bearer {token}",
|
584
586
|
"Content-Type": "application/json",
|
585
587
|
}
|
588
|
+
if not record.get("id", None):
|
589
|
+
raise InvenioRDMError("Error publishing draft record")
|
586
590
|
try:
|
587
591
|
response = requests.post(
|
588
592
|
f"https://{host}/api/records/{record['id']}/draft/actions/publish",
|
589
593
|
headers=headers,
|
590
594
|
)
|
591
|
-
response.
|
595
|
+
if response.status_code == 429:
|
596
|
+
record["status"] = "failed_rate_limited"
|
597
|
+
return record
|
598
|
+
if response.status_code != 202:
|
599
|
+
print(response.json())
|
600
|
+
record["status"] = "failed_publish_draft"
|
601
|
+
return record
|
592
602
|
data = response.json()
|
593
603
|
record["uuid"] = py_.get(data, "metadata.identifiers.0.identifier")
|
594
604
|
record["created"] = data.get("created", None)
|
@@ -623,11 +633,11 @@ def update_legacy_record(record, legacy_key: str):
|
|
623
633
|
legacy_host = "bosczcmeodcrajtcaddf.supabase.co"
|
624
634
|
|
625
635
|
if not legacy_key:
|
626
|
-
|
636
|
+
raise ValueError("no legacy key provided")
|
627
637
|
if not record.get("uuid", None):
|
628
|
-
|
638
|
+
raise ValueError("no UUID provided")
|
629
639
|
if not record.get("doi", None):
|
630
|
-
|
640
|
+
raise ValueError("no valid doi to update")
|
631
641
|
|
632
642
|
now = f"{int(time())}"
|
633
643
|
if record.get("id", None) is not None:
|
@@ -637,13 +647,15 @@ def update_legacy_record(record, legacy_key: str):
|
|
637
647
|
"indexed": "true",
|
638
648
|
"archived": "true",
|
639
649
|
}
|
640
|
-
|
650
|
+
elif record.get("doi", None) is not None:
|
641
651
|
output = {
|
642
652
|
"doi": record.get("doi"),
|
643
653
|
"indexed_at": now,
|
644
654
|
"indexed": "true",
|
645
655
|
"archived": "true",
|
646
656
|
}
|
657
|
+
else:
|
658
|
+
return record # nothing to update
|
647
659
|
|
648
660
|
request_url = f"https://{legacy_host}/rest/v1/posts?id=eq.{record['uuid']}"
|
649
661
|
headers = {
|
@@ -657,7 +669,7 @@ def update_legacy_record(record, legacy_key: str):
|
|
657
669
|
response = requests.patch(request_url, json=output, headers=headers, timeout=30)
|
658
670
|
response.raise_for_status()
|
659
671
|
if response.status_code != 204:
|
660
|
-
return
|
672
|
+
return Exception(f"Unexpected status code: {response.status_code}")
|
661
673
|
|
662
674
|
record["status"] = "updated_legacy"
|
663
675
|
return record
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: commonmeta-py
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.115
|
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,4 +1,4 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=9NdC2BSzN0Rp6KnVhAe9H5V8scjRuYuJjOzC2MA8834,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
|
@@ -80,11 +80,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=QpfyhG__7o_XpsOTCPWxGymO7YKwZi2LQ
|
|
80
80
|
commonmeta/writers/crossref_xml_writer.py,sha256=d-Rb2Vd_g3UW8GM4APIT7fivSQ5GMssZ6Ubi3OykHaw,33479
|
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=339nr2D17GYkt5U7gTzR36Fz5_j3nOADW5LauTBr1hg,24600
|
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.115.dist-info/METADATA,sha256=67byC97xVsjCX71rLBqHAvN8aY8_pXe4V-iuDzyyT68,7652
|
87
|
+
commonmeta_py-0.115.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
88
|
+
commonmeta_py-0.115.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
|
89
|
+
commonmeta_py-0.115.dist-info/licenses/LICENSE,sha256=wsIvxF9Q9GC9vA_s79zTWP3BkXJdfUNRmALlU8GbW1s,1074
|
90
|
+
commonmeta_py-0.115.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|