Skip to content

Commit

Permalink
Add sync script and update identifier handling
Browse files Browse the repository at this point in the history
* Add sync_dois.sh script per #309
* Update identifier handling for NoneType identifiers #331
  • Loading branch information
jordanpadams committed May 16, 2022
1 parent 98d511e commit 4ec0f4a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
47 changes: 47 additions & 0 deletions scripts/sync_dois.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
echo "sync_dois.sh [-h|--help] [-p|--prefix <doi_prefix>] [-s|--submitter <submitter email>]"
exit 0
;;
-p|--prefix)
PREFIX="$2"
shift
shift
;;
-s|--submitter)
SUBMITTER="$2"
shift
shift
;;
*)
echo "Unknown option $1"
exit 1
;;
esac
done

if [[ -z ${PREFIX} ]]; then
PREFIX="10.17189"
fi

if [[ -z ${SUBMITTER} ]]; then
SUBMITTER="[email protected]"
fi

echo "=================================================="
echo "Starting DOI sync for $(date)"
echo
echo "PREFIX=${PREFIX}"
echo "SUBMITTER=${SUBMITTER}"

source /home/pds4/pds-doi-service/bin/activate

pds-doi-init --service datacite --prefix ${PREFIX} --submitter ${SUBMITTER}

echo "Sync complete"
echo

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def _parse_identifiers(record):
identifiers = record["identifiers"]

for identifier in identifiers:
identifier["identifier"] = identifier["identifier"].strip()
if identifier["identifier"] is None:
logger.warn(f"Odd metadata. NoneType identifier in record: {json.dumps(record, indent=4, sort_keys=True)}")
identifiers.remove(identifier)
else:
identifier["identifier"] = identifier["identifier"].strip()

return identifiers
except KeyError:
Expand Down

0 comments on commit 4ec0f4a

Please sign in to comment.