mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-12 12:35:53 +01:00
Removed iteritems and itervalues, which are redundant
This commit is contained in:
@@ -10,7 +10,6 @@ import pkg_resources
|
||||
|
||||
from ebook_converter.utils.lock import ExclusiveFile
|
||||
from ebook_converter.constants import config_dir, CONFIG_DIR_MODE, ispy3, preferred_encoding, filesystem_encoding, iswindows
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
plugin_dir = os.path.join(config_dir, 'plugins')
|
||||
|
||||
@@ -92,7 +91,7 @@ def force_unicode_recursive(obj):
|
||||
if isinstance(obj, (list, tuple)):
|
||||
return type(obj)(map(force_unicode_recursive, obj))
|
||||
if isinstance(obj, dict):
|
||||
return {force_unicode_recursive(k): force_unicode_recursive(v) for k, v in iteritems(obj)}
|
||||
return {force_unicode_recursive(k): force_unicode_recursive(v) for k, v in obj.items()}
|
||||
return obj
|
||||
|
||||
|
||||
@@ -569,7 +568,7 @@ def make_unicode(obj):
|
||||
if isinstance(obj, (list, tuple)):
|
||||
return list(map(make_unicode, obj))
|
||||
if isinstance(obj, dict):
|
||||
return {make_unicode(k): make_unicode(v) for k, v in iteritems(obj)}
|
||||
return {make_unicode(k): make_unicode(v) for k, v in obj.items()}
|
||||
return obj
|
||||
|
||||
|
||||
@@ -577,7 +576,7 @@ def normalize_tweak(val):
|
||||
if isinstance(val, (list, tuple)):
|
||||
return tuple(map(normalize_tweak, val))
|
||||
if isinstance(val, dict):
|
||||
return {k: normalize_tweak(v) for k, v in iteritems(val)}
|
||||
return {k: normalize_tweak(v) for k, v in val.items()}
|
||||
return val
|
||||
|
||||
|
||||
@@ -586,7 +585,7 @@ def write_custom_tweaks(tweaks_dict):
|
||||
tweaks_dict = make_unicode(tweaks_dict)
|
||||
changed_tweaks = {}
|
||||
default_tweaks = exec_tweaks(default_tweaks_raw())
|
||||
for key, cval in iteritems(tweaks_dict):
|
||||
for key, cval in tweaks_dict.items():
|
||||
if key in default_tweaks and normalize_tweak(cval) == normalize_tweak(default_tweaks[key]):
|
||||
continue
|
||||
changed_tweaks[key] = cval
|
||||
|
||||
@@ -13,7 +13,6 @@ from ebook_converter.constants import (
|
||||
filesystem_encoding, iswindows, plugins, preferred_encoding, isosx, ispy3
|
||||
)
|
||||
from ebook_converter.utils.localization import get_udc
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
def ascii_text(orig):
|
||||
@@ -367,7 +366,7 @@ class WindowsAtomicFolderMove(object):
|
||||
names = os.listdir(path)
|
||||
name_to_fileid = {x:windows_get_fileid(os.path.join(path, x)) for x in names}
|
||||
fileid_to_names = defaultdict(set)
|
||||
for name, fileid in iteritems(name_to_fileid):
|
||||
for name, fileid in name_to_fileid.items():
|
||||
fileid_to_names[fileid].add(name)
|
||||
|
||||
for x in names:
|
||||
@@ -417,7 +416,7 @@ class WindowsAtomicFolderMove(object):
|
||||
def copy_path_to(self, path, dest):
|
||||
import win32file
|
||||
handle = None
|
||||
for p, h in iteritems(self.handle_map):
|
||||
for p, h in self.handle_map.items():
|
||||
if samefile_windows(path, p):
|
||||
handle = h
|
||||
break
|
||||
@@ -446,20 +445,20 @@ class WindowsAtomicFolderMove(object):
|
||||
def release_file(self, path):
|
||||
' Release the lock on the file pointed to by path. Will also release the lock on any hardlinks to path '
|
||||
key = None
|
||||
for p, h in iteritems(self.handle_map):
|
||||
for p, h in self.handle_map.items():
|
||||
if samefile_windows(path, p):
|
||||
key = (p, h)
|
||||
break
|
||||
if key is not None:
|
||||
import win32file
|
||||
win32file.CloseHandle(key[1])
|
||||
remove = [f for f, h in iteritems(self.handle_map) if h is key[1]]
|
||||
remove = [f for f, h in self.handle_map.items() if h is key[1]]
|
||||
for x in remove:
|
||||
self.handle_map.pop(x)
|
||||
|
||||
def close_handles(self):
|
||||
import win32file
|
||||
for h in itervalues(self.handle_map):
|
||||
for h in self.handle_map.values():
|
||||
win32file.CloseHandle(h)
|
||||
self.handle_map = {}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from ebook_converter import walk, prints, as_unicode
|
||||
from ebook_converter.constants import (config_dir, iswindows, isosx, plugins, DEBUG,
|
||||
isworker, filesystem_encoding)
|
||||
from ebook_converter.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
||||
from ebook_converter.polyglot.builtins import itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -149,14 +148,14 @@ def path_significance(path, folders):
|
||||
|
||||
def build_families(cached_fonts, folders, family_attr='font-family'):
|
||||
families = defaultdict(list)
|
||||
for font in itervalues(cached_fonts):
|
||||
for font in cached_fonts.values():
|
||||
if not font:
|
||||
continue
|
||||
lf = (font.get(family_attr) or '').lower()
|
||||
if lf:
|
||||
families[lf].append(font)
|
||||
|
||||
for fonts in itervalues(families):
|
||||
for fonts in families.values():
|
||||
# Look for duplicate font files and choose the copy that is from a
|
||||
# more significant font directory (prefer user directories over
|
||||
# system directories).
|
||||
@@ -181,7 +180,7 @@ def build_families(cached_fonts, folders, family_attr='font-family'):
|
||||
|
||||
font_family_map = dict.copy(families)
|
||||
font_families = tuple(sorted((font[0]['font-family'] for font in
|
||||
itervalues(font_family_map))))
|
||||
font_family_map.values())))
|
||||
return font_family_map, font_families
|
||||
# }}}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont, NoGlyphs
|
||||
from ebook_converter.utils.fonts.sfnt.cff.dict_data import TopDict, PrivateDict
|
||||
from ebook_converter.utils.fonts.sfnt.cff.constants import (cff_standard_strings,
|
||||
STANDARD_CHARSETS)
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -195,8 +194,8 @@ class CFFTable(UnknownTable):
|
||||
# Map codes from the cmap table to glyph names, this will be used to
|
||||
# reconstruct character_map for the subset font
|
||||
charset_map = {code:self.cff.charset.safe_lookup(glyph_id) for code,
|
||||
glyph_id in iteritems(character_map)}
|
||||
charset = set(itervalues(charset_map))
|
||||
glyph_id in character_map.items()}
|
||||
charset = set(charset_map.values())
|
||||
charset.discard(None)
|
||||
if not charset and character_map:
|
||||
raise NoGlyphs('This font has no glyphs for the specified characters')
|
||||
@@ -207,7 +206,7 @@ class CFFTable(UnknownTable):
|
||||
|
||||
# Rebuild character_map with the glyph ids from the subset font
|
||||
character_map.clear()
|
||||
for code, charname in iteritems(charset_map):
|
||||
for code, charname in charset_map.items():
|
||||
glyph_id = s.charname_map.get(charname, None)
|
||||
if glyph_id:
|
||||
character_map[code] = glyph_id
|
||||
|
||||
@@ -2,7 +2,6 @@ from struct import unpack_from, calcsize
|
||||
from collections import OrderedDict, namedtuple
|
||||
|
||||
from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -78,7 +77,7 @@ class ListTable(OrderedDict):
|
||||
def dump(self, prefix=''):
|
||||
print(prefix, self.__class__.__name__, sep='')
|
||||
prefix += ' '
|
||||
for tag, child in iteritems(self):
|
||||
for tag, child in self.items():
|
||||
print(prefix, tag, sep='')
|
||||
child.dump(prefix=prefix+' ')
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ from struct import unpack_from
|
||||
from collections import OrderedDict
|
||||
|
||||
from ebook_converter.utils.fonts.sfnt import UnknownTable
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -80,7 +79,7 @@ class GlyfTable(UnknownTable):
|
||||
ans = OrderedDict()
|
||||
offset = 0
|
||||
block = []
|
||||
for glyph_id, glyph in iteritems(sorted_glyph_map):
|
||||
for glyph_id, glyph in sorted_glyph_map.items():
|
||||
raw = glyph()
|
||||
pad = 4 - (len(raw) % 4)
|
||||
if pad < 4:
|
||||
|
||||
@@ -6,7 +6,6 @@ from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont
|
||||
from ebook_converter.utils.fonts.sfnt.common import (ScriptListTable, FeatureListTable,
|
||||
SimpleListTable, LookupTable, ExtensionSubstitution,
|
||||
UnknownLookupSubTable)
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -29,7 +28,7 @@ class SingleSubstitution(UnknownLookupSubTable):
|
||||
gid_index_map = self.coverage.coverage_indices(glyph_ids)
|
||||
if self.format == 1:
|
||||
return {gid + self.delta for gid in gid_index_map}
|
||||
return {self.substitutes[i] for i in itervalues(gid_index_map)}
|
||||
return {self.substitutes[i] for i in gid_index_map.values()}
|
||||
|
||||
|
||||
class MultipleSubstitution(UnknownLookupSubTable):
|
||||
@@ -42,7 +41,7 @@ class MultipleSubstitution(UnknownLookupSubTable):
|
||||
def all_substitutions(self, glyph_ids):
|
||||
gid_index_map = self.coverage.coverage_indices(glyph_ids)
|
||||
ans = set()
|
||||
for index in itervalues(gid_index_map):
|
||||
for index in gid_index_map.values():
|
||||
glyphs = set(self.coverage_to_subs_map[index])
|
||||
ans |= glyphs
|
||||
return ans
|
||||
@@ -67,7 +66,7 @@ class LigatureSubstitution(UnknownLookupSubTable):
|
||||
def all_substitutions(self, glyph_ids):
|
||||
gid_index_map = self.coverage.coverage_indices(glyph_ids)
|
||||
ans = set()
|
||||
for start_glyph_id, index in iteritems(gid_index_map):
|
||||
for start_glyph_id, index in gid_index_map.items():
|
||||
for glyph_id, components in self.coverage_to_lig_map[index]:
|
||||
components = (start_glyph_id,) + components
|
||||
if set(components).issubset(glyph_ids):
|
||||
@@ -126,7 +125,7 @@ class ReverseChainSingleSubstitution(UnknownLookupSubTable):
|
||||
|
||||
def all_substitutions(self, glyph_ids):
|
||||
gid_index_map = self.coverage.coverage_indices(glyph_ids)
|
||||
return {self.substitutes[i] for i in itervalues(gid_index_map)}
|
||||
return {self.substitutes[i] for i in gid_index_map.values()}
|
||||
|
||||
|
||||
subtable_map = {
|
||||
|
||||
@@ -3,7 +3,6 @@ from operator import itemgetter
|
||||
from itertools import repeat
|
||||
|
||||
from ebook_converter.utils.fonts.sfnt import UnknownTable
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -54,7 +53,7 @@ class LocaTable(UnknownTable):
|
||||
max_glyph_id = max(max_glyph_id, current_max_glyph_id)
|
||||
self.offset_map = list(repeat(0, max_glyph_id + 2))
|
||||
glyphs = [(glyph_id, x[0], x[1]) for glyph_id, x in
|
||||
iteritems(resolved_glyph_map)]
|
||||
resolved_glyph_map.items()]
|
||||
glyphs.sort(key=itemgetter(1))
|
||||
for glyph_id, offset, sz in glyphs:
|
||||
self.offset_map[glyph_id] = offset
|
||||
|
||||
@@ -6,7 +6,6 @@ from functools import partial
|
||||
from ebook_converter.utils.icu import safe_chr, ord_string
|
||||
from ebook_converter.utils.fonts.sfnt.container import Sfnt
|
||||
from ebook_converter.utils.fonts.sfnt.errors import UnsupportedFont, NoGlyphs
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -17,7 +16,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
def resolve_glyphs(loca, glyf, character_map, extra_glyphs):
|
||||
unresolved_glyphs = set(itervalues(character_map)) | extra_glyphs
|
||||
unresolved_glyphs = set(character_map.values()) | extra_glyphs
|
||||
unresolved_glyphs.add(0) # We always want the .notdef glyph
|
||||
resolved_glyphs = {}
|
||||
|
||||
@@ -33,7 +32,7 @@ def resolve_glyphs(loca, glyf, character_map, extra_glyphs):
|
||||
if gid not in resolved_glyphs:
|
||||
unresolved_glyphs.add(gid)
|
||||
|
||||
return OrderedDict(sorted(iteritems(resolved_glyphs), key=itemgetter(0)))
|
||||
return OrderedDict(sorted(resolved_glyphs.items(), key=itemgetter(0)))
|
||||
|
||||
|
||||
def subset_truetype(sfnt, character_map, extra_glyphs):
|
||||
@@ -52,7 +51,7 @@ def subset_truetype(sfnt, character_map, extra_glyphs):
|
||||
'set, subsetting it is pointless')
|
||||
|
||||
# Keep only character codes that have resolved glyphs
|
||||
for code, glyph_id in tuple(iteritems(character_map)):
|
||||
for code, glyph_id in tuple(character_map.items()):
|
||||
if glyph_id not in resolved_glyphs:
|
||||
del character_map[code]
|
||||
|
||||
@@ -154,7 +153,7 @@ def subset(raw, individual_chars, ranges=(), warnings=None):
|
||||
gsub = sfnt[b'GSUB']
|
||||
try:
|
||||
gsub.decompile()
|
||||
extra_glyphs = gsub.all_substitutions(itervalues(character_map))
|
||||
extra_glyphs = gsub.all_substitutions(character_map.values())
|
||||
except UnsupportedFont as e:
|
||||
warn('Usupported GSUB table: %s'%e)
|
||||
except Exception:
|
||||
@@ -175,7 +174,7 @@ def subset(raw, individual_chars, ranges=(), warnings=None):
|
||||
|
||||
if b'kern' in sfnt:
|
||||
try:
|
||||
sfnt[b'kern'].restrict_to_glyphs(frozenset(itervalues(character_map)))
|
||||
sfnt[b'kern'].restrict_to_glyphs(frozenset(character_map.values()))
|
||||
except UnsupportedFont as e:
|
||||
warn('kern table unsupported, ignoring: %s'%e)
|
||||
except Exception:
|
||||
@@ -214,8 +213,8 @@ def print_stats(old_stats, new_stats):
|
||||
prints('Table', ' ', '%10s'%'Size', ' ', 'Percent', ' ', '%10s'%'New Size',
|
||||
' New Percent')
|
||||
prints('='*80)
|
||||
old_total = sum(itervalues(old_stats))
|
||||
new_total = sum(itervalues(new_stats))
|
||||
old_total = sum(old_stats.values())
|
||||
new_total = sum(new_stats.values())
|
||||
tables = sorted(old_stats, key=lambda x:old_stats[x],
|
||||
reverse=True)
|
||||
for table in tables:
|
||||
@@ -350,7 +349,8 @@ def all():
|
||||
print('Failed!')
|
||||
failed.append((font['full_name'], font['path'], str(e)))
|
||||
else:
|
||||
averages.append(sum(itervalues(new_stats))/sum(itervalues(old_stats)) * 100)
|
||||
averages.append(sum(new_stats.values()) /
|
||||
sum(old_stats.values()) * 100)
|
||||
print('Reduced to:', '%.1f'%averages[-1] , '%')
|
||||
if unsupported:
|
||||
print('\n\nUnsupported:')
|
||||
@@ -359,7 +359,7 @@ def all():
|
||||
print()
|
||||
if warnings:
|
||||
print('\n\nWarnings:')
|
||||
for name, w in iteritems(warnings):
|
||||
for name, w in warnings.items():
|
||||
if w:
|
||||
print(name)
|
||||
print('', '\n\t'.join(w), sep='\t')
|
||||
|
||||
@@ -2,7 +2,7 @@ import struct
|
||||
from io import BytesIO
|
||||
from collections import defaultdict
|
||||
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues, as_bytes
|
||||
from ebook_converter.polyglot.builtins import as_bytes
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -162,7 +162,7 @@ def decode_name_record(recs):
|
||||
return mac_names[0]
|
||||
|
||||
# Use unicode names
|
||||
for val in itervalues(unicode_names):
|
||||
for val in unicode_names.values():
|
||||
return val
|
||||
|
||||
return None
|
||||
@@ -223,9 +223,10 @@ def get_all_font_names(raw, raw_is_table=False):
|
||||
records = _get_font_names(raw, raw_is_table)
|
||||
ans = {}
|
||||
|
||||
for name, num in iteritems({'family_name':1, 'subfamily_name':2, 'full_name':4,
|
||||
'preferred_family_name':16, 'preferred_subfamily_name':17,
|
||||
'wws_family_name':21, 'wws_subfamily_name':22}):
|
||||
for name, num in {'family_name': 1, 'subfamily_name': 2, 'full_name': 4,
|
||||
'preferred_family_name': 16,
|
||||
'preferred_subfamily_name': 17, 'wws_family_name': 21,
|
||||
'wws_subfamily_name': 22}.items():
|
||||
try:
|
||||
ans[name] = decode_name_record(records[num])
|
||||
except (IndexError, KeyError, ValueError):
|
||||
|
||||
@@ -14,7 +14,6 @@ from ebook_converter.utils.titlecase import titlecase
|
||||
from ebook_converter.utils.icu import capitalize, strcmp, sort_key
|
||||
from ebook_converter.utils.date import parse_date, format_date, now, UNDEFINED_DATE
|
||||
from ebook_converter.utils.localization import calibre_langcode_to_name, canonicalize_lang
|
||||
from ebook_converter.polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -60,7 +59,7 @@ class FormatterFunctions(object):
|
||||
self._register_functions()
|
||||
|
||||
def _register_functions(self):
|
||||
for compiled_funcs in itervalues(self._functions_from_library):
|
||||
for compiled_funcs in self._functions_from_library.values():
|
||||
for cls in compiled_funcs:
|
||||
f = self._functions.get(cls.name, None)
|
||||
replace = False
|
||||
@@ -90,7 +89,7 @@ class FormatterFunctions(object):
|
||||
|
||||
def get_builtins_and_aliases(self):
|
||||
res = {}
|
||||
for f in itervalues(self._builtins):
|
||||
for f in self._builtins.values():
|
||||
res[f.name] = f
|
||||
for a in f.aliases:
|
||||
res[a] = f
|
||||
@@ -834,7 +833,7 @@ class BuiltinFormatsSizes(BuiltinFormatterFunction):
|
||||
def evaluate(self, formatter, kwargs, mi, locals):
|
||||
fmt_data = mi.get('format_metadata', {})
|
||||
try:
|
||||
return ','.join(k.upper()+':'+str(v['size']) for k,v in iteritems(fmt_data))
|
||||
return ','.join(k.upper()+':'+str(v['size']) for k,v in fmt_data.items())
|
||||
except:
|
||||
return ''
|
||||
|
||||
@@ -853,7 +852,7 @@ class BuiltinFormatsPaths(BuiltinFormatterFunction):
|
||||
def evaluate(self, formatter, kwargs, mi, locals):
|
||||
fmt_data = mi.get('format_metadata', {})
|
||||
try:
|
||||
return ','.join(k.upper()+':'+str(v['path']) for k,v in iteritems(fmt_data))
|
||||
return ','.join(k.upper()+':'+str(v['path']) for k,v in fmt_data.items())
|
||||
except:
|
||||
return ''
|
||||
|
||||
@@ -1530,7 +1529,7 @@ class BuiltinUserCategories(BuiltinFormatterFunction):
|
||||
|
||||
def evaluate(self, formatter, kwargs, mi, locals_):
|
||||
if hasattr(mi, '_proxy_metadata'):
|
||||
cats = set(k for k, v in iteritems(mi._proxy_metadata.user_categories) if v)
|
||||
cats = set(k for k, v in mi._proxy_metadata.user_categories.items() if v)
|
||||
cats = sorted(cats, key=sort_key)
|
||||
return ', '.join(cats)
|
||||
return _('This function can be used only in the GUI')
|
||||
|
||||
@@ -5,7 +5,7 @@ from ebook_converter.constants import isosx, isfrozen, filesystem_encoding, ispy
|
||||
from ebook_converter.utils.config import prefs
|
||||
from ebook_converter.ptempfile import PersistentTemporaryFile, base_dir
|
||||
from ebook_converter.utils.serialize import msgpack_dumps
|
||||
from ebook_converter.polyglot.builtins import iteritems, environ_item, native_string_type
|
||||
from ebook_converter.polyglot.builtins import environ_item, native_string_type
|
||||
from ebook_converter.polyglot.binary import as_hex_unicode
|
||||
try:
|
||||
import win32process
|
||||
@@ -162,7 +162,7 @@ class Worker(object):
|
||||
self._env = env.copy()
|
||||
else:
|
||||
# Windows cannot handle unicode env vars
|
||||
for k, v in iteritems(env):
|
||||
for k, v in env.items():
|
||||
try:
|
||||
if isinstance(k, str):
|
||||
k = k.encode('ascii')
|
||||
|
||||
@@ -7,8 +7,6 @@ import json
|
||||
from gettext import GNUTranslations, NullTranslations
|
||||
import pkg_resources
|
||||
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
_available_translations = None
|
||||
|
||||
|
||||
@@ -284,7 +282,7 @@ def lang_map():
|
||||
translate = _
|
||||
global _lang_map
|
||||
if _lang_map is None:
|
||||
_lang_map = {k:translate(v) for k, v in iteritems(iso639['by_3'])}
|
||||
_lang_map = {k:translate(v) for k, v in iso639['by_3'].items()}
|
||||
return _lang_map
|
||||
|
||||
|
||||
@@ -308,7 +306,7 @@ def langnames_to_langcodes(names):
|
||||
translate = _
|
||||
ans = {}
|
||||
names = set(names)
|
||||
for k, v in iteritems(iso639['by_3']):
|
||||
for k, v in iso639['by_3'].items():
|
||||
tv = translate(v)
|
||||
if tv in names:
|
||||
names.remove(tv)
|
||||
|
||||
@@ -9,8 +9,6 @@ from struct import calcsize, unpack, pack
|
||||
from collections import namedtuple, OrderedDict
|
||||
from tempfile import SpooledTemporaryFile
|
||||
|
||||
from ebook_converter.polyglot.builtins import itervalues
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
@@ -311,7 +309,7 @@ class LocalZipFile(object):
|
||||
|
||||
with SpooledTemporaryFile(max_size=100*1024*1024) as temp:
|
||||
ztemp = ZipFile(temp, 'w')
|
||||
for offset, header in itervalues(self.file_info):
|
||||
for offset, header in self.file_info.values():
|
||||
if header.filename in names:
|
||||
zi = ZipInfo(header.filename)
|
||||
zi.compress_type = header.compression_method
|
||||
|
||||
@@ -6,7 +6,6 @@ from functools import partial
|
||||
from threading import Lock
|
||||
|
||||
from ebook_converter import isbytestring, force_unicode, as_unicode, prints
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
@@ -88,7 +87,7 @@ class HTMLStream(Stream):
|
||||
|
||||
class UnicodeHTMLStream(HTMLStream):
|
||||
|
||||
color = {k: v.decode('ascii') for k, v in iteritems(HTMLStream.color)}
|
||||
color = {k: v.decode('ascii') for k, v in HTMLStream.color.items()}
|
||||
normal = HTMLStream.normal.decode('ascii')
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -7,7 +7,7 @@ except ValueError:
|
||||
iswindows = False
|
||||
|
||||
from ebook_converter.constants import ispy3
|
||||
from ebook_converter.polyglot.builtins import iteritems, native_string_type
|
||||
from ebook_converter.polyglot.builtins import native_string_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -42,7 +42,7 @@ RATTRIBUTES = dict(
|
||||
'concealed'
|
||||
)
|
||||
))
|
||||
ATTRIBUTES = {v:fmt(k) for k, v in iteritems(RATTRIBUTES)}
|
||||
ATTRIBUTES = {v:fmt(k) for k, v in RATTRIBUTES.items()}
|
||||
del ATTRIBUTES['']
|
||||
|
||||
RBACKGROUNDS = dict(
|
||||
@@ -56,7 +56,7 @@ RBACKGROUNDS = dict(
|
||||
'white'
|
||||
),
|
||||
))
|
||||
BACKGROUNDS = {v:fmt(k) for k, v in iteritems(RBACKGROUNDS)}
|
||||
BACKGROUNDS = {v:fmt(k) for k, v in RBACKGROUNDS.items()}
|
||||
|
||||
RCOLORS = dict(
|
||||
zip(range(31, 38), (
|
||||
@@ -69,7 +69,7 @@ RCOLORS = dict(
|
||||
'white',
|
||||
),
|
||||
))
|
||||
COLORS = {v:fmt(k) for k, v in iteritems(RCOLORS)}
|
||||
COLORS = {v:fmt(k) for k, v in RCOLORS.items()}
|
||||
|
||||
RESET = fmt(0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user