From a8fb3b2025bd82d19e3d11162d6a6aaf9feaa40a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 23 Nov 2011 09:05:46 +0530 Subject: [PATCH] When downloading metadata, fix the case normalization of double-barelled names. Fixes #893257 (Fetching metadata: Minuscules in the second part of hyphenated double-barrelled names) --- src/calibre/ebooks/metadata/sources/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py index 78203e40be..532c97b624 100644 --- a/src/calibre/ebooks/metadata/sources/base.py +++ b/src/calibre/ebooks/metadata/sources/base.py @@ -15,7 +15,7 @@ from calibre.customize import Plugin from calibre.utils.logging import ThreadSafeLog, FileStream from calibre.utils.config import JSONConfig from calibre.utils.titlecase import titlecase -from calibre.utils.icu import capitalize, lower +from calibre.utils.icu import capitalize, lower, upper from calibre.ebooks.metadata import check_isbn msprefs = JSONConfig('metadata_sources/global.json') @@ -121,7 +121,12 @@ def cap_author_token(token): # Normalize tokens of the form J.K. to J. K. parts = token.split('.') return '. '.join(map(capitalize, parts)).strip() - return capitalize(token) + ans = capitalize(token) + for x in ('-', "'"): + idx = ans.find(x) + if idx > -1 and len(ans) > idx+2: + ans = ans[:idx+1] + upper(ans[idx+1]) + ans[idx+2:] + return ans def fixauthors(authors): if not authors: