Preserve capitalization of Scottish author names when downloading metadata

This commit is contained in:
Kovid Goyal 2011-11-28 09:29:07 +05:30
parent 735de1d229
commit 3fd851a355

View File

@ -121,7 +121,15 @@ def cap_author_token(token):
# Normalize tokens of the form J.K. to J. K.
parts = token.split('.')
return '. '.join(map(capitalize, parts)).strip()
scots_name = None
for x in ('mc', 'mac'):
if (token.lower().startswith(x) and len(token) > len(x) and
token[len(x)] == upper(token[len(x)])):
scots_name = len(x)
break
ans = capitalize(token)
if scots_name is not None:
ans = ans[:scots_name] + upper(ans[scots_name]) + ans[scots_name+1:]
for x in ('-', "'"):
idx = ans.find(x)
if idx > -1 and len(ans) > idx+2: