commonmeta-py 0.115__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 -47
- {commonmeta_py-0.115.dist-info → commonmeta_py-0.117.dist-info}/METADATA +1 -1
- {commonmeta_py-0.115.dist-info → commonmeta_py-0.117.dist-info}/RECORD +7 -7
- {commonmeta_py-0.115.dist-info → commonmeta_py-0.117.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.115.dist-info → commonmeta_py-0.117.dist-info}/entry_points.txt +0 -0
- {commonmeta_py-0.115.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,50 +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
|
-
if not record.get("doi", None):
|
640
|
-
raise ValueError("no valid doi to update")
|
641
|
-
|
642
|
-
now = f"{int(time())}"
|
643
|
-
if record.get("id", None) is not None:
|
644
|
-
output = {
|
645
|
-
"rid": record.get("id"),
|
646
|
-
"indexed_at": now,
|
647
|
-
"indexed": "true",
|
648
|
-
"archived": "true",
|
649
|
-
}
|
650
|
-
elif record.get("doi", None) is not None:
|
651
|
-
output = {
|
652
|
-
"doi": record.get("doi"),
|
653
|
-
"indexed_at": now,
|
654
|
-
"indexed": "true",
|
655
|
-
"archived": "true",
|
656
|
-
}
|
657
|
-
else:
|
658
|
-
return record # nothing to update
|
659
|
-
|
660
|
-
request_url = f"https://{legacy_host}/rest/v1/posts?id=eq.{record['uuid']}"
|
661
|
-
headers = {
|
662
|
-
"Content-Type": "application/json",
|
663
|
-
"apikey": legacy_key,
|
664
|
-
"Authorization": f"Bearer {legacy_key}",
|
665
|
-
"Prefer": "return=minimal",
|
666
|
-
}
|
667
|
-
|
668
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
|
+
}
|
669
677
|
response = requests.patch(request_url, json=output, headers=headers, timeout=30)
|
670
|
-
response.raise_for_status()
|
671
678
|
if response.status_code != 204:
|
672
679
|
return Exception(f"Unexpected status code: {response.status_code}")
|
673
680
|
|
@@ -675,7 +682,9 @@ def update_legacy_record(record, legacy_key: str):
|
|
675
682
|
return record
|
676
683
|
|
677
684
|
except requests.exceptions.RequestException as e:
|
678
|
-
|
685
|
+
print(f"Error updating legacy record: {str(e)}")
|
686
|
+
record["status"] = "error_update_legacy_record"
|
687
|
+
return record
|
679
688
|
|
680
689
|
|
681
690
|
def search_by_slug(slug, type_value, host, token) -> Optional[str]:
|
@@ -695,11 +704,12 @@ def search_by_slug(slug, type_value, host, token) -> Optional[str]:
|
|
695
704
|
return py_.get(data, "hits.hits.0.id")
|
696
705
|
return None
|
697
706
|
except requests.exceptions.RequestException as e:
|
698
|
-
|
707
|
+
print(f"Error searching for community: {str(e)}")
|
708
|
+
return None
|
699
709
|
|
700
710
|
|
701
711
|
def string_to_slug(text):
|
702
|
-
"""
|
712
|
+
"""makes a string lowercase and removes non-alphanumeric characters"""
|
703
713
|
# Replace spaces with hyphens
|
704
714
|
slug = re.sub(r"\s+", "-", text.lower())
|
705
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
|