File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ def save_profile():
204204 # Get ORCID
205205 while True :
206206 orcid = get_user_input ("Enter your ORCID identifier: " )
207+ orcid = normalize_orcid (orcid )
207208 family_name , given_name = get_names (orcid )
208209 if family_name is not None and given_name is not None :
209210 break
@@ -476,6 +477,19 @@ def parse_args():
476477 return args
477478
478479
480+ def normalize_orcid (val ):
481+ orcid_urls = ["https://orcid.org/" , "http://orcid.org/" , "orcid.org/" ]
482+ for orcid_url in orcid_urls :
483+ if val .startswith (orcid_url ):
484+ val = val [len (orcid_url ) :]
485+ break
486+
487+ val = val .replace ("-" , "" ).replace (" " , "" )
488+ if len (val ) != 16 or not val .isdigit ():
489+ raise ValueError (f"Invalid ORCID identifier: { val } " )
490+ return "-" .join ([val [0 :4 ], val [4 :8 ], val [8 :12 ], val [12 :16 ]])
491+
492+
479493def main ():
480494 args = parse_args ()
481495 production = not args .test
You can’t perform that action at this time.
0 commit comments