mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
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:
parent
15802fe3cb
commit
7256c9bf4e
@ -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')
|
||||
|
||||
|
@ -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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user