Fix a regression in the previous release that broke downloading metadata for authors witha double initial such as R. A. Salvatore. Fixes #1294529 [Metadata download fails on author with 2 intials](https://bugs.launchpad.net/calibre/+bug/1294529)

This commit is contained in:
Kovid Goyal 2014-03-19 21:05:41 +05:30
parent 15802fe3cb
commit 7256c9bf4e
2 changed files with 7 additions and 1 deletions

View File

@ -197,7 +197,11 @@ lower = _make_func(_change_case_template, 'lower', which='LOWER_CASE')
title_case = _make_func(_change_case_template, 'title_case', which='TITLE_CASE')
capitalize = lambda x: upper(x[0]) + lower(x[1:])
def capitalize(x):
try:
return upper(x[0]) + lower(x[1:])
except (IndexError, TypeError, AttributeError):
return x
find = _make_func(_strcmp_template, 'find', collator='_collator', collator_func='collator', func='find')

View File

@ -80,6 +80,8 @@ class TestICU(unittest.TestCase):
from calibre.utils.titlecase import titlecase
# Test corner cases
self.ae('A', icu.upper(b'a'))
for x in ('', None, False, 1):
self.ae(x, icu.capitalize(x))
for x in ('a', 'Alice\'s code', 'macdonald\'s machIne', '02 the wars'):
self.ae(icu.upper(x), x.upper())