mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-26 10:00:37 +00:00
Fix except clause
except: will catch specific error.
This commit is contained in:
parent
cf4816fc13
commit
0bc4f52783
@ -44,7 +44,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
try:#maybe description isn't present
|
try:#maybe description isn't present
|
||||||
comments = tree.xpath("//*[local-name() = 'description']/text()")[0]
|
comments = tree.xpath("//*[local-name() = 'description']/text()")[0]
|
||||||
epub_metadata['comments'] = comments
|
epub_metadata['comments'] = comments
|
||||||
except:
|
except IndexError as e:
|
||||||
epub_metadata['comments'] = ""
|
epub_metadata['comments'] = ""
|
||||||
|
|
||||||
for s in ['title', 'description', 'creator']:
|
for s in ['title', 'description', 'creator']:
|
||||||
@ -64,7 +64,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
epub_metadata['languages'] = isoLanguages.get(part3=lang).name
|
epub_metadata['languages'] = isoLanguages.get(part3=lang).name
|
||||||
else:
|
else:
|
||||||
epub_metadata['languages'] = ""
|
epub_metadata['languages'] = ""
|
||||||
except:
|
except IndexError as e:
|
||||||
epub_metadata['languages'] = ""
|
epub_metadata['languages'] = ""
|
||||||
|
|
||||||
coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href", namespaces=ns)
|
coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href", namespaces=ns)
|
||||||
|
@ -5,9 +5,9 @@ from lxml import etree
|
|||||||
import os
|
import os
|
||||||
import uploader
|
import uploader
|
||||||
try:
|
try:
|
||||||
import StringIO
|
|
||||||
except:
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
except ImportError as e:
|
||||||
|
import StringIO
|
||||||
|
|
||||||
def get_fb2_info(tmp_file_path, original_file_extension):
|
def get_fb2_info(tmp_file_path, original_file_extension):
|
||||||
|
|
||||||
|
@ -14,15 +14,15 @@ import traceback
|
|||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
try:
|
try:
|
||||||
from StringIO import StringIO
|
|
||||||
from email.MIMEBase import MIMEBase
|
|
||||||
from email.MIMEMultipart import MIMEMultipart
|
|
||||||
from email.MIMEText import MIMEText
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from email.mime.base import MIMEBase
|
from email.mime.base import MIMEBase
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
|
except ImportError as e:
|
||||||
|
from StringIO import StringIO
|
||||||
|
from email.MIMEBase import MIMEBase
|
||||||
|
from email.MIMEMultipart import MIMEMultipart
|
||||||
|
from email.MIMEText import MIMEText
|
||||||
from email import encoders
|
from email import encoders
|
||||||
from email.generator import Generator
|
from email.generator import Generator
|
||||||
from email.utils import formatdate
|
from email.utils import formatdate
|
||||||
@ -247,8 +247,9 @@ def get_valid_filename(value, replace_whitespace=True):
|
|||||||
re_slugify = re.compile('[\W\s-]', re.UNICODE)
|
re_slugify = re.compile('[\W\s-]', re.UNICODE)
|
||||||
try:
|
try:
|
||||||
value = str(re_slugify.sub('', value).strip())
|
value = str(re_slugify.sub('', value).strip())
|
||||||
except: #will exception on Python2.7
|
except UnicodeEncodeError as e: #will exception on Python2.7
|
||||||
value = unicode(re_slugify.sub('', value).strip())
|
value = unicode(re_slugify.sub('', value).strip())
|
||||||
|
raise
|
||||||
if replace_whitespace:
|
if replace_whitespace:
|
||||||
#*+:\"/<>? werden durch _ ersetzt
|
#*+:\"/<>? werden durch _ ersetzt
|
||||||
value = re.sub('[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U)
|
value = re.sub('[\*\+:\\\"/<>\?]+', u'_', value, flags=re.U)
|
||||||
|
@ -53,7 +53,7 @@ try:
|
|||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
from imp import reload
|
from imp import reload
|
||||||
from past.builtins import xrange
|
from past.builtins import xrange
|
||||||
except:
|
except ImportError as e:
|
||||||
from urllib import quote
|
from urllib import quote
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user