-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CDLUC3/dev
Fixing 10.3 bug
- Loading branch information
Showing
4 changed files
with
38 additions
and
14 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,13 @@ | ||
~$ | ||
\.map$ | ||
*.pyc | ||
\.project$ | ||
\.DS_Store$ | ||
^dev/css/*$ | ||
\.old[0-9]*$ | ||
^ui_library$ | ||
^node_modules$ | ||
\.pydevproject$ | ||
templates/info/ | ||
settings/ezid.conf.shadow | ||
static/javascripts/metadata_tooltips.js |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# | ||
# Author: | ||
# Greg Janee <[email protected]> | ||
# Rushiraj Nenuji <[email protected]> | ||
# | ||
# License: | ||
# Copyright (c) 2010, Regents of the University of California | ||
|
@@ -56,7 +57,7 @@ def validateDoi (doi): | |
if len(doi) > maxIdentifierLength-4: return None | ||
return doi.upper() | ||
|
||
_arkPattern1 = re.compile("((?:\d{5}(?:\d{4})?|[b-k]\d{4})/)([!-~]+)$") | ||
_arkPattern1 = re.compile("((?:\d{5}(?:\d{4})?|[bcdfghjkmnpqrstvwxz]\d{4})/)([!-~]+)$") | ||
_arkPattern2 = re.compile("\./|/\.") | ||
_arkPattern3 = re.compile("([./])[./]+") | ||
_arkPattern4 = re.compile("^[./]|[./]$") | ||
|
@@ -238,12 +239,16 @@ def doi2shadow (doi): | |
# Update: to prevent different DOIs from mapping to the same shadow | ||
# ARK, we percent-encode characters (and only those characters) that | ||
# would otherwise be removed by the ARK normalization process. | ||
beta_numeric_char = "bcdfghjkmnpqrstvwxz" | ||
doi_prefix = doi.split("/")[0] | ||
i = len(doi_prefix) + 1 | ||
if doi[7] == "/": | ||
i = 8 | ||
p = "b" + doi[3:i] | ||
else: | ||
i = 9 | ||
p = chr(ord("c")+ord(doi[3])-ord("1")) + doi[4:i] | ||
if i == 9: | ||
p = beta_numeric_char[(ord(doi[3])-ord("0"))] + doi[4:i] | ||
elif i == 10: | ||
p = beta_numeric_char[((ord(doi[3]) - ord("0")) * 10) + (ord(doi[4]) - ord("0"))] + doi[5:i] | ||
s = doi[i:].replace("%", "%25").replace("-", "%2d").lower() | ||
s = _arkPattern4.sub(lambda c: "%%%02x" % ord(c.group(0)), s) | ||
s = _arkPattern3.sub(_percentEncodeCdr, s) | ||
|
@@ -260,13 +265,20 @@ def shadow2doi (ark): | |
(e.g., "10.5060/FOO"). The returned identifier is in canonical | ||
form. | ||
""" | ||
beta_numeric_char = "bcdfghjkmnpqrstvwxz" | ||
if ark[0] == "b": | ||
doi = "10." + ark[1:] | ||
else: | ||
doi = "10." + chr(ord("1")+ord(ark[0])-ord("c")) + ark[1:] | ||
try: | ||
if beta_numeric_char.find(ark[0]) > -1: | ||
doi = "10." + str(beta_numeric_char.find(ark[0])) + ark[1:] | ||
else: | ||
raise Exception("Not a valid ark") | ||
except: | ||
print "Sorry, an error occured while converting shadow 2 doi" | ||
return _hexDecodePattern.sub(lambda c: chr(int(c.group(1), 16)), doi).upper() | ||
|
||
_shadowedDoiPattern = re.compile("ark:/[b-k]") # see _arkPattern1 above | ||
_shadowedDoiPattern = re.compile("ark:/[bcdfghjkmnpqrstvwxz]") # see _arkPattern1 above | ||
|
||
def normalizeIdentifier (identifier): | ||
""" | ||
|
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
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