mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use six for reraise
This commit is contained in:
parent
01fbf09c0b
commit
1d15fe84c0
Binary file not shown.
@ -11,6 +11,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, shutil, uuid, json, glob, time, hashlib, errno, sys
|
import os, shutil, uuid, json, glob, time, hashlib, errno, sys
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
import six
|
||||||
import apsw
|
import apsw
|
||||||
|
|
||||||
from calibre import isbytestring, force_unicode, prints, as_unicode
|
from calibre import isbytestring, force_unicode, prints, as_unicode
|
||||||
@ -1626,7 +1627,7 @@ class DB(object):
|
|||||||
except EnvironmentError as err:
|
except EnvironmentError as err:
|
||||||
if err.errno == errno.EEXIST:
|
if err.errno == errno.EEXIST:
|
||||||
# Parent directory already exists, re-raise original exception
|
# Parent directory already exists, re-raise original exception
|
||||||
raise exc_info[0], exc_info[1], exc_info[2]
|
six.reraise(*exc_info)
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
del exc_info
|
del exc_info
|
||||||
|
@ -6,6 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
|||||||
import re, sys
|
import re, sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
import six
|
||||||
from lxml.etree import tostring
|
from lxml.etree import tostring
|
||||||
from lxml.html import (fragment_fromstring, document_fromstring,
|
from lxml.html import (fragment_fromstring, document_fromstring,
|
||||||
tostring as htostring)
|
tostring as htostring)
|
||||||
@ -156,7 +157,7 @@ class Document:
|
|||||||
return cleaned_article
|
return cleaned_article
|
||||||
except StandardError as e:
|
except StandardError as e:
|
||||||
self.log.exception('error getting summary: ')
|
self.log.exception('error getting summary: ')
|
||||||
raise Unparseable(str(e)), None, sys.exc_info()[2]
|
six.reraise(Unparseable, Unparseable(str(e)), sys.exc_info()[2])
|
||||||
|
|
||||||
def get_article(self, candidates, best_candidate):
|
def get_article(self, candidates, best_candidate):
|
||||||
# Now that we have the top candidate, look through its siblings for content that might also be related.
|
# Now that we have the top candidate, look through its siblings for content that might also be related.
|
||||||
|
@ -14,6 +14,7 @@ from Queue import Queue, Empty
|
|||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
|
|
||||||
|
import six
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QImageReader, QFormLayout, QVBoxLayout, QSplitter, QGroupBox, QListWidget,
|
QImageReader, QFormLayout, QVBoxLayout, QSplitter, QGroupBox, QListWidget,
|
||||||
QLineEdit, QSpinBox, QTextEdit, QSize, QListWidgetItem, QIcon, QImage,
|
QLineEdit, QSpinBox, QTextEdit, QSize, QListWidgetItem, QIcon, QImage,
|
||||||
@ -368,7 +369,7 @@ def create_themeball(report, progress=None, abort=None):
|
|||||||
return
|
return
|
||||||
if errors:
|
if errors:
|
||||||
e = errors[0]
|
e = errors[0]
|
||||||
raise e[0], e[1], e[2]
|
six.reraise(*e)
|
||||||
|
|
||||||
if progress is not None:
|
if progress is not None:
|
||||||
progress(next(num), _('Creating theme file'))
|
progress(next(num), _('Creating theme file'))
|
||||||
|
@ -11,6 +11,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
|
import six
|
||||||
from PyQt5.Qt import QEventLoop
|
from PyQt5.Qt import QEventLoop
|
||||||
|
|
||||||
from calibre import force_unicode
|
from calibre import force_unicode
|
||||||
@ -314,7 +315,7 @@ def linux_native_dialog(name):
|
|||||||
t.start()
|
t.start()
|
||||||
loop.exec_(QEventLoop.ExcludeUserInputEvents)
|
loop.exec_(QEventLoop.ExcludeUserInputEvents)
|
||||||
if ret[1] is not None:
|
if ret[1] is not None:
|
||||||
raise ret[1][0], ret[1][1], ret[1][2]
|
six.reraise(*ret[1])
|
||||||
return ret[0]
|
return ret[0]
|
||||||
except Exception:
|
except Exception:
|
||||||
linux_native_dialog.native_failed = True
|
linux_native_dialog.native_failed = True
|
||||||
|
@ -14,6 +14,8 @@ from operator import itemgetter
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from future_builtins import map
|
from future_builtins import map
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from calibre import guess_type, force_unicode
|
from calibre import guess_type, force_unicode
|
||||||
from calibre.constants import __version__, plugins
|
from calibre.constants import __version__, plugins
|
||||||
from calibre.srv.loop import WRITE
|
from calibre.srv.loop import WRITE
|
||||||
@ -478,7 +480,7 @@ class HTTPConnection(HTTPRequest):
|
|||||||
if e.log:
|
if e.log:
|
||||||
self.log.warn(e.log)
|
self.log.warn(e.log)
|
||||||
return self.simple_response(e.http_code, msg=e.message or '', close_after_response=e.close_connection, extra_headers=eh)
|
return self.simple_response(e.http_code, msg=e.message or '', close_after_response=e.close_connection, extra_headers=eh)
|
||||||
raise etype, e, tb
|
six.reraise(etype, e, tb)
|
||||||
|
|
||||||
data, output = result
|
data, output = result
|
||||||
output = self.finalize_output(output, data, self.method is HTTP1)
|
output = self.finalize_output(output, data, self.method is HTTP1)
|
||||||
|
@ -7,6 +7,9 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from calibre.constants import iswindows, plugins
|
from calibre.constants import iswindows, plugins
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -119,7 +122,11 @@ if iswindows:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def raise_winerror(pywinerr):
|
def raise_winerror(pywinerr):
|
||||||
raise WindowsError(pywinerr.winerror, (pywinerr.funcname or '') + b': ' + (pywinerr.strerror or '')), None, sys.exc_info()[2]
|
six.reraise(
|
||||||
|
WindowsError,
|
||||||
|
WindowsError(pywinerr.winerror,
|
||||||
|
(pywinerr.funcname or '') + b': ' + (pywinerr.strerror or '')),
|
||||||
|
sys.exc_info()[2])
|
||||||
|
|
||||||
def os_open(path, flags, mode=0o777, share_flags=FILE_SHARE_VALID_FLAGS):
|
def os_open(path, flags, mode=0o777, share_flags=FILE_SHARE_VALID_FLAGS):
|
||||||
'''
|
'''
|
||||||
@ -173,7 +180,7 @@ else:
|
|||||||
return speedup.fdopen(os.open(path, flags), path, mode, buffering)
|
return speedup.fdopen(os.open(path, flags), path, mode, buffering)
|
||||||
|
|
||||||
def raise_winerror(x):
|
def raise_winerror(x):
|
||||||
raise NotImplementedError(), None, sys.exc_info()[2]
|
six.reraise(NotImplementedError, None, sys.exc_info()[2])
|
||||||
|
|
||||||
|
|
||||||
def find_tests():
|
def find_tests():
|
||||||
|
@ -12,6 +12,7 @@ __all__ = ['dukpy', 'Context', 'undefined', 'JSError', 'to_python']
|
|||||||
import errno, os, sys, numbers, hashlib, json
|
import errno, os, sys, numbers, hashlib, json
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
import six
|
||||||
import dukpy
|
import dukpy
|
||||||
|
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
@ -157,7 +158,7 @@ class Function(object):
|
|||||||
self.reraise(e)
|
self.reraise(e)
|
||||||
|
|
||||||
def reraise(self, e):
|
def reraise(self, e):
|
||||||
raise JSError(e), None, sys.exc_info()[2]
|
six.reraise(JSError, JSError(e), sys.exc_info()[2])
|
||||||
|
|
||||||
def to_python(x):
|
def to_python(x):
|
||||||
try:
|
try:
|
||||||
@ -332,7 +333,7 @@ class Context(object):
|
|||||||
'<init>')
|
'<init>')
|
||||||
|
|
||||||
def reraise(self, e):
|
def reraise(self, e):
|
||||||
raise JSError(e), None, sys.exc_info()[2]
|
six.reraise(JSError, JSError(e), sys.exc_info()[2])
|
||||||
|
|
||||||
def eval(self, code='', fname='<eval>', noreturn=False):
|
def eval(self, code='', fname='<eval>', noreturn=False):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user