mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Preserve capitalization of Scottish author names when downloading metadata
This commit is contained in:
parent
735de1d229
commit
3fd851a355
@ -121,7 +121,15 @@ def cap_author_token(token):
|
|||||||
# Normalize tokens of the form J.K. to J. K.
|
# Normalize tokens of the form J.K. to J. K.
|
||||||
parts = token.split('.')
|
parts = token.split('.')
|
||||||
return '. '.join(map(capitalize, parts)).strip()
|
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)
|
ans = capitalize(token)
|
||||||
|
if scots_name is not None:
|
||||||
|
ans = ans[:scots_name] + upper(ans[scots_name]) + ans[scots_name+1:]
|
||||||
for x in ('-', "'"):
|
for x in ('-', "'"):
|
||||||
idx = ans.find(x)
|
idx = ans.find(x)
|
||||||
if idx > -1 and len(ans) > idx+2:
|
if idx > -1 and len(ans) > idx+2:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user