commonmeta-py 0.116__py3-none-any.whl → 0.117__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 +57 -46
- {commonmeta_py-0.116.dist-info → commonmeta_py-0.117.dist-info}/METADATA +1 -1
- {commonmeta_py-0.116.dist-info → commonmeta_py-0.117.dist-info}/RECORD +7 -7
- {commonmeta_py-0.116.dist-info → commonmeta_py-0.117.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.116.dist-info → commonmeta_py-0.117.dist-info}/entry_points.txt +0 -0
- {commonmeta_py-0.116.dist-info → commonmeta_py-0.117.dist-info}/licenses/LICENSE +0 -0
commonmeta/__init__.py
CHANGED
@@ -477,7 +477,7 @@ def push_inveniordm(metadata, host: str, token: str, legacy_key: str):
|
|
477
477
|
if host == "rogue-scholar.org" and legacy_key is not None:
|
478
478
|
record = update_legacy_record(record, legacy_key)
|
479
479
|
except Exception as e:
|
480
|
-
|
480
|
+
print(f"Unexpected error: {str(e)}")
|
481
481
|
|
482
482
|
return record
|
483
483
|
|
@@ -508,7 +508,8 @@ def search_by_doi(doi, host, token) -> Optional[str]:
|
|
508
508
|
return py_.get(data, "hits.hits.0.id")
|
509
509
|
return None
|
510
510
|
except requests.exceptions.RequestException as e:
|
511
|
-
|
511
|
+
print(f"Error searching for DOI: {str(e)}")
|
512
|
+
return None
|
512
513
|
|
513
514
|
|
514
515
|
def create_draft_record(record, host, token, input):
|
@@ -535,7 +536,9 @@ def create_draft_record(record, host, token, input):
|
|
535
536
|
record["status"] = "draft"
|
536
537
|
return record
|
537
538
|
except requests.exceptions.RequestException as e:
|
538
|
-
|
539
|
+
print(f"Error creating draft record: {str(e)}")
|
540
|
+
record["status"] = "error_draft"
|
541
|
+
return record
|
539
542
|
|
540
543
|
|
541
544
|
def edit_published_record(record, host, token):
|
@@ -554,7 +557,9 @@ def edit_published_record(record, host, token):
|
|
554
557
|
record["status"] = "edited"
|
555
558
|
return record
|
556
559
|
except requests.exceptions.RequestException as e:
|
557
|
-
|
560
|
+
print(f"Error creating draft from published record: {str(e)}")
|
561
|
+
record["status"] = "error_edit_published_record"
|
562
|
+
return record
|
558
563
|
|
559
564
|
|
560
565
|
def update_draft_record(record, host, token, inveniordm_data):
|
@@ -576,7 +581,9 @@ def update_draft_record(record, host, token, inveniordm_data):
|
|
576
581
|
record["status"] = "updated"
|
577
582
|
return record
|
578
583
|
except requests.exceptions.RequestException as e:
|
579
|
-
|
584
|
+
print(f"Error updating draft record: {str(e)}")
|
585
|
+
record["status"] = "error_update_draft_record"
|
586
|
+
return record
|
580
587
|
|
581
588
|
|
582
589
|
def publish_draft_record(record, host, token):
|
@@ -585,9 +592,10 @@ def publish_draft_record(record, host, token):
|
|
585
592
|
"Authorization": f"Bearer {token}",
|
586
593
|
"Content-Type": "application/json",
|
587
594
|
}
|
588
|
-
if not record.get("id", None):
|
589
|
-
raise InvenioRDMError("Error publishing draft record")
|
590
595
|
try:
|
596
|
+
if not record.get("id", None):
|
597
|
+
raise InvenioRDMError("Missing record id")
|
598
|
+
|
591
599
|
response = requests.post(
|
592
600
|
f"https://{host}/api/records/{record['id']}/draft/actions/publish",
|
593
601
|
headers=headers,
|
@@ -606,7 +614,9 @@ def publish_draft_record(record, host, token):
|
|
606
614
|
record["status"] = "published"
|
607
615
|
return record
|
608
616
|
except requests.exceptions.RequestException as e:
|
609
|
-
|
617
|
+
print(f"Error publishing draft record: {str(e)}")
|
618
|
+
record["status"] = "error_publish_draft_record"
|
619
|
+
return record
|
610
620
|
|
611
621
|
|
612
622
|
def add_record_to_community(record, host, token, community_id):
|
@@ -624,49 +634,47 @@ def add_record_to_community(record, host, token, community_id):
|
|
624
634
|
response.raise_for_status()
|
625
635
|
return record
|
626
636
|
except requests.exceptions.RequestException as e:
|
627
|
-
|
637
|
+
print(f"Error adding record to community: {str(e)}")
|
638
|
+
return record
|
628
639
|
|
629
640
|
|
630
641
|
def update_legacy_record(record, legacy_key: str):
|
631
642
|
"""Update corresponding record in Rogue Scholar legacy database."""
|
632
643
|
|
633
644
|
legacy_host = "bosczcmeodcrajtcaddf.supabase.co"
|
634
|
-
|
635
|
-
if not legacy_key:
|
636
|
-
raise ValueError("no legacy key provided")
|
637
|
-
if not record.get("uuid", None):
|
638
|
-
raise ValueError("no UUID provided")
|
639
|
-
|
640
|
-
now = f"{int(time())}"
|
641
|
-
if record.get("id", None) is not None:
|
642
|
-
output = {
|
643
|
-
"rid": record.get("id"),
|
644
|
-
"indexed_at": now,
|
645
|
-
"indexed": "true",
|
646
|
-
"archived": "true",
|
647
|
-
}
|
648
|
-
elif record.get("doi", None) is not None:
|
649
|
-
output = {
|
650
|
-
"doi": record.get("doi"),
|
651
|
-
"indexed_at": now,
|
652
|
-
"indexed": "true",
|
653
|
-
"archived": "true",
|
654
|
-
}
|
655
|
-
else:
|
656
|
-
print(f"nothing to update for id {record.get("uuid")}")
|
657
|
-
return record # nothing to update
|
658
|
-
|
659
|
-
request_url = f"https://{legacy_host}/rest/v1/posts?id=eq.{record['uuid']}"
|
660
|
-
headers = {
|
661
|
-
"Content-Type": "application/json",
|
662
|
-
"apikey": legacy_key,
|
663
|
-
"Authorization": f"Bearer {legacy_key}",
|
664
|
-
"Prefer": "return=minimal",
|
665
|
-
}
|
666
|
-
|
667
645
|
try:
|
646
|
+
if not legacy_key:
|
647
|
+
raise ValueError("no legacy key provided")
|
648
|
+
if not record.get("uuid", None):
|
649
|
+
raise ValueError("no UUID provided")
|
650
|
+
|
651
|
+
now = f"{int(time())}"
|
652
|
+
if record.get("id", None) is not None:
|
653
|
+
output = {
|
654
|
+
"rid": record.get("id"),
|
655
|
+
"indexed_at": now,
|
656
|
+
"indexed": "true",
|
657
|
+
"archived": "true",
|
658
|
+
}
|
659
|
+
elif record.get("doi", None) is not None:
|
660
|
+
output = {
|
661
|
+
"doi": record.get("doi"),
|
662
|
+
"indexed_at": now,
|
663
|
+
"indexed": "true",
|
664
|
+
"archived": "true",
|
665
|
+
}
|
666
|
+
else:
|
667
|
+
print(f"nothing to update for id {record.get("uuid")}")
|
668
|
+
return record # nothing to update
|
669
|
+
|
670
|
+
request_url = f"https://{legacy_host}/rest/v1/posts?id=eq.{record['uuid']}"
|
671
|
+
headers = {
|
672
|
+
"Content-Type": "application/json",
|
673
|
+
"apikey": legacy_key,
|
674
|
+
"Authorization": f"Bearer {legacy_key}",
|
675
|
+
"Prefer": "return=minimal",
|
676
|
+
}
|
668
677
|
response = requests.patch(request_url, json=output, headers=headers, timeout=30)
|
669
|
-
response.raise_for_status()
|
670
678
|
if response.status_code != 204:
|
671
679
|
return Exception(f"Unexpected status code: {response.status_code}")
|
672
680
|
|
@@ -674,7 +682,9 @@ def update_legacy_record(record, legacy_key: str):
|
|
674
682
|
return record
|
675
683
|
|
676
684
|
except requests.exceptions.RequestException as e:
|
677
|
-
|
685
|
+
print(f"Error updating legacy record: {str(e)}")
|
686
|
+
record["status"] = "error_update_legacy_record"
|
687
|
+
return record
|
678
688
|
|
679
689
|
|
680
690
|
def search_by_slug(slug, type_value, host, token) -> Optional[str]:
|
@@ -694,11 +704,12 @@ def search_by_slug(slug, type_value, host, token) -> Optional[str]:
|
|
694
704
|
return py_.get(data, "hits.hits.0.id")
|
695
705
|
return None
|
696
706
|
except requests.exceptions.RequestException as e:
|
697
|
-
|
707
|
+
print(f"Error searching for community: {str(e)}")
|
708
|
+
return None
|
698
709
|
|
699
710
|
|
700
711
|
def string_to_slug(text):
|
701
|
-
"""
|
712
|
+
"""makes a string lowercase and removes non-alphanumeric characters"""
|
702
713
|
# Replace spaces with hyphens
|
703
714
|
slug = re.sub(r"\s+", "-", text.lower())
|
704
715
|
# Remove special characters
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: commonmeta-py
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.117
|
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=PewWTIqOQpCR4ity3t6THBO24iVtVoQrhf6Bd6itSF4,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=NZhNCAsNSLl5OYMjgOzmf_3DopILxWNYkIS4sSXC3ak,24976
|
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.117.dist-info/METADATA,sha256=2Gmzajh3uMNxvylQurm9NUOYCGnWzW6IcG2Ksw_pqzQ,7652
|
87
|
+
commonmeta_py-0.117.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
88
|
+
commonmeta_py-0.117.dist-info/entry_points.txt,sha256=U4w4BoRuS3rN5t5Y-uYSyOeU5Lh_VRVMS9OIDzIgw4w,50
|
89
|
+
commonmeta_py-0.117.dist-info/licenses/LICENSE,sha256=wsIvxF9Q9GC9vA_s79zTWP3BkXJdfUNRmALlU8GbW1s,1074
|
90
|
+
commonmeta_py-0.117.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|