From 3fd851a355f8fd1e5507abfd14ba5edf454b2b39 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Nov 2011 09:29:07 +0530 Subject: [PATCH] Preserve capitalization of Scottish author names when downloading metadata --- src/calibre/ebooks/metadata/sources/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py index 532c97b624..045f9e44be 100644 --- a/src/calibre/ebooks/metadata/sources/base.py +++ b/src/calibre/ebooks/metadata/sources/base.py @@ -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: