mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix template bugs introduced by using + instead of '%s'
This commit is contained in:
parent
bd8a206219
commit
f280cc956f
@ -43,9 +43,9 @@ class SafeFormat(string.Formatter):
|
||||
ign, v = mi.format_field(key, series_with_index=False)
|
||||
if v is None:
|
||||
return ''
|
||||
if v is '':
|
||||
if v == '':
|
||||
return ''
|
||||
return prefix + v + suffix
|
||||
return prefix + unicode(v) + suffix
|
||||
except:
|
||||
return key
|
||||
|
||||
|
@ -101,7 +101,8 @@ def preprocess_template(template):
|
||||
template = template.decode(preferred_encoding, 'replace')
|
||||
return template
|
||||
|
||||
template_value_re = re.compile(r'^([^\|]*(?=\|))(?:\|?)([^\|]*)(?:\|?)((?<=\|).*?)$')
|
||||
template_value_re = re.compile(r'^([^\|]*(?=\|))(?:\|?)([^\|]*)(?:\|?)((?<=\|).*?)$',
|
||||
flags= re.UNICODE)
|
||||
|
||||
def explode_string_template_value(key):
|
||||
try:
|
||||
@ -120,7 +121,7 @@ class SafeFormat(string.Formatter):
|
||||
try:
|
||||
prefix, key, suffix = explode_string_template_value(key)
|
||||
if kwargs[key]:
|
||||
return prefix + kwargs[key] + suffix
|
||||
return prefix + unicode(kwargs[key]) + suffix
|
||||
return ''
|
||||
except:
|
||||
return ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user