mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-19 01:27:40 +00:00
use condition rather than try/catch
This commit is contained in:
@@ -245,9 +245,9 @@ def get_valid_filename(value, replace_whitespace=True):
|
||||
value=value.replace(u'ß',u'ss')
|
||||
value = unicodedata.normalize('NFKD', value)
|
||||
re_slugify = re.compile('[\W\s-]', re.UNICODE)
|
||||
try:
|
||||
value = str(re_slugify.sub('', value).strip())
|
||||
except UnicodeEncodeError as e: #will exception on Python2.7
|
||||
if type(value) is str: #Python3 str, Python2 unicode
|
||||
value = re_slugify.sub('', value).strip()
|
||||
else:
|
||||
value = unicode(re_slugify.sub('', value).strip())
|
||||
if replace_whitespace:
|
||||
#*+:\"/<>? werden durch _ ersetzt
|
||||
|
Reference in New Issue
Block a user