mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
...
This commit is contained in:
parent
b96ec77417
commit
c1e1d7712b
@ -10,16 +10,8 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, sys, re
|
import os, sys, re
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
try:
|
|
||||||
from calibre import force_unicode
|
from calibre import force_unicode
|
||||||
from calibre.constants import filesystem_encoding
|
from calibre.constants import filesystem_encoding
|
||||||
filesystem_encoding, force_unicode
|
|
||||||
except ImportError:
|
|
||||||
filesystem_encoding = sys.getfilesystemencoding()
|
|
||||||
def force_unicode(x, enc=filesystem_encoding):
|
|
||||||
if isinstance(x, bytes):
|
|
||||||
x = x.decode(enc, 'replace')
|
|
||||||
return x
|
|
||||||
|
|
||||||
class UNRARError(Exception):
|
class UNRARError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -93,11 +85,7 @@ class RARStream(object):
|
|||||||
|
|
||||||
|
|
||||||
def RARFile(stream, get_comment=False):
|
def RARFile(stream, get_comment=False):
|
||||||
try:
|
|
||||||
from calibre.constants import plugins
|
from calibre.constants import plugins
|
||||||
except ImportError:
|
|
||||||
unrar, err = sys.modules['unrar'], None
|
|
||||||
else:
|
|
||||||
unrar, err = plugins['unrar']
|
unrar, err = plugins['unrar']
|
||||||
if err:
|
if err:
|
||||||
raise RuntimeError('Failed to load unrar module with error: %s'
|
raise RuntimeError('Failed to load unrar module with error: %s'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user