mirror of
https://github.com/janeczku/calibre-web
synced 2025-01-13 19:00:30 +00:00
use condition rather than try/catch
This commit is contained in:
parent
6e3d4877ed
commit
4dfa157161
@ -245,9 +245,9 @@ def get_valid_filename(value, replace_whitespace=True):
|
|||||||
value=value.replace(u'ß',u'ss')
|
value=value.replace(u'ß',u'ss')
|
||||||
value = unicodedata.normalize('NFKD', value)
|
value = unicodedata.normalize('NFKD', value)
|
||||||
re_slugify = re.compile('[\W\s-]', re.UNICODE)
|
re_slugify = re.compile('[\W\s-]', re.UNICODE)
|
||||||
try:
|
if type(value) is str: #Python3 str, Python2 unicode
|
||||||
value = str(re_slugify.sub('', value).strip())
|
value = re_slugify.sub('', value).strip()
|
||||||
except UnicodeEncodeError as e: #will exception on Python2.7
|
else:
|
||||||
value = unicode(re_slugify.sub('', value).strip())
|
value = unicode(re_slugify.sub('', value).strip())
|
||||||
if replace_whitespace:
|
if replace_whitespace:
|
||||||
#*+:\"/<>? werden durch _ ersetzt
|
#*+:\"/<>? werden durch _ ersetzt
|
||||||
|
@ -1052,8 +1052,10 @@ def stats():
|
|||||||
stdin=subprocess.PIPE)
|
stdin=subprocess.PIPE)
|
||||||
p.wait()
|
p.wait()
|
||||||
for lines in p.stdout.readlines():
|
for lines in p.stdout.readlines():
|
||||||
if re.search('Amazon kindlegen\(', str(lines)):
|
if type(lines) is bytes:
|
||||||
versions['KindlegenVersion'] = str(lines)
|
lines = lines.decode('utf-8')
|
||||||
|
if re.search('Amazon kindlegen\(', lines):
|
||||||
|
versions['KindlegenVersion'] = lines
|
||||||
versions['PythonVersion'] = sys.version
|
versions['PythonVersion'] = sys.version
|
||||||
versions['babel'] = babelVersion
|
versions['babel'] = babelVersion
|
||||||
versions['sqlalchemy'] = sqlalchemyVersion
|
versions['sqlalchemy'] = sqlalchemyVersion
|
||||||
|
Loading…
Reference in New Issue
Block a user