drop fallback for people running from source with calibre 6.1

This commit is contained in:
Eli Schwartz 2023-09-26 19:52:03 -04:00
parent 6ac3ae28b8
commit ce5a6e8b78
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6

View File

@ -109,14 +109,7 @@ _CHARSET_ALIASES = {"macintosh" : "mac-roman", "x-sjis" : "shift-jis"}
def detect(bytestring):
if isinstance(bytestring, str):
bytestring = bytestring.encode('utf-8', 'replace')
try:
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()
return {'encoding': enc, 'confidence': 1 if enc else 0}