mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Drop (object) from class definitions
Python2 had old-style classes (no "(object)"), and new style classes (with "object"). Under Py3 this is a noop, so let's drop it to make the code a bit shorter.
This commit is contained in:
parent
52c55cc42e
commit
9d63b6ae56
@ -58,7 +58,7 @@ def binary_includes():
|
|||||||
] + list(map(qt_get_dll_path, QT_DLLS))
|
] + list(map(qt_get_dll_path, QT_DLLS))
|
||||||
|
|
||||||
|
|
||||||
class Env(object):
|
class Env:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.src_root = CALIBRE_DIR
|
self.src_root = CALIBRE_DIR
|
||||||
|
@ -146,7 +146,7 @@ def flush(func):
|
|||||||
return ff
|
return ff
|
||||||
|
|
||||||
|
|
||||||
class Freeze(object):
|
class Freeze:
|
||||||
|
|
||||||
FID = '@executable_path/../Frameworks'
|
FID = '@executable_path/../Frameworks'
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ def run_compiler(env, *cmd):
|
|||||||
run(*cmd, cwd=env.obj_dir)
|
run(*cmd, cwd=env.obj_dir)
|
||||||
|
|
||||||
|
|
||||||
class Env(object):
|
class Env:
|
||||||
|
|
||||||
def __init__(self, build_dir):
|
def __init__(self, build_dir):
|
||||||
self.python_base = os.path.join(PREFIX, 'private', 'python')
|
self.python_base = os.path.join(PREFIX, 'private', 'python')
|
||||||
|
@ -162,7 +162,7 @@ class MerryExtract():
|
|||||||
return killingSoup
|
return killingSoup
|
||||||
|
|
||||||
|
|
||||||
class MerryProcess(object):
|
class MerryProcess:
|
||||||
myKiller = MerryExtract()
|
myKiller = MerryExtract()
|
||||||
myPrepare = MerryPreProcess()
|
myPrepare = MerryPreProcess()
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ def edit_file(path):
|
|||||||
]).wait() == 0
|
]).wait() == 0
|
||||||
|
|
||||||
|
|
||||||
class Command(object):
|
class Command:
|
||||||
|
|
||||||
SRC = SRC
|
SRC = SRC
|
||||||
RESOURCES = os.path.join(os.path.dirname(SRC), 'resources')
|
RESOURCES = os.path.join(os.path.dirname(SRC), 'resources')
|
||||||
|
@ -31,7 +31,7 @@ def absolutize(paths):
|
|||||||
return list(set([x if os.path.isabs(x) else os.path.join(SRC, x.replace('/', os.sep)) for x in paths]))
|
return list(set([x if os.path.isabs(x) else os.path.join(SRC, x.replace('/', os.sep)) for x in paths]))
|
||||||
|
|
||||||
|
|
||||||
class Extension(object):
|
class Extension:
|
||||||
|
|
||||||
def __init__(self, name, sources, **kwargs):
|
def __init__(self, name, sources, **kwargs):
|
||||||
self.data = d = {}
|
self.data = d = {}
|
||||||
|
@ -69,7 +69,7 @@ class ReadFileWithProgressReporting: # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class Base(object): # {{{
|
class Base: # {{{
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.d = os.path.dirname
|
self.d = os.path.dirname
|
||||||
|
@ -194,7 +194,7 @@ def convert_node(fields, x, names={}, import_data=None):
|
|||||||
Alias = namedtuple('Alias', 'name asname')
|
Alias = namedtuple('Alias', 'name asname')
|
||||||
|
|
||||||
|
|
||||||
class Module(object):
|
class Module:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ class Translations(POT): # {{{
|
|||||||
|
|
||||||
def auto_fix_iso639_files(self, files):
|
def auto_fix_iso639_files(self, files):
|
||||||
|
|
||||||
class Fix(object):
|
class Fix:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.seen = set()
|
self.seen = set()
|
||||||
@ -391,7 +391,7 @@ class Translations(POT): # {{{
|
|||||||
self.seen.add(msgstr)
|
self.seen.add(msgstr)
|
||||||
return match.group()
|
return match.group()
|
||||||
|
|
||||||
class Fix2(object):
|
class Fix2:
|
||||||
|
|
||||||
def __init__(self, fix1):
|
def __init__(self, fix1):
|
||||||
self.bad = fix1.bad
|
self.bad = fix1.bad
|
||||||
|
@ -358,7 +358,7 @@ def fit_image(width, height, pwidth, pheight):
|
|||||||
return scaled, int(width), int(height)
|
return scaled, int(width), int(height)
|
||||||
|
|
||||||
|
|
||||||
class CurrentDir(object):
|
class CurrentDir:
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
@ -30,7 +30,7 @@ class PluginInstallationType(enum.IntEnum):
|
|||||||
BUILTIN = 3
|
BUILTIN = 3
|
||||||
|
|
||||||
|
|
||||||
class Plugin(object): # {{{
|
class Plugin: # {{{
|
||||||
'''
|
'''
|
||||||
A calibre plugin. Useful members include:
|
A calibre plugin. Useful members include:
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from calibre.customize import Plugin
|
|||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
|
|
||||||
class ConversionOption(object):
|
class ConversionOption:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Class representing conversion options
|
Class representing conversion options
|
||||||
@ -50,7 +50,7 @@ class ConversionOption(object):
|
|||||||
choices=self.choices)
|
choices=self.choices)
|
||||||
|
|
||||||
|
|
||||||
class OptionRecommendation(object):
|
class OptionRecommendation:
|
||||||
LOW = 1
|
LOW = 1
|
||||||
MED = 2
|
MED = 2
|
||||||
HIGH = 3
|
HIGH = 3
|
||||||
@ -86,7 +86,7 @@ class OptionRecommendation(object):
|
|||||||
self.recommended_value) + ' is not a string or a number')
|
self.recommended_value) + ' is not a string or a number')
|
||||||
|
|
||||||
|
|
||||||
class DummyReporter(object):
|
class DummyReporter:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cancel_requested = False
|
self.cancel_requested = False
|
||||||
|
@ -373,7 +373,7 @@ def metadata_writers():
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class QuickMetadata(object):
|
class QuickMetadata:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.quick = False
|
self.quick = False
|
||||||
@ -388,7 +388,7 @@ class QuickMetadata(object):
|
|||||||
quick_metadata = QuickMetadata()
|
quick_metadata = QuickMetadata()
|
||||||
|
|
||||||
|
|
||||||
class ApplyNullMetadata(object):
|
class ApplyNullMetadata:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.apply_null = False
|
self.apply_null = False
|
||||||
@ -403,7 +403,7 @@ class ApplyNullMetadata(object):
|
|||||||
apply_null_metadata = ApplyNullMetadata()
|
apply_null_metadata = ApplyNullMetadata()
|
||||||
|
|
||||||
|
|
||||||
class ForceIdentifiers(object):
|
class ForceIdentifiers:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.force_identifiers = False
|
self.force_identifiers = False
|
||||||
|
@ -70,7 +70,7 @@ CUSTOM_DATA_TYPES = frozenset(('rating', 'text', 'comments', 'datetime',
|
|||||||
WINDOWS_RESERVED_NAMES = frozenset('CON PRN AUX NUL COM1 COM2 COM3 COM4 COM5 COM6 COM7 COM8 COM9 LPT1 LPT2 LPT3 LPT4 LPT5 LPT6 LPT7 LPT8 LPT9'.split())
|
WINDOWS_RESERVED_NAMES = frozenset('CON PRN AUX NUL COM1 COM2 COM3 COM4 COM5 COM6 COM7 COM8 COM9 LPT1 LPT2 LPT3 LPT4 LPT5 LPT6 LPT7 LPT8 LPT9'.split())
|
||||||
|
|
||||||
|
|
||||||
class DynamicFilter(object): # {{{
|
class DynamicFilter: # {{{
|
||||||
|
|
||||||
'No longer used, present for legacy compatibility'
|
'No longer used, present for legacy compatibility'
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ def rmtree_with_retry(path, sleep_time=1):
|
|||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
|
|
||||||
class DB(object):
|
class DB:
|
||||||
|
|
||||||
PATH_LIMIT = 40 if iswindows else 100
|
PATH_LIMIT = 40 if iswindows else 100
|
||||||
WINDOWS_LIBRARY_PATH_LIMIT = 75
|
WINDOWS_LIBRARY_PATH_LIMIT = 75
|
||||||
|
@ -126,7 +126,7 @@ def _add_default_custom_column_values(mi, fm):
|
|||||||
dynamic_category_preferences = frozenset({'grouped_search_make_user_categories', 'grouped_search_terms', 'user_categories'})
|
dynamic_category_preferences = frozenset({'grouped_search_make_user_categories', 'grouped_search_terms', 'user_categories'})
|
||||||
|
|
||||||
|
|
||||||
class Cache(object):
|
class Cache:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
An in-memory cache of the metadata.db file from a calibre library.
|
An in-memory cache of the metadata.db file from a calibre library.
|
||||||
@ -1069,7 +1069,7 @@ class Cache(object):
|
|||||||
orders = tuple(1 if order else -1 for _, order in fields)
|
orders = tuple(1 if order else -1 for _, order in fields)
|
||||||
Lazy = object() # Lazy load the sort keys for sub-sort fields
|
Lazy = object() # Lazy load the sort keys for sub-sort fields
|
||||||
|
|
||||||
class SortKey(object):
|
class SortKey:
|
||||||
|
|
||||||
__slots__ = 'book_id', 'sort_key'
|
__slots__ = 'book_id', 'sort_key'
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from calibre.utils.icu import sort_key, collation_order
|
|||||||
CATEGORY_SORTS = ('name', 'popularity', 'rating') # This has to be a tuple not a set
|
CATEGORY_SORTS = ('name', 'popularity', 'rating') # This has to be a tuple not a set
|
||||||
|
|
||||||
|
|
||||||
class Tag(object):
|
class Tag:
|
||||||
|
|
||||||
__slots__ = ('name', 'original_name', 'id', 'count', 'state', 'is_hierarchical',
|
__slots__ = ('name', 'original_name', 'id', 'count', 'state', 'is_hierarchical',
|
||||||
'is_editable', 'is_searchable', 'id_set', 'avg_rating', 'sort',
|
'is_editable', 'is_searchable', 'id_set', 'avg_rating', 'sort',
|
||||||
|
@ -42,7 +42,7 @@ automatically, every time metadata is changed.
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
class BackupProgress(object):
|
class BackupProgress:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.total = 0
|
self.total = 0
|
||||||
|
@ -101,7 +101,7 @@ an opf file). You can get id numbers from the search command.
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
class DBProxy(object):
|
class DBProxy:
|
||||||
|
|
||||||
# Proxy to allow do_save_book_to_disk() to work with remote database
|
# Proxy to allow do_save_book_to_disk() to work with remote database
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ what is found in the OPF files.
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
class Progress(object):
|
class Progress:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.total = 1
|
self.total = 1
|
||||||
|
@ -125,7 +125,7 @@ def read_credentials(opts):
|
|||||||
return username, pw
|
return username, pw
|
||||||
|
|
||||||
|
|
||||||
class DBCtx(object):
|
class DBCtx:
|
||||||
|
|
||||||
def __init__(self, opts):
|
def __init__(self, opts):
|
||||||
self.library_path = opts.library_path or prefs['library_path']
|
self.library_path = opts.library_path or prefs['library_path']
|
||||||
|
@ -16,7 +16,7 @@ from polyglot.builtins import iteritems
|
|||||||
from polyglot.io import PolyglotBytesIO
|
from polyglot.io import PolyglotBytesIO
|
||||||
|
|
||||||
|
|
||||||
class Checker(object):
|
class Checker:
|
||||||
|
|
||||||
def __init__(self, kw):
|
def __init__(self, kw):
|
||||||
for k, v in iteritems(kw):
|
for k, v in iteritems(kw):
|
||||||
|
@ -39,7 +39,7 @@ class InvalidLinkTable(Exception):
|
|||||||
self.field_name = name
|
self.field_name = name
|
||||||
|
|
||||||
|
|
||||||
class Field(object):
|
class Field:
|
||||||
|
|
||||||
is_many = False
|
is_many = False
|
||||||
is_many_many = False
|
is_many_many = False
|
||||||
@ -441,7 +441,7 @@ class OnDeviceField(OneToOneField):
|
|||||||
yield val, book_ids
|
yield val, book_ids
|
||||||
|
|
||||||
|
|
||||||
class LazySortMap(object):
|
class LazySortMap:
|
||||||
|
|
||||||
__slots__ = ('default_sort_key', 'sort_key_func', 'id_map', 'cache')
|
__slots__ = ('default_sort_key', 'sort_key_func', 'id_map', 'cache')
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ class FormatsField(ManyToManyField):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class LazySeriesSortMap(object):
|
class LazySeriesSortMap:
|
||||||
|
|
||||||
__slots__ = ('default_sort_key', 'sort_key_func', 'id_map', 'cache')
|
__slots__ = ('default_sort_key', 'sort_key_func', 'id_map', 'cache')
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ def resolved(f):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class MutableBase(object):
|
class MutableBase:
|
||||||
|
|
||||||
@resolved
|
@resolved
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -161,7 +161,7 @@ class ThreadSafePrefs(MutableMapping):
|
|||||||
return json.loads(raw, object_hook=from_json)
|
return json.loads(raw, object_hook=from_json)
|
||||||
|
|
||||||
|
|
||||||
class LibraryDatabase(object):
|
class LibraryDatabase:
|
||||||
|
|
||||||
''' Emulate the old LibraryDatabase2 interface '''
|
''' Emulate the old LibraryDatabase2 interface '''
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def create_locks():
|
|||||||
return wrapper(l), wrapper(l, is_shared=False)
|
return wrapper(l), wrapper(l, is_shared=False)
|
||||||
|
|
||||||
|
|
||||||
class SHLock(object): # {{{
|
class SHLock: # {{{
|
||||||
'''
|
'''
|
||||||
Shareable lock class. Used to implement the Multiple readers-single writer
|
Shareable lock class. Used to implement the Multiple readers-single writer
|
||||||
paradigm. As best as I can tell, neither writer nor reader starvation
|
paradigm. As best as I can tell, neither writer nor reader starvation
|
||||||
@ -222,7 +222,7 @@ class SHLock(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class RWLockWrapper(object):
|
class RWLockWrapper:
|
||||||
|
|
||||||
def __init__(self, shlock, is_shared=True):
|
def __init__(self, shlock, is_shared=True):
|
||||||
self._shlock = shlock
|
self._shlock = shlock
|
||||||
@ -266,7 +266,7 @@ class DebugRWLockWrapper(RWLockWrapper):
|
|||||||
__exit__ = release
|
__exit__ = release
|
||||||
|
|
||||||
|
|
||||||
class SafeReadLock(object):
|
class SafeReadLock:
|
||||||
|
|
||||||
def __init__(self, read_lock):
|
def __init__(self, read_lock):
|
||||||
self.read_lock = read_lock
|
self.read_lock = read_lock
|
||||||
|
@ -13,7 +13,7 @@ from calibre.utils.date import isoformat, DEFAULT_DATE
|
|||||||
from polyglot.builtins import itervalues, unicode_type
|
from polyglot.builtins import itervalues, unicode_type
|
||||||
|
|
||||||
|
|
||||||
class SchemaUpgrade(object):
|
class SchemaUpgrade:
|
||||||
|
|
||||||
def __init__(self, db, library_path, field_metadata):
|
def __init__(self, db, library_path, field_metadata):
|
||||||
db.execute('BEGIN EXCLUSIVE TRANSACTION')
|
db.execute('BEGIN EXCLUSIVE TRANSACTION')
|
||||||
|
@ -87,7 +87,7 @@ def _match(query, value, matchkind, use_primary_find_in_search=True, case_sensit
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class DateSearch(object): # {{{
|
class DateSearch: # {{{
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.operators = OrderedDict((
|
self.operators = OrderedDict((
|
||||||
@ -212,7 +212,7 @@ class DateSearch(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class NumericSearch(object): # {{{
|
class NumericSearch: # {{{
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.operators = OrderedDict((
|
self.operators = OrderedDict((
|
||||||
@ -305,7 +305,7 @@ class NumericSearch(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class BooleanSearch(object): # {{{
|
class BooleanSearch: # {{{
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.local_no = icu_lower(_('no'))
|
self.local_no = icu_lower(_('no'))
|
||||||
@ -347,7 +347,7 @@ class BooleanSearch(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class KeyPairSearch(object): # {{{
|
class KeyPairSearch: # {{{
|
||||||
|
|
||||||
def __call__(self, query, field_iter, candidates, use_primary_find):
|
def __call__(self, query, field_iter, candidates, use_primary_find):
|
||||||
matches = set()
|
matches = set()
|
||||||
@ -388,7 +388,7 @@ class KeyPairSearch(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class SavedSearchQueries(object): # {{{
|
class SavedSearchQueries: # {{{
|
||||||
queries = {}
|
queries = {}
|
||||||
opt_name = ''
|
opt_name = ''
|
||||||
|
|
||||||
@ -794,7 +794,7 @@ class Parser(SearchQueryParser): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class LRUCache(object): # {{{
|
class LRUCache: # {{{
|
||||||
|
|
||||||
'A simple Least-Recently-Used cache'
|
'A simple Least-Recently-Used cache'
|
||||||
|
|
||||||
@ -851,7 +851,7 @@ class LRUCache(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class Search(object):
|
class Search:
|
||||||
|
|
||||||
MAX_CACHE_UPDATE = 50
|
MAX_CACHE_UPDATE = 50
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ ONE_ONE, MANY_ONE, MANY_MANY = range(3)
|
|||||||
null = object()
|
null = object()
|
||||||
|
|
||||||
|
|
||||||
class Table(object):
|
class Table:
|
||||||
|
|
||||||
def __init__(self, name, metadata, link_table=None):
|
def __init__(self, name, metadata, link_table=None):
|
||||||
self.name, self.metadata = name, metadata
|
self.name, self.metadata = name, metadata
|
||||||
|
@ -18,7 +18,7 @@ from polyglot import reprlib
|
|||||||
# Utils {{{
|
# Utils {{{
|
||||||
|
|
||||||
|
|
||||||
class ET(object):
|
class ET:
|
||||||
|
|
||||||
def __init__(self, func_name, args, kwargs={}, old=None, legacy=None):
|
def __init__(self, func_name, args, kwargs={}, old=None, legacy=None):
|
||||||
self.func_name = func_name
|
self.func_name = func_name
|
||||||
|
@ -102,7 +102,7 @@ class CacheError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ThumbnailCache(object):
|
class ThumbnailCache:
|
||||||
|
|
||||||
' This is a persistent disk cache to speed up loading and resizing of covers '
|
' This is a persistent disk cache to speed up loading and resizing of covers '
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ def sanitize_sort_field_name(field_metadata, field):
|
|||||||
return field
|
return field
|
||||||
|
|
||||||
|
|
||||||
class MarkedVirtualField(object):
|
class MarkedVirtualField:
|
||||||
|
|
||||||
def __init__(self, marked_ids):
|
def __init__(self, marked_ids):
|
||||||
self.marked_ids = marked_ids
|
self.marked_ids = marked_ids
|
||||||
@ -37,7 +37,7 @@ class MarkedVirtualField(object):
|
|||||||
return lambda book_id:g(book_id, '')
|
return lambda book_id:g(book_id, '')
|
||||||
|
|
||||||
|
|
||||||
class TableRow(object):
|
class TableRow:
|
||||||
|
|
||||||
def __init__(self, book_id, view):
|
def __init__(self, book_id, view):
|
||||||
self.book_id = book_id
|
self.book_id = book_id
|
||||||
@ -74,7 +74,7 @@ def format_identifiers(x):
|
|||||||
return ','.join('%s:%s'%(k, v) for k, v in iteritems(x))
|
return ','.join('%s:%s'%(k, v) for k, v in iteritems(x))
|
||||||
|
|
||||||
|
|
||||||
class View(object):
|
class View:
|
||||||
|
|
||||||
''' A table view of the database, with rows and columns. Also supports
|
''' A table view of the database, with rows and columns. Also supports
|
||||||
filtering and sorting. '''
|
filtering and sorting. '''
|
||||||
|
@ -530,7 +530,7 @@ def dummy(book_id_val_map, *args):
|
|||||||
return set()
|
return set()
|
||||||
|
|
||||||
|
|
||||||
class Writer(object):
|
class Writer:
|
||||||
|
|
||||||
def __init__(self, field):
|
def __init__(self, field):
|
||||||
self.adapter = get_adapter(field.name, field.metadata)
|
self.adapter = get_adapter(field.name, field.metadata)
|
||||||
|
@ -23,7 +23,7 @@ from polyglot.io import PolyglotStringIO
|
|||||||
MINIMUM_COL_WIDTH = 12 # : Minimum width of columns in ls output
|
MINIMUM_COL_WIDTH = 12 # : Minimum width of columns in ls output
|
||||||
|
|
||||||
|
|
||||||
class FileFormatter(object):
|
class FileFormatter:
|
||||||
|
|
||||||
def __init__(self, file):
|
def __init__(self, file):
|
||||||
self.is_dir = file.is_dir
|
self.is_dir = file.is_dir
|
||||||
|
@ -767,7 +767,7 @@ class BookList(list):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class CurrentlyConnectedDevice(object):
|
class CurrentlyConnectedDevice:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._device = None
|
self._device = None
|
||||||
|
@ -21,7 +21,7 @@ from calibre.constants import DEBUG
|
|||||||
from polyglot.builtins import range, as_unicode, as_bytes, unicode_type, map
|
from polyglot.builtins import range, as_unicode, as_bytes, unicode_type, map
|
||||||
|
|
||||||
|
|
||||||
class APNXBuilder(object):
|
class APNXBuilder:
|
||||||
'''
|
'''
|
||||||
Create an APNX file using a pseudo page mapping.
|
Create an APNX file using a pseudo page mapping.
|
||||||
'''
|
'''
|
||||||
|
@ -120,7 +120,7 @@ class Book(Book_):
|
|||||||
return super(Book,self).__str__() + "\n" + ans
|
return super(Book,self).__str__() + "\n" + ans
|
||||||
|
|
||||||
|
|
||||||
class ImageWrapper(object):
|
class ImageWrapper:
|
||||||
|
|
||||||
def __init__(self, image_path):
|
def __init__(self, image_path):
|
||||||
self.image_path = image_path
|
self.image_path = image_path
|
||||||
|
@ -68,7 +68,7 @@ def any_in(haystack, *needles):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class DummyCSSPreProcessor(object):
|
class DummyCSSPreProcessor:
|
||||||
|
|
||||||
def __call__(self, data, add_namespace=False):
|
def __call__(self, data, add_namespace=False):
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from calibre.constants import iswindows
|
|||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
class DeviceDefaults(object):
|
class DeviceDefaults:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.rules = (
|
self.rules = (
|
||||||
|
@ -535,7 +535,7 @@ class MTP_DEVICE(BASE):
|
|||||||
cw.commit()
|
cw.commit()
|
||||||
|
|
||||||
def settings(self):
|
def settings(self):
|
||||||
class Opts(object):
|
class Opts:
|
||||||
|
|
||||||
def __init__(s):
|
def __init__(s):
|
||||||
s.format_map = self.get_pref('format_map')
|
s.format_map = self.get_pref('format_map')
|
||||||
|
@ -20,7 +20,7 @@ from calibre.ebooks import BOOK_EXTENSIONS
|
|||||||
bexts = frozenset(BOOK_EXTENSIONS) - {'mbp', 'tan', 'rar', 'zip', 'xml'}
|
bexts = frozenset(BOOK_EXTENSIONS) - {'mbp', 'tan', 'rar', 'zip', 'xml'}
|
||||||
|
|
||||||
|
|
||||||
class FileOrFolder(object):
|
class FileOrFolder:
|
||||||
|
|
||||||
def __init__(self, entry, fs_cache):
|
def __init__(self, entry, fs_cache):
|
||||||
self.all_storage_ids = fs_cache.all_storage_ids
|
self.all_storage_ids = fs_cache.all_storage_ids
|
||||||
@ -181,7 +181,7 @@ class FileOrFolder(object):
|
|||||||
return 'mtp:::' + json.dumps(self.object_id) + ':::' + '/'.join(self.full_path)
|
return 'mtp:::' + json.dumps(self.object_id) + ':::' + '/'.join(self.full_path)
|
||||||
|
|
||||||
|
|
||||||
class FilesystemCache(object):
|
class FilesystemCache:
|
||||||
|
|
||||||
def __init__(self, all_storage, entries):
|
def __init__(self, all_storage, entries):
|
||||||
self.entries = []
|
self.entries = []
|
||||||
|
@ -15,7 +15,7 @@ from calibre.devices.scanner import DeviceScanner
|
|||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class ProgressCallback(object):
|
class ProgressCallback:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.count = 0
|
self.count = 0
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, glob
|
import os, glob
|
||||||
|
|
||||||
|
|
||||||
class MTPDetect(object):
|
class MTPDetect:
|
||||||
|
|
||||||
SYSFS_PATH = os.environ.get('SYSFS_PATH', '/sys')
|
SYSFS_PATH = os.environ.get('SYSFS_PATH', '/sys')
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from calibre.devices.usbms.books import CollectionsBookList, BookList
|
|||||||
DBPATH = 'paladin/database/books.db'
|
DBPATH = 'paladin/database/books.db'
|
||||||
|
|
||||||
|
|
||||||
class ImageWrapper(object):
|
class ImageWrapper:
|
||||||
|
|
||||||
def __init__(self, image_path):
|
def __init__(self, image_path):
|
||||||
self.image_path = image_path
|
self.image_path = image_path
|
||||||
|
@ -89,7 +89,7 @@ def uuid():
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class XMLCache(object):
|
class XMLCache:
|
||||||
|
|
||||||
def __init__(self, paths, ext_paths, prefixes, use_author_sort):
|
def __init__(self, paths, ext_paths, prefixes, use_author_sort):
|
||||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||||
|
@ -29,7 +29,7 @@ DBPATH = 'Sony_Reader/database/books.db'
|
|||||||
THUMBPATH = 'Sony_Reader/database/cache/books/%s/thumbnail/main_thumbnail.jpg'
|
THUMBPATH = 'Sony_Reader/database/cache/books/%s/thumbnail/main_thumbnail.jpg'
|
||||||
|
|
||||||
|
|
||||||
class ImageWrapper(object):
|
class ImageWrapper:
|
||||||
|
|
||||||
def __init__(self, image_path):
|
def __init__(self, image_path):
|
||||||
self.image_path = image_path
|
self.image_path = image_path
|
||||||
|
@ -56,7 +56,7 @@ class USBDevice(_USBDevice):
|
|||||||
__unicode__ = __repr__
|
__unicode__ = __repr__
|
||||||
|
|
||||||
|
|
||||||
class LibUSBScanner(object):
|
class LibUSBScanner:
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
if not hasattr(self, 'libusb'):
|
if not hasattr(self, 'libusb'):
|
||||||
@ -93,7 +93,7 @@ class LibUSBScanner(object):
|
|||||||
print('after', num, 'repeats')
|
print('after', num, 'repeats')
|
||||||
|
|
||||||
|
|
||||||
class LinuxScanner(object):
|
class LinuxScanner:
|
||||||
|
|
||||||
SYSFS_PATH = os.environ.get('SYSFS_PATH', '/sys')
|
SYSFS_PATH = os.environ.get('SYSFS_PATH', '/sys')
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ if isnetbsd:
|
|||||||
netbsd_scanner = None
|
netbsd_scanner = None
|
||||||
|
|
||||||
|
|
||||||
class DeviceScanner(object):
|
class DeviceScanner:
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
if iswindows:
|
if iswindows:
|
||||||
|
@ -12,7 +12,7 @@ from calibre.devices.errors import PathError
|
|||||||
from calibre.utils.filenames import case_preserving_open_file
|
from calibre.utils.filenames import case_preserving_open_file
|
||||||
|
|
||||||
|
|
||||||
class File(object):
|
class File:
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
stats = os.stat(path)
|
stats = os.stat(path)
|
||||||
@ -33,7 +33,7 @@ def check_transfer(infile, dest):
|
|||||||
return infile.read() == dest.read()
|
return infile.read() == dest.read()
|
||||||
|
|
||||||
|
|
||||||
class CLI(object):
|
class CLI:
|
||||||
|
|
||||||
def get_file(self, path, outfile, end_session=True):
|
def get_file(self, path, outfile, end_session=True):
|
||||||
path = self.munge_path(path)
|
path = self.munge_path(path)
|
||||||
|
@ -9,7 +9,7 @@ from calibre.utils.config_base import Config, ConfigProxy
|
|||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
|
|
||||||
class DeviceConfig(object):
|
class DeviceConfig:
|
||||||
|
|
||||||
HELP_MESSAGE = _('Configure Device')
|
HELP_MESSAGE = _('Configure Device')
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ def devid_pat():
|
|||||||
return _devid_pat
|
return _devid_pat
|
||||||
|
|
||||||
|
|
||||||
class DeviceSet(object):
|
class DeviceSet:
|
||||||
|
|
||||||
def __init__(self, guid=GUID_DEVINTERFACE_VOLUME, enumerator=None, flags=DIGCF_PRESENT | DIGCF_DEVICEINTERFACE):
|
def __init__(self, guid=GUID_DEVINTERFACE_VOLUME, enumerator=None, flags=DIGCF_PRESENT | DIGCF_DEVICEINTERFACE):
|
||||||
self.guid_ref, self.enumerator, self.flags = (None if guid is None else byref(guid)), enumerator, flags
|
self.guid_ref, self.enumerator, self.flags = (None if guid is None else byref(guid)), enumerator, flags
|
||||||
|
@ -26,7 +26,7 @@ def compile_pats(binary):
|
|||||||
yield re.compile(raw, flags=re.IGNORECASE)
|
yield re.compile(raw, flags=re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
class LazyEncodingPats(object):
|
class LazyEncodingPats:
|
||||||
|
|
||||||
def __call__(self, binary=False):
|
def __call__(self, binary=False):
|
||||||
attr = 'binary_pats' if binary else 'unicode_pats'
|
attr = 'binary_pats' if binary else 'unicode_pats'
|
||||||
|
@ -223,7 +223,7 @@ def render_pages(tasks, dest, opts, notification=lambda x, y: x):
|
|||||||
return pages, failures
|
return pages, failures
|
||||||
|
|
||||||
|
|
||||||
class Progress(object):
|
class Progress:
|
||||||
|
|
||||||
def __init__(self, total, update):
|
def __init__(self, total, update):
|
||||||
self.total = total
|
self.total = total
|
||||||
|
@ -9,7 +9,7 @@ import re
|
|||||||
from polyglot.builtins import int_to_byte, range
|
from polyglot.builtins import int_to_byte, range
|
||||||
|
|
||||||
|
|
||||||
class TCRCompressor(object):
|
class TCRCompressor:
|
||||||
'''
|
'''
|
||||||
TCR compression takes the form header+code_dict+coded_text.
|
TCR compression takes the form header+code_dict+coded_text.
|
||||||
The header is always "!!8-Bit!!". The code dict is a list of 256 strings.
|
The header is always "!!8-Bit!!". The code dict is a list of 256 strings.
|
||||||
|
@ -277,7 +277,7 @@ def option_parser():
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
class ProgressBar(object):
|
class ProgressBar:
|
||||||
|
|
||||||
def __init__(self, log):
|
def __init__(self, log):
|
||||||
self.log = log
|
self.log = log
|
||||||
|
@ -13,7 +13,7 @@ from calibre.customize.conversion import OptionRecommendation
|
|||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
|
|
||||||
class LRFOptions(object):
|
class LRFOptions:
|
||||||
|
|
||||||
def __init__(self, output, opts, oeb):
|
def __init__(self, output, opts, oeb):
|
||||||
def f2s(f):
|
def f2s(f):
|
||||||
|
@ -255,7 +255,7 @@ if __name__ == '__main__':
|
|||||||
from calibre.ebooks.conversion.preprocess import HTMLPreProcessor
|
from calibre.ebooks.conversion.preprocess import HTMLPreProcessor
|
||||||
from calibre.customize.profiles import HanlinV3Output
|
from calibre.customize.profiles import HanlinV3Output
|
||||||
|
|
||||||
class OptionValues(object):
|
class OptionValues:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
opts = OptionValues()
|
opts = OptionValues()
|
||||||
|
@ -51,11 +51,11 @@ def supported_input_formats():
|
|||||||
return fmts
|
return fmts
|
||||||
|
|
||||||
|
|
||||||
class OptionValues(object):
|
class OptionValues:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CompositeProgressReporter(object):
|
class CompositeProgressReporter:
|
||||||
|
|
||||||
def __init__(self, global_min, global_max, global_reporter):
|
def __init__(self, global_min, global_max, global_reporter):
|
||||||
self.global_min, self.global_max = global_min, global_max
|
self.global_min, self.global_max = global_min, global_max
|
||||||
@ -70,7 +70,7 @@ class CompositeProgressReporter(object):
|
|||||||
ARCHIVE_FMTS = ('zip', 'rar', 'oebzip')
|
ARCHIVE_FMTS = ('zip', 'rar', 'oebzip')
|
||||||
|
|
||||||
|
|
||||||
class Plumber(object):
|
class Plumber:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The `Plumber` manages the conversion pipeline. An UI should call the methods
|
The `Plumber` manages the conversion pipeline. An UI should call the methods
|
||||||
|
@ -86,7 +86,7 @@ def smarten_punctuation(html, log=None):
|
|||||||
return substitute_entites(html)
|
return substitute_entites(html)
|
||||||
|
|
||||||
|
|
||||||
class DocAnalysis(object):
|
class DocAnalysis:
|
||||||
'''
|
'''
|
||||||
Provides various text analysis functions to determine how the document is structured.
|
Provides various text analysis functions to determine how the document is structured.
|
||||||
format is the type of document analysis will be done against.
|
format is the type of document analysis will be done against.
|
||||||
@ -191,7 +191,7 @@ class DocAnalysis(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Dehyphenator(object):
|
class Dehyphenator:
|
||||||
'''
|
'''
|
||||||
Analyzes words to determine whether hyphens should be retained/removed. Uses the document
|
Analyzes words to determine whether hyphens should be retained/removed. Uses the document
|
||||||
itself is as a dictionary. This method handles all languages along with uncommon, made-up, and
|
itself is as a dictionary. This method handles all languages along with uncommon, made-up, and
|
||||||
@ -299,7 +299,7 @@ class Dehyphenator(object):
|
|||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
class CSSPreProcessor(object):
|
class CSSPreProcessor:
|
||||||
|
|
||||||
# Remove some of the broken CSS Microsoft products
|
# Remove some of the broken CSS Microsoft products
|
||||||
# create
|
# create
|
||||||
@ -455,7 +455,7 @@ def book_designer_rules():
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class HTMLPreProcessor(object):
|
class HTMLPreProcessor:
|
||||||
|
|
||||||
def __init__(self, log=None, extra_opts=None, regex_wizard_callback=None):
|
def __init__(self, log=None, extra_opts=None, regex_wizard_callback=None):
|
||||||
self.log = log
|
self.log = log
|
||||||
|
@ -14,7 +14,7 @@ from calibre.utils.wordcount import get_wordcount_obj
|
|||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
|
|
||||||
class HeuristicProcessor(object):
|
class HeuristicProcessor:
|
||||||
|
|
||||||
def __init__(self, extra_opts=None, log=None):
|
def __init__(self, extra_opts=None, log=None):
|
||||||
self.log = default_log if log is None else log
|
self.log = default_log if log is None else log
|
||||||
|
@ -126,7 +126,7 @@ def parse_text_formatting(text):
|
|||||||
return text, formats
|
return text, formats
|
||||||
|
|
||||||
|
|
||||||
class Block(object):
|
class Block:
|
||||||
|
|
||||||
def __init__(self, text='', width=0, font=None, img=None, max_height=100, align=Qt.AlignmentFlag.AlignCenter):
|
def __init__(self, text='', width=0, font=None, img=None, max_height=100, align=Qt.AlignmentFlag.AlignCenter):
|
||||||
self.layouts = []
|
self.layouts = []
|
||||||
@ -340,7 +340,7 @@ def color(color_theme, name):
|
|||||||
# Styles {{{
|
# Styles {{{
|
||||||
|
|
||||||
|
|
||||||
class Style(object):
|
class Style:
|
||||||
|
|
||||||
TITLE_ALIGN = SUBTITLE_ALIGN = FOOTER_ALIGN = Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop
|
TITLE_ALIGN = SUBTITLE_ALIGN = FOOTER_ALIGN = Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ def all_properties(decl):
|
|||||||
yield p
|
yield p
|
||||||
|
|
||||||
|
|
||||||
class StyleDeclaration(object):
|
class StyleDeclaration:
|
||||||
|
|
||||||
def __init__(self, css_declaration):
|
def __init__(self, css_declaration):
|
||||||
self.css_declaration = css_declaration
|
self.css_declaration = css_declaration
|
||||||
@ -164,7 +164,7 @@ def transform_number(val, op, raw):
|
|||||||
return unicode_type(v) + u
|
return unicode_type(v) + u
|
||||||
|
|
||||||
|
|
||||||
class Rule(object):
|
class Rule:
|
||||||
|
|
||||||
def __init__(self, property='color', match_type='*', query='', action='remove', action_data=''):
|
def __init__(self, property='color', match_type='*', query='', action='remove', action_data=''):
|
||||||
self.property_name = property.lower()
|
self.property_name = property.lower()
|
||||||
|
@ -16,7 +16,7 @@ import struct
|
|||||||
from calibre.ebooks.djvu.djvubzzdec import BZZDecoder
|
from calibre.ebooks.djvu.djvubzzdec import BZZDecoder
|
||||||
|
|
||||||
|
|
||||||
class DjvuChunk(object):
|
class DjvuChunk:
|
||||||
|
|
||||||
def __init__(self, buf, start, end, align=True, bigendian=True,
|
def __init__(self, buf, start, end, align=True, bigendian=True,
|
||||||
inclheader=False, verbose=0):
|
inclheader=False, verbose=0):
|
||||||
@ -105,7 +105,7 @@ class DjvuChunk(object):
|
|||||||
schunk.dump(verbose=verbose, indent=indent+1, out=out, txtout=txtout)
|
schunk.dump(verbose=verbose, indent=indent+1, out=out, txtout=txtout)
|
||||||
|
|
||||||
|
|
||||||
class DJVUFile(object):
|
class DJVUFile:
|
||||||
|
|
||||||
def __init__(self, instream, verbose=0):
|
def __init__(self, instream, verbose=0):
|
||||||
self.instream = instream
|
self.instream = instream
|
||||||
|
@ -10,7 +10,7 @@ from collections import OrderedDict
|
|||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
class Inherit(object):
|
class Inherit:
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return other is self
|
return other is self
|
||||||
@ -250,7 +250,7 @@ def read_numbering(parent, dest, XPath, get):
|
|||||||
setattr(dest, 'numbering_level', lvl)
|
setattr(dest, 'numbering_level', lvl)
|
||||||
|
|
||||||
|
|
||||||
class Frame(object):
|
class Frame:
|
||||||
|
|
||||||
all_attributes = ('drop_cap', 'h', 'w', 'h_anchor', 'h_rule', 'v_anchor', 'wrap',
|
all_attributes = ('drop_cap', 'h', 'w', 'h_anchor', 'h_rule', 'v_anchor', 'wrap',
|
||||||
'h_space', 'v_space', 'lines', 'x_align', 'y_align', 'x', 'y')
|
'h_space', 'v_space', 'lines', 'x_align', 'y_align', 'x', 'y')
|
||||||
@ -337,7 +337,7 @@ def read_frame(parent, dest, XPath, get):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class ParagraphStyle(object):
|
class ParagraphStyle:
|
||||||
|
|
||||||
all_properties = (
|
all_properties = (
|
||||||
'adjustRightInd', 'autoSpaceDE', 'autoSpaceDN', 'bidi',
|
'adjustRightInd', 'autoSpaceDE', 'autoSpaceDN', 'bidi',
|
||||||
|
@ -174,7 +174,7 @@ def read_font_cs(parent, dest, XPath, get):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class RunStyle(object):
|
class RunStyle:
|
||||||
|
|
||||||
all_properties = {
|
all_properties = {
|
||||||
'b', 'bCs', 'caps', 'cs', 'dstrike', 'emboss', 'i', 'iCs', 'imprint',
|
'b', 'bCs', 'caps', 'cs', 'dstrike', 'emboss', 'i', 'iCs', 'imprint',
|
||||||
|
@ -86,7 +86,7 @@ def read_default_style_language(raw, mi, XPath):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class DOCX(object):
|
class DOCX:
|
||||||
|
|
||||||
def __init__(self, path_or_stream, log=None, extract=True):
|
def __init__(self, path_or_stream, log=None, extract=True):
|
||||||
self.docx_is_transitional = True
|
self.docx_is_transitional = True
|
||||||
|
@ -11,7 +11,7 @@ from calibre.ebooks.docx.index import process_index, polish_index_markup
|
|||||||
from polyglot.builtins import iteritems, native_string_type
|
from polyglot.builtins import iteritems, native_string_type
|
||||||
|
|
||||||
|
|
||||||
class Field(object):
|
class Field:
|
||||||
|
|
||||||
def __init__(self, start):
|
def __init__(self, start):
|
||||||
self.start = start
|
self.start = start
|
||||||
@ -98,7 +98,7 @@ parse_noteref = parser('noteref',
|
|||||||
'f:footnote h:hyperlink p:position')
|
'f:footnote h:hyperlink p:position')
|
||||||
|
|
||||||
|
|
||||||
class Fields(object):
|
class Fields:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -51,7 +51,7 @@ def get_best_font(fonts, style, stretch):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Family(object):
|
class Family:
|
||||||
|
|
||||||
def __init__(self, elem, embed_relationships, XPath, get):
|
def __init__(self, elem, embed_relationships, XPath, get):
|
||||||
self.name = self.family_name = get(elem, 'w:name')
|
self.name = self.family_name = get(elem, 'w:name')
|
||||||
@ -134,7 +134,7 @@ def map_symbol_text(text, font):
|
|||||||
return ''.join(do_map(m, ord_string(text)))
|
return ''.join(do_map(m, ord_string(text)))
|
||||||
|
|
||||||
|
|
||||||
class Fonts(object):
|
class Fonts:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -9,7 +9,7 @@ from collections import OrderedDict
|
|||||||
from polyglot.builtins import iteritems, unicode_type
|
from polyglot.builtins import iteritems, unicode_type
|
||||||
|
|
||||||
|
|
||||||
class Note(object):
|
class Note:
|
||||||
|
|
||||||
def __init__(self, namespace, parent, rels):
|
def __init__(self, namespace, parent, rels):
|
||||||
self.type = namespace.get(parent, 'w:type', 'normal')
|
self.type = namespace.get(parent, 'w:type', 'normal')
|
||||||
@ -22,7 +22,7 @@ class Note(object):
|
|||||||
yield p
|
yield p
|
||||||
|
|
||||||
|
|
||||||
class Footnotes(object):
|
class Footnotes:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -129,7 +129,7 @@ def get_hpos(anchor, page_width, XPath, get, width_frac):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
class Images(object):
|
class Images:
|
||||||
|
|
||||||
def __init__(self, namespace, log):
|
def __init__(self, namespace, log):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -94,7 +94,7 @@ def generate_anchor(name, existing):
|
|||||||
return y
|
return y
|
||||||
|
|
||||||
|
|
||||||
class DOCXNamespace(object):
|
class DOCXNamespace:
|
||||||
|
|
||||||
def __init__(self, transitional=True):
|
def __init__(self, transitional=True):
|
||||||
self.xpath_cache = {}
|
self.xpath_cache = {}
|
||||||
|
@ -44,7 +44,7 @@ alphabet_map = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Level(object):
|
class Level:
|
||||||
|
|
||||||
def __init__(self, namespace, lvl=None):
|
def __init__(self, namespace, lvl=None):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
@ -152,7 +152,7 @@ class Level(object):
|
|||||||
return css
|
return css
|
||||||
|
|
||||||
|
|
||||||
class NumberingDefinition(object):
|
class NumberingDefinition:
|
||||||
|
|
||||||
def __init__(self, namespace, parent=None, an_id=None):
|
def __init__(self, namespace, parent=None, an_id=None):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
@ -174,7 +174,7 @@ class NumberingDefinition(object):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class Numbering(object):
|
class Numbering:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
|
|
||||||
class Settings(object):
|
class Settings:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.default_tab_stop = 720 / 20
|
self.default_tab_stop = 720 / 20
|
||||||
|
@ -14,7 +14,7 @@ from calibre.ebooks.docx.tables import TableStyle
|
|||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems, itervalues
|
||||||
|
|
||||||
|
|
||||||
class PageProperties(object):
|
class PageProperties:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Class representing page level properties (page size/margins) read from
|
Class representing page level properties (page size/margins) read from
|
||||||
@ -39,7 +39,7 @@ class PageProperties(object):
|
|||||||
setval('margin_left', l), setval('margin_right', r)
|
setval('margin_left', l), setval('margin_right', r)
|
||||||
|
|
||||||
|
|
||||||
class Style(object):
|
class Style:
|
||||||
'''
|
'''
|
||||||
Class representing a <w:style> element. Can contain block, character, etc. styles.
|
Class representing a <w:style> element. Can contain block, character, etc. styles.
|
||||||
'''
|
'''
|
||||||
@ -104,7 +104,7 @@ class Style(object):
|
|||||||
self.character_style.resolve_based_on(parent.character_style)
|
self.character_style.resolve_based_on(parent.character_style)
|
||||||
|
|
||||||
|
|
||||||
class Styles(object):
|
class Styles:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Collection of all styles defined in the document. Used to get the final styles applicable to elements in the document markup.
|
Collection of all styles defined in the document. Used to get the final styles applicable to elements in the document markup.
|
||||||
|
@ -174,7 +174,7 @@ def clone(style):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class Style(object):
|
class Style:
|
||||||
|
|
||||||
is_bidi = False
|
is_bidi = False
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ class TableStyle(Style):
|
|||||||
return self._css
|
return self._css
|
||||||
|
|
||||||
|
|
||||||
class Table(object):
|
class Table:
|
||||||
|
|
||||||
def __init__(self, namespace, tbl, styles, para_map, is_sub_table=False):
|
def __init__(self, namespace, tbl, styles, para_map, is_sub_table=False):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
@ -670,7 +670,7 @@ class Table(object):
|
|||||||
elem.set('class', self.styles.register(css, elem.tag))
|
elem.set('class', self.styles.register(css, elem.tag))
|
||||||
|
|
||||||
|
|
||||||
class Tables(object):
|
class Tables:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.tables = []
|
self.tables = []
|
||||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
|
|
||||||
class Theme(object):
|
class Theme:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.major_latin_font = 'Cambria'
|
self.major_latin_font = 'Cambria'
|
||||||
|
@ -57,7 +57,7 @@ def html_lang(docx_lang):
|
|||||||
return lang
|
return lang
|
||||||
|
|
||||||
|
|
||||||
class Convert(object):
|
class Convert:
|
||||||
|
|
||||||
def __init__(self, path_or_stream, dest_dir=None, log=None, detect_cover=True, notes_text=None, notes_nopb=False, nosupsub=False):
|
def __init__(self, path_or_stream, dest_dir=None, log=None, detect_cover=True, notes_text=None, notes_nopb=False, nosupsub=False):
|
||||||
self.docx = DOCX(path_or_stream, log=log)
|
self.docx = DOCX(path_or_stream, log=log)
|
||||||
|
@ -115,7 +115,7 @@ def update_doc_props(root, mi, namespace):
|
|||||||
setm('language', lang_as_iso639_1(l) or l)
|
setm('language', lang_as_iso639_1(l) or l)
|
||||||
|
|
||||||
|
|
||||||
class DocumentRelationships(object):
|
class DocumentRelationships:
|
||||||
|
|
||||||
def __init__(self, namespace):
|
def __init__(self, namespace):
|
||||||
self.rmap = {}
|
self.rmap = {}
|
||||||
@ -153,7 +153,7 @@ class DocumentRelationships(object):
|
|||||||
return xml2str(relationships)
|
return xml2str(relationships)
|
||||||
|
|
||||||
|
|
||||||
class DOCX(object):
|
class DOCX:
|
||||||
|
|
||||||
def __init__(self, opts, log):
|
def __init__(self, opts, log):
|
||||||
self.namespace = DOCXNamespace()
|
self.namespace = DOCXNamespace()
|
||||||
|
@ -20,7 +20,7 @@ def obfuscate_font_data(data, key):
|
|||||||
return prefix + data[32:]
|
return prefix + data[32:]
|
||||||
|
|
||||||
|
|
||||||
class FontsManager(object):
|
class FontsManager:
|
||||||
|
|
||||||
def __init__(self, namespace, oeb, opts):
|
def __init__(self, namespace, oeb, opts):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -54,7 +54,7 @@ class Stylizer(Sz):
|
|||||||
return Style(element, self)
|
return Style(element, self)
|
||||||
|
|
||||||
|
|
||||||
class TextRun(object):
|
class TextRun:
|
||||||
|
|
||||||
ws_pat = soft_hyphen_pat = None
|
ws_pat = soft_hyphen_pat = None
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ class TextRun(object):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class Block(object):
|
class Block:
|
||||||
|
|
||||||
def __init__(self, namespace, styles_manager, links_manager, html_block, style, is_table_cell=False, float_spec=None, is_list_item=False, parent_bg=None):
|
def __init__(self, namespace, styles_manager, links_manager, html_block, style, is_table_cell=False, float_spec=None, is_list_item=False, parent_bg=None):
|
||||||
self.force_not_empty = False
|
self.force_not_empty = False
|
||||||
@ -262,7 +262,7 @@ class Block(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Blocks(object):
|
class Blocks:
|
||||||
|
|
||||||
def __init__(self, namespace, styles_manager, links_manager):
|
def __init__(self, namespace, styles_manager, links_manager):
|
||||||
self.top_bookmark = None
|
self.top_bookmark = None
|
||||||
@ -417,7 +417,7 @@ class Blocks(object):
|
|||||||
return 'Block(%r)' % self.runs
|
return 'Block(%r)' % self.runs
|
||||||
|
|
||||||
|
|
||||||
class Convert(object):
|
class Convert:
|
||||||
|
|
||||||
# Word does not apply default styling to hyperlinks, so we ensure they get
|
# Word does not apply default styling to hyperlinks, so we ensure they get
|
||||||
# default styling (the conversion pipeline does not apply any styling to
|
# default styling (the conversion pipeline does not apply any styling to
|
||||||
|
@ -38,7 +38,7 @@ def get_image_margins(style):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class ImagesManager(object):
|
class ImagesManager:
|
||||||
|
|
||||||
def __init__(self, oeb, document_relationships, opts):
|
def __init__(self, oeb, document_relationships, opts):
|
||||||
self.oeb, self.log = oeb, oeb.log
|
self.oeb, self.log = oeb, oeb.log
|
||||||
|
@ -27,7 +27,7 @@ def start_text(tag, prefix_len=0, top_level=True):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class TOCItem(object):
|
class TOCItem:
|
||||||
|
|
||||||
def __init__(self, title, bmark, level):
|
def __init__(self, title, bmark, level):
|
||||||
self.title, self.bmark, self.level = title, bmark, level
|
self.title, self.bmark, self.level = title, bmark, level
|
||||||
@ -65,7 +65,7 @@ def sanitize_bookmark_name(base):
|
|||||||
return re.sub(r'[^0-9a-zA-Z]', '_', ascii_text(base))[:32].rstrip('_')
|
return re.sub(r'[^0-9a-zA-Z]', '_', ascii_text(base))[:32].rstrip('_')
|
||||||
|
|
||||||
|
|
||||||
class LinksManager(object):
|
class LinksManager:
|
||||||
|
|
||||||
def __init__(self, namespace, document_relationships, log):
|
def __init__(self, namespace, document_relationships, log):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -50,7 +50,7 @@ def find_list_containers(list_tag, tag_style):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class NumberingDefinition(object):
|
class NumberingDefinition:
|
||||||
|
|
||||||
def __init__(self, top_most, stylizer, namespace):
|
def __init__(self, top_most, stylizer, namespace):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
@ -90,7 +90,7 @@ class NumberingDefinition(object):
|
|||||||
level.serialize(an, makeelement)
|
level.serialize(an, makeelement)
|
||||||
|
|
||||||
|
|
||||||
class Level(object):
|
class Level:
|
||||||
|
|
||||||
def __init__(self, list_type, container, items, ilvl=0):
|
def __init__(self, list_type, container, items, ilvl=0):
|
||||||
self.ilvl = ilvl
|
self.ilvl = ilvl
|
||||||
@ -125,7 +125,7 @@ class Level(object):
|
|||||||
makeelement(makeelement(lvl, 'w:rPr'), 'w:rFonts', w_ascii=ff, w_hAnsi=ff, w_hint="default")
|
makeelement(makeelement(lvl, 'w:rPr'), 'w:rFonts', w_ascii=ff, w_hAnsi=ff, w_hint="default")
|
||||||
|
|
||||||
|
|
||||||
class ListsManager(object):
|
class ListsManager:
|
||||||
|
|
||||||
def __init__(self, docx):
|
def __init__(self, docx):
|
||||||
self.namespace = docx.namespace
|
self.namespace = docx.namespace
|
||||||
|
@ -49,7 +49,7 @@ def is_dropcaps(html_tag, tag_style):
|
|||||||
return len(html_tag) < 2 and len(etree.tostring(html_tag, method='text', encoding='unicode', with_tail=False)) < 5 and tag_style['float'] == 'left'
|
return len(html_tag) < 2 and len(etree.tostring(html_tag, method='text', encoding='unicode', with_tail=False)) < 5 and tag_style['float'] == 'left'
|
||||||
|
|
||||||
|
|
||||||
class CombinedStyle(object):
|
class CombinedStyle:
|
||||||
|
|
||||||
def __init__(self, bs, rs, blocks, namespace):
|
def __init__(self, bs, rs, blocks, namespace):
|
||||||
self.bs, self.rs, self.blocks = bs, rs, blocks
|
self.bs, self.rs, self.blocks = bs, rs, blocks
|
||||||
@ -81,7 +81,7 @@ class CombinedStyle(object):
|
|||||||
self.rs.serialize_properties(rPr, normal_style.rs)
|
self.rs.serialize_properties(rPr, normal_style.rs)
|
||||||
|
|
||||||
|
|
||||||
class FloatSpec(object):
|
class FloatSpec:
|
||||||
|
|
||||||
def __init__(self, namespace, html_tag, tag_style):
|
def __init__(self, namespace, html_tag, tag_style):
|
||||||
self.makeelement = namespace.makeelement
|
self.makeelement = namespace.makeelement
|
||||||
@ -141,7 +141,7 @@ class FloatSpec(object):
|
|||||||
bdr, 'w:'+edge, w_space=unicode_type(padding), w_val=bstyle, w_sz=unicode_type(width), w_color=getattr(self, 'border_%s_color' % edge))
|
bdr, 'w:'+edge, w_space=unicode_type(padding), w_val=bstyle, w_sz=unicode_type(width), w_color=getattr(self, 'border_%s_color' % edge))
|
||||||
|
|
||||||
|
|
||||||
class DOCXStyle(object):
|
class DOCXStyle:
|
||||||
|
|
||||||
ALL_PROPS = ()
|
ALL_PROPS = ()
|
||||||
TYPE = 'paragraph'
|
TYPE = 'paragraph'
|
||||||
@ -356,7 +356,7 @@ class TextStyle(DOCXStyle):
|
|||||||
rPr.append(bdr)
|
rPr.append(bdr)
|
||||||
|
|
||||||
|
|
||||||
class DescendantTextStyle(object):
|
class DescendantTextStyle:
|
||||||
|
|
||||||
def __init__(self, parent_style, child_style):
|
def __init__(self, parent_style, child_style):
|
||||||
self.id = self.name = None
|
self.id = self.name = None
|
||||||
@ -632,7 +632,7 @@ class BlockStyle(DOCXStyle):
|
|||||||
pPr.append(makeelement(pPr, 'next', val=self.next_style))
|
pPr.append(makeelement(pPr, 'next', val=self.next_style))
|
||||||
|
|
||||||
|
|
||||||
class StylesManager(object):
|
class StylesManager:
|
||||||
|
|
||||||
def __init__(self, namespace, log, document_lang):
|
def __init__(self, namespace, log, document_lang):
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
|
@ -12,7 +12,7 @@ from calibre.ebooks.docx.writer.styles import read_css_block_borders as rcbb, bo
|
|||||||
from polyglot.builtins import iteritems, range, unicode_type
|
from polyglot.builtins import iteritems, range, unicode_type
|
||||||
|
|
||||||
|
|
||||||
class Dummy(object):
|
class Dummy:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ border_style_weight = {
|
|||||||
x:100-i for i, x in enumerate(('double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove', 'inset'))}
|
x:100-i for i, x in enumerate(('double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove', 'inset'))}
|
||||||
|
|
||||||
|
|
||||||
class SpannedCell(object):
|
class SpannedCell:
|
||||||
|
|
||||||
def __init__(self, spanning_cell, horizontal=True):
|
def __init__(self, spanning_cell, horizontal=True):
|
||||||
self.spanning_cell = spanning_cell
|
self.spanning_cell = spanning_cell
|
||||||
@ -79,7 +79,7 @@ def convert_width(tag_style):
|
|||||||
return ('auto', 0)
|
return ('auto', 0)
|
||||||
|
|
||||||
|
|
||||||
class Cell(object):
|
class Cell:
|
||||||
|
|
||||||
BLEVEL = 2
|
BLEVEL = 2
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ class Cell(object):
|
|||||||
return getattr(ans, 'spanning_cell', ans)
|
return getattr(ans, 'spanning_cell', ans)
|
||||||
|
|
||||||
|
|
||||||
class Row(object):
|
class Row:
|
||||||
|
|
||||||
BLEVEL = 1
|
BLEVEL = 1
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ class Row(object):
|
|||||||
cell.serialize(tr, makeelement)
|
cell.serialize(tr, makeelement)
|
||||||
|
|
||||||
|
|
||||||
class Table(object):
|
class Table:
|
||||||
|
|
||||||
BLEVEL = 0
|
BLEVEL = 0
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import regex
|
|||||||
from polyglot.builtins import map, zip
|
from polyglot.builtins import map, zip
|
||||||
|
|
||||||
|
|
||||||
class Parser(object):
|
class Parser:
|
||||||
|
|
||||||
''' See epubcfi.ebnf for the specification that this parser tries to
|
''' See epubcfi.ebnf for the specification that this parser tries to
|
||||||
follow. I have implemented it manually, since I dont want to depend on
|
follow. I have implemented it manually, since I dont want to depend on
|
||||||
|
@ -25,7 +25,7 @@ from polyglot.binary import as_base64_unicode
|
|||||||
from polyglot.urllib import urlparse
|
from polyglot.urllib import urlparse
|
||||||
|
|
||||||
|
|
||||||
class FB2MLizer(object):
|
class FB2MLizer:
|
||||||
'''
|
'''
|
||||||
Todo: * Include more FB2 specific tags in the conversion.
|
Todo: * Include more FB2 specific tags in the conversion.
|
||||||
* Handle notes and anchor links.
|
* Handle notes and anchor links.
|
||||||
|
@ -21,7 +21,7 @@ from polyglot.builtins import unicode_type
|
|||||||
from polyglot.urllib import urlparse, urlunparse
|
from polyglot.urllib import urlparse, urlunparse
|
||||||
|
|
||||||
|
|
||||||
class Link(object):
|
class Link:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Represents a link in a HTML file.
|
Represents a link in a HTML file.
|
||||||
@ -76,7 +76,7 @@ class IgnoreFile(Exception):
|
|||||||
self.errno = errno
|
self.errno = errno
|
||||||
|
|
||||||
|
|
||||||
class HTMLFile(object):
|
class HTMLFile:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Contains basic information about an HTML file. This
|
Contains basic information about an HTML file. This
|
||||||
|
@ -5,7 +5,7 @@ __copyright__ = '2010, Fabian Grassl <fg@jusmeum.de>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
class EasyMeta(object):
|
class EasyMeta:
|
||||||
|
|
||||||
def __init__(self, meta):
|
def __init__(self, meta):
|
||||||
self.meta = meta
|
self.meta = meta
|
||||||
|
@ -26,7 +26,7 @@ from polyglot.urllib import urldefrag
|
|||||||
SELF_CLOSING_TAGS = {'area', 'base', 'basefont', 'br', 'hr', 'input', 'img', 'link', 'meta'}
|
SELF_CLOSING_TAGS = {'area', 'base', 'basefont', 'br', 'hr', 'input', 'img', 'link', 'meta'}
|
||||||
|
|
||||||
|
|
||||||
class OEB2HTML(object):
|
class OEB2HTML:
|
||||||
'''
|
'''
|
||||||
Base class. All subclasses should implement dump_text to actually transform
|
Base class. All subclasses should implement dump_text to actually transform
|
||||||
content. Also, callers should use oeb2html to get the transformed html.
|
content. Also, callers should use oeb2html to get the transformed html.
|
||||||
|
@ -15,7 +15,7 @@ LZXError = _lzx.LZXError
|
|||||||
Compressor = _lzx.Compressor
|
Compressor = _lzx.Compressor
|
||||||
|
|
||||||
|
|
||||||
class Decompressor(object):
|
class Decompressor:
|
||||||
|
|
||||||
def __init__(self, wbits):
|
def __init__(self, wbits):
|
||||||
self.wbits = wbits
|
self.wbits = wbits
|
||||||
|
@ -121,7 +121,7 @@ K = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class mssha1(object):
|
class mssha1:
|
||||||
"An implementation of the MD5 hash function in pure Python."
|
"An implementation of the MD5 hash function in pure Python."
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -124,7 +124,7 @@ def encode(string):
|
|||||||
return unicode_type(string).encode('ascii', 'xmlcharrefreplace')
|
return unicode_type(string).encode('ascii', 'xmlcharrefreplace')
|
||||||
|
|
||||||
|
|
||||||
class UnBinary(object):
|
class UnBinary:
|
||||||
AMPERSAND_RE = re.compile(
|
AMPERSAND_RE = re.compile(
|
||||||
br'&(?!(?:#[0-9]+|#x[0-9a-fA-F]+|[a-zA-Z_:][a-zA-Z0-9.-_:]+);)')
|
br'&(?!(?:#[0-9]+|#x[0-9a-fA-F]+|[a-zA-Z_:][a-zA-Z0-9.-_:]+);)')
|
||||||
OPEN_ANGLE_RE = re.compile(br'<<(?![!]--)')
|
OPEN_ANGLE_RE = re.compile(br'<<(?![!]--)')
|
||||||
@ -384,7 +384,7 @@ class UnBinary(object):
|
|||||||
state = 'get attr'
|
state = 'get attr'
|
||||||
|
|
||||||
|
|
||||||
class DirectoryEntry(object):
|
class DirectoryEntry:
|
||||||
|
|
||||||
def __init__(self, name, section, offset, size):
|
def __init__(self, name, section, offset, size):
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -400,7 +400,7 @@ class DirectoryEntry(object):
|
|||||||
return repr(self)
|
return repr(self)
|
||||||
|
|
||||||
|
|
||||||
class ManifestItem(object):
|
class ManifestItem:
|
||||||
|
|
||||||
def __init__(self, original, internal, mime_type, offset, root, state):
|
def __init__(self, original, internal, mime_type, offset, root, state):
|
||||||
self.original = original
|
self.original = original
|
||||||
@ -442,7 +442,7 @@ def preserve(function):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class LitFile(object):
|
class LitFile:
|
||||||
PIECE_SIZE = 16
|
PIECE_SIZE = 16
|
||||||
|
|
||||||
def __init__(self, filename_or_stream, log):
|
def __init__(self, filename_or_stream, log):
|
||||||
@ -889,7 +889,7 @@ class LitFile(object):
|
|||||||
return (tags, attrs)
|
return (tags, attrs)
|
||||||
|
|
||||||
|
|
||||||
class LitContainer(object):
|
class LitContainer:
|
||||||
"""Simple Container-interface, read-only accessor for LIT files."""
|
"""Simple Container-interface, read-only accessor for LIT files."""
|
||||||
|
|
||||||
def __init__(self, filename_or_stream, log):
|
def __init__(self, filename_or_stream, log):
|
||||||
|
@ -140,7 +140,7 @@ def warn(x):
|
|||||||
print(x)
|
print(x)
|
||||||
|
|
||||||
|
|
||||||
class ReBinary(object):
|
class ReBinary:
|
||||||
NSRMAP = {'': None, XML_NS: 'xml'}
|
NSRMAP = {'': None, XML_NS: 'xml'}
|
||||||
|
|
||||||
def __init__(self, root, item, oeb, opts, map=HTML_MAP):
|
def __init__(self, root, item, oeb, opts, map=HTML_MAP):
|
||||||
@ -304,7 +304,7 @@ def preserve(function):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class LitWriter(object):
|
class LitWriter:
|
||||||
|
|
||||||
def __init__(self, opts):
|
def __init__(self, opts):
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
|
@ -20,7 +20,7 @@ class LRFParseError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PRS500_PROFILE(object):
|
class PRS500_PROFILE:
|
||||||
screen_width = 600
|
screen_width = 600
|
||||||
screen_height = 775
|
screen_height = 775
|
||||||
dpi = 166
|
dpi = 166
|
||||||
|
@ -86,7 +86,7 @@ def tag_regex(tagname):
|
|||||||
close=r'</\s*%(t)s\s*>'%dict(t=tagname))
|
close=r'</\s*%(t)s\s*>'%dict(t=tagname))
|
||||||
|
|
||||||
|
|
||||||
class HTMLConverter(object):
|
class HTMLConverter:
|
||||||
SELECTOR_PAT = re.compile(r"([A-Za-z0-9\-\_\:\.]+[A-Za-z0-9\-\_\:\.\s\,]*)\s*\{([^\}]*)\}")
|
SELECTOR_PAT = re.compile(r"([A-Za-z0-9\-\_\:\.]+[A-Za-z0-9\-\_\:\.\s\,]*)\s*\{([^\}]*)\}")
|
||||||
PAGE_BREAK_PAT = re.compile(r'page-break-(?:after|before)\s*:\s*(\w+)', re.IGNORECASE)
|
PAGE_BREAK_PAT = re.compile(r'page-break-(?:after|before)\s*:\s*(\w+)', re.IGNORECASE)
|
||||||
IGNORED_TAGS = (Comment, Declaration, ProcessingInstruction)
|
IGNORED_TAGS = (Comment, Declaration, ProcessingInstruction)
|
||||||
|
@ -69,7 +69,7 @@ def tokens(tb):
|
|||||||
yield k
|
yield k
|
||||||
|
|
||||||
|
|
||||||
class Cell(object):
|
class Cell:
|
||||||
|
|
||||||
def __init__(self, conv, tag, css):
|
def __init__(self, conv, tag, css):
|
||||||
self.conv = conv
|
self.conv = conv
|
||||||
@ -210,7 +210,7 @@ class Cell(object):
|
|||||||
return sum([self.text_block_size(i, width)[1] for i in self.text_blocks])
|
return sum([self.text_block_size(i, width)[1] for i in self.text_blocks])
|
||||||
|
|
||||||
|
|
||||||
class Row(object):
|
class Row:
|
||||||
|
|
||||||
def __init__(self, conv, row, css, colpad):
|
def __init__(self, conv, row, css, colpad):
|
||||||
self.cells = []
|
self.cells = []
|
||||||
@ -277,7 +277,7 @@ class Row(object):
|
|||||||
yield c
|
yield c
|
||||||
|
|
||||||
|
|
||||||
class Table(object):
|
class Table:
|
||||||
|
|
||||||
def __init__(self, conv, table, css, rowpad=10, colpad=10):
|
def __init__(self, conv, table, css, rowpad=10, colpad=10):
|
||||||
self.rows = []
|
self.rows = []
|
||||||
|
@ -18,7 +18,7 @@ from polyglot.builtins import unicode_type, itervalues
|
|||||||
|
|
||||||
class LRFDocument(LRFMetaFile):
|
class LRFDocument(LRFMetaFile):
|
||||||
|
|
||||||
class temp(object):
|
class temp:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
|
@ -25,7 +25,7 @@ from calibre.utils.config import OptionParser
|
|||||||
from polyglot.builtins import string_or_bytes, unicode_type
|
from polyglot.builtins import string_or_bytes, unicode_type
|
||||||
|
|
||||||
|
|
||||||
class LrsParser(object):
|
class LrsParser:
|
||||||
|
|
||||||
def __init__(self, stream, logger):
|
def __init__(self, stream, logger):
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
@ -29,7 +29,7 @@ DWORD = "<I" #: Unsigned integer little endian encoded in 4 bytes
|
|||||||
QWORD = "<Q" #: Unsigned long long little endian encoded in 8 bytes
|
QWORD = "<Q" #: Unsigned long long little endian encoded in 8 bytes
|
||||||
|
|
||||||
|
|
||||||
class field(object):
|
class field:
|
||||||
""" A U{Descriptor<http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html>}, that implements access
|
""" A U{Descriptor<http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html>}, that implements access
|
||||||
to protocol packets in a human readable way.
|
to protocol packets in a human readable way.
|
||||||
"""
|
"""
|
||||||
@ -81,7 +81,7 @@ class LRFException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class fixed_stringfield(object):
|
class fixed_stringfield:
|
||||||
""" A field storing a variable length string. """
|
""" A field storing a variable length string. """
|
||||||
|
|
||||||
def __init__(self, length=8, start=0):
|
def __init__(self, length=8, start=0):
|
||||||
@ -111,7 +111,7 @@ class fixed_stringfield(object):
|
|||||||
" starting at byte " + unicode_type(self._start)
|
" starting at byte " + unicode_type(self._start)
|
||||||
|
|
||||||
|
|
||||||
class xml_attr_field(object):
|
class xml_attr_field:
|
||||||
|
|
||||||
def __init__(self, tag_name, attr, parent='BookInfo'):
|
def __init__(self, tag_name, attr, parent='BookInfo'):
|
||||||
self.tag_name = tag_name
|
self.tag_name = tag_name
|
||||||
@ -152,7 +152,7 @@ class xml_attr_field(object):
|
|||||||
return self.tag_name+'.'+self.attr
|
return self.tag_name+'.'+self.attr
|
||||||
|
|
||||||
|
|
||||||
class xml_field(object):
|
class xml_field:
|
||||||
"""
|
"""
|
||||||
Descriptor that gets and sets XML based meta information from an LRF file.
|
Descriptor that gets and sets XML based meta information from an LRF file.
|
||||||
Works for simple XML fields of the form <tagname>data</tagname>
|
Works for simple XML fields of the form <tagname>data</tagname>
|
||||||
@ -299,7 +299,7 @@ def get_metadata(stream):
|
|||||||
return mi
|
return mi
|
||||||
|
|
||||||
|
|
||||||
class LRFMetaFile(object):
|
class LRFMetaFile:
|
||||||
""" Has properties to read and write all Meta information in a LRF file. """
|
""" Has properties to read and write all Meta information in a LRF file. """
|
||||||
#: The first 6 bytes of all valid LRF files
|
#: The first 6 bytes of all valid LRF files
|
||||||
LRF_HEADER = 'LRF'.encode('utf-16le')
|
LRF_HEADER = 'LRF'.encode('utf-16le')
|
||||||
|
@ -19,7 +19,7 @@ ruby_tags = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class LRFObject(object):
|
class LRFObject:
|
||||||
|
|
||||||
tag_map = {
|
tag_map = {
|
||||||
0xF500: ['', ''],
|
0xF500: ['', ''],
|
||||||
@ -192,7 +192,7 @@ class PageTree(LRFObject):
|
|||||||
yield self._document.objects[id]
|
yield self._document.objects[id]
|
||||||
|
|
||||||
|
|
||||||
class StyleObject(object):
|
class StyleObject:
|
||||||
|
|
||||||
def _tags_to_xml(self):
|
def _tags_to_xml(self):
|
||||||
s = ''
|
s = ''
|
||||||
@ -245,7 +245,7 @@ class PageAttr(StyleObject, LRFObject):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class Color(object):
|
class Color:
|
||||||
|
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.a, self.r, self.g, self.b = val & 0xFF, (val>>8)&0xFF, (val>>16)&0xFF, (val>>24)&0xFF
|
self.a, self.r, self.g, self.b = val & 0xFF, (val>>8)&0xFF, (val>>16)&0xFF, (val>>24)&0xFF
|
||||||
@ -263,7 +263,7 @@ class Color(object):
|
|||||||
return 'rgb(%d, %d, %d)'%(self.r, self.g, self.b)
|
return 'rgb(%d, %d, %d)'%(self.r, self.g, self.b)
|
||||||
|
|
||||||
|
|
||||||
class EmptyPageElement(object):
|
class EmptyPageElement:
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for i in range(0):
|
for i in range(0):
|
||||||
@ -486,7 +486,7 @@ class BlockAttr(StyleObject, LRFObject):
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class TextCSS(object):
|
class TextCSS:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def to_css(cls, obj, inline=False):
|
def to_css(cls, obj, inline=False):
|
||||||
@ -682,7 +682,7 @@ class Text(LRFStream):
|
|||||||
0xF5D2: 'cr',
|
0xF5D2: 'cr',
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextTag(object):
|
class TextTag:
|
||||||
|
|
||||||
def __init__(self, name, attrs={}, self_closing=False):
|
def __init__(self, name, attrs={}, self_closing=False):
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -1198,7 +1198,7 @@ class SimpleText(Text):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TocLabel(object):
|
class TocLabel:
|
||||||
|
|
||||||
def __init__(self, refpage, refobject, label):
|
def __init__(self, refpage, refobject, label):
|
||||||
self.refpage, self.refobject, self.label = refpage, refobject, label
|
self.refpage, self.refobject, self.label = refpage, refobject, label
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
from polyglot.builtins import unicode_type, string_or_bytes
|
||||||
|
|
||||||
|
|
||||||
class ElementWriter(object):
|
class ElementWriter:
|
||||||
|
|
||||||
def __init__(self, e, header=False, sourceEncoding="ascii",
|
def __init__(self, e, header=False, sourceEncoding="ascii",
|
||||||
spaceBeforeClose=True, outputEncodingName="UTF-16"):
|
spaceBeforeClose=True, outputEncodingName="UTF-16"):
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user