mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-13 17:13:32 +02:00
Moved misc functions from polyglot package to single polyglot module.
This commit is contained in:
@@ -2,7 +2,7 @@ import struct
|
||||
from io import BytesIO
|
||||
from collections import defaultdict
|
||||
|
||||
from ebook_converter.polyglot.builtins import as_bytes
|
||||
from ebook_converter import polyglot
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -38,7 +38,7 @@ def get_tables(raw):
|
||||
|
||||
def get_table(raw, name):
|
||||
''' Get the raw table bytes for the specified table in the font '''
|
||||
name = as_bytes(name.lower())
|
||||
name = polyglot.as_bytes(name.lower())
|
||||
for table_tag, table, table_index, table_offset, table_checksum in get_tables(raw):
|
||||
if table_tag.lower() == name:
|
||||
return table, table_index, table_offset, table_checksum
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from ebook_converter import polyglot
|
||||
|
||||
|
||||
MSGPACK_MIME = 'application/x-msgpack'
|
||||
CANARY = 'jPoAv3zOyHvQ5JFNYg4hJ9'
|
||||
|
||||
@@ -56,11 +59,11 @@ def json_dumps(data, **kw):
|
||||
|
||||
|
||||
def decode_metadata(x, for_json):
|
||||
from ebook_converter.polyglot.binary import from_base64_bytes
|
||||
from ebook_converter.ebooks.metadata.book.serialize import metadata_from_dict
|
||||
obj = metadata_from_dict(x)
|
||||
if for_json and obj.cover_data and obj.cover_data[1]:
|
||||
obj.cover_data = obj.cover_data[0], from_base64_bytes(obj.cover_data[1])
|
||||
obj.cover_data = (obj.cover_data[0],
|
||||
polyglot.from_base64_bytes(obj.cover_data[1]))
|
||||
return obj
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import os, sys, re
|
||||
import fcntl, termios, struct
|
||||
import fcntl
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
import sys
|
||||
import termios
|
||||
|
||||
|
||||
def fmt(code):
|
||||
|
||||
@@ -10,7 +10,7 @@ from tempfile import SpooledTemporaryFile
|
||||
from ebook_converter.utils import filenames as fms
|
||||
from ebook_converter.constants_old import filesystem_encoding
|
||||
from ebook_converter.ebooks.chardet import detect
|
||||
from ebook_converter.polyglot.builtins import as_bytes
|
||||
from ebook_converter import polyglot
|
||||
|
||||
try:
|
||||
import zlib # We may need its compression method
|
||||
@@ -330,7 +330,7 @@ class ZipInfo (object):
|
||||
if os.sep != '/':
|
||||
os_sep, sep = os.sep, '/'
|
||||
if isinstance(filename, bytes):
|
||||
os_sep, sep = as_bytes(os_sep), b'/'
|
||||
os_sep, sep = polyglot.as_bytes(os_sep), b'/'
|
||||
if os_sep in filename:
|
||||
filename = filename.replace(os_sep, sep)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user