mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
drop fallback for people running from source with calibre 6.1
This commit is contained in:
parent
6ac3ae28b8
commit
ce5a6e8b78
@ -109,14 +109,7 @@ _CHARSET_ALIASES = {"macintosh" : "mac-roman", "x-sjis" : "shift-jis"}
|
|||||||
def detect(bytestring):
|
def detect(bytestring):
|
||||||
if isinstance(bytestring, str):
|
if isinstance(bytestring, str):
|
||||||
bytestring = bytestring.encode('utf-8', 'replace')
|
bytestring = bytestring.encode('utf-8', 'replace')
|
||||||
try:
|
from calibre_extensions.uchardet import detect as implementation
|
||||||
from calibre_extensions.uchardet import detect as implementation
|
|
||||||
except ImportError:
|
|
||||||
# People running from source without updated binaries
|
|
||||||
from cchardet import detect as cdi
|
|
||||||
|
|
||||||
def implementation(x):
|
|
||||||
return cdi(x).get('encoding') or ''
|
|
||||||
enc = implementation(bytestring).lower()
|
enc = implementation(bytestring).lower()
|
||||||
return {'encoding': enc, 'confidence': 1 if enc else 0}
|
return {'encoding': enc, 'confidence': 1 if enc else 0}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user