Trim whitespace from filename
This avoids an OSError when the book's metadata has whitespace at the end of it.
This commit is contained in:
parent
1a1d105fae
commit
969105b205
@ -254,7 +254,7 @@ def get_valid_filename(value, replace_whitespace=True):
|
|||||||
value = re.sub(r'[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U)
|
value = re.sub(r'[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U)
|
||||||
# pipe has to be replaced with comma
|
# pipe has to be replaced with comma
|
||||||
value = re.sub(r'[\|]+', u',', value, flags=re.U)
|
value = re.sub(r'[\|]+', u',', value, flags=re.U)
|
||||||
value = value[:128]
|
value = value[:128].strip()
|
||||||
if not value:
|
if not value:
|
||||||
raise ValueError("Filename cannot be empty")
|
raise ValueError("Filename cannot be empty")
|
||||||
if sys.version_info.major == 3:
|
if sys.version_info.major == 3:
|
||||||
|
Loading…
Reference in New Issue
Block a user