-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add script to push METS records mentioned in a CSV * Apply auto-formatting rules * add source id script --------- Co-authored-by: Buildkite on behalf of Wellcome Collection <[email protected]>
- Loading branch information
1 parent
f7893cc
commit 3f740ca
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import csv | ||
import sys | ||
from populate_mets import specific | ||
|
||
|
||
# Push each Born Digital bag mentioned in a CSV through the adapter. | ||
# The CSV should have a row corresponding to each Bag (Item) thus: | ||
# Item, MY/BAG/1/2/3 | ||
# Item, MY/BAG/4/5/6 | ||
# More columns can be added, and rows starting with other values are ignored. | ||
|
||
|
||
def main(csv_path): | ||
with open(csv_path, "r") as csv_file: | ||
specific(extract_bag_ids(csv.reader(csv_file))) | ||
|
||
|
||
def extract_bag_ids(csv_reader): | ||
for row in csv_reader: | ||
if row[0] == "Item": | ||
yield f"born-digital/{row[1]}" | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Given the identifier and source system name, return a GET request that can be | ||
# used in the Elasticsearch console to fetch the record from the works-source index. | ||
|
||
# It's basically just URL Encoding, but it can be a bit of a faff compared to ids in other indices | ||
import sys | ||
from urllib.parse import quote_plus | ||
|
||
date = sys.argv[1] | ||
source_system = sys.argv[2] | ||
work_id = sys.argv[3] | ||
doc_id = quote_plus(f"Work[{source_system}/{work_id.lower()}]") | ||
print(f"GET works-source-{date}/_doc/{doc_id}") |