Skip to content

Commit

Permalink
Merge pull request #332 from NASA-PDS/i331
Browse files Browse the repository at this point in the history
Add sync script and update identifier handling
  • Loading branch information
jordanpadams authored May 17, 2022
2 parents 98d511e + 4ec0f4a commit 2d2081e
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 2d2081e

Please sign in to comment.