mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-11-22 14:33:02 -05:00
itervalues (manual)
This commit is contained in:
parent
38771f3b80
commit
25c0040177
@ -52,7 +52,7 @@ from calibre.utils.filenames import make_long_path_useable
|
|||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.utils.localization import canonicalize_lang
|
from calibre.utils.localization import canonicalize_lang
|
||||||
from polyglot.builtins import cmp, iteritems, itervalues
|
from polyglot.builtins import cmp, iteritems
|
||||||
|
|
||||||
|
|
||||||
class ExtraFile(NamedTuple):
|
class ExtraFile(NamedTuple):
|
||||||
@ -2119,10 +2119,10 @@ class Cache:
|
|||||||
implementation of :meth:`has_book` in a worker process without access to the
|
implementation of :meth:`has_book` in a worker process without access to the
|
||||||
db. '''
|
db. '''
|
||||||
try:
|
try:
|
||||||
return {icu_lower(title) for title in itervalues(self.fields['title'].table.book_col_map)}
|
return {icu_lower(title) for title in self.fields['title'].table.book_col_map.values()}
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# Some non-unicode titles in the db
|
# Some non-unicode titles in the db
|
||||||
return {icu_lower(as_unicode(title)) for title in itervalues(self.fields['title'].table.book_col_map)}
|
return {icu_lower(as_unicode(title)) for title in self.fields['title'].table.book_col_map.values()}
|
||||||
|
|
||||||
@read_api
|
@read_api
|
||||||
def has_book(self, mi):
|
def has_book(self, mi):
|
||||||
@ -2134,7 +2134,7 @@ class Cache:
|
|||||||
if isbytestring(title):
|
if isbytestring(title):
|
||||||
title = title.decode(preferred_encoding, 'replace')
|
title = title.decode(preferred_encoding, 'replace')
|
||||||
q = icu_lower(title).strip()
|
q = icu_lower(title).strip()
|
||||||
for title in itervalues(self.fields['title'].table.book_col_map):
|
for title in self.fields['title'].table.book_col_map.values():
|
||||||
if q == icu_lower(title):
|
if q == icu_lower(title):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from calibre.ebooks.metadata import author_to_author_sort
|
|||||||
from calibre.utils.date import UNDEFINED_DATE, parse_date, utc_tz
|
from calibre.utils.date import UNDEFINED_DATE, parse_date, utc_tz
|
||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
from calibre_extensions.speedup import parse_date as _c_speedup
|
from calibre_extensions.speedup import parse_date as _c_speedup
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
def identity(x):
|
def identity(x):
|
||||||
@ -680,7 +679,7 @@ class FormatsTable(ManyToManyTable):
|
|||||||
|
|
||||||
def zero_max(book_id):
|
def zero_max(book_id):
|
||||||
try:
|
try:
|
||||||
return max(itervalues(self.size_map[book_id]))
|
return max(self.size_map[book_id].values())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -710,7 +709,7 @@ class FormatsTable(ManyToManyTable):
|
|||||||
self.size_map[book_id][fmt] = size
|
self.size_map[book_id][fmt] = size
|
||||||
db.execute('INSERT OR REPLACE INTO data (book,format,uncompressed_size,name) VALUES (?,?,?,?)',
|
db.execute('INSERT OR REPLACE INTO data (book,format,uncompressed_size,name) VALUES (?,?,?,?)',
|
||||||
(book_id, fmt, size, fname))
|
(book_id, fmt, size, fname))
|
||||||
return max(itervalues(self.size_map[book_id]))
|
return max(self.size_map[book_id].values())
|
||||||
|
|
||||||
|
|
||||||
class IdentifiersTable(ManyToManyTable):
|
class IdentifiersTable(ManyToManyTable):
|
||||||
|
|||||||
@ -18,7 +18,7 @@ from calibre.ptempfile import PersistentTemporaryFile
|
|||||||
from calibre.utils.date import UNDEFINED_DATE, now, utcnow
|
from calibre.utils.date import UNDEFINED_DATE, now, utcnow
|
||||||
from calibre.utils.img import image_from_path
|
from calibre.utils.img import image_from_path
|
||||||
from calibre.utils.resources import get_image_path
|
from calibre.utils.resources import get_image_path
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
def import_test(replacement_data, replacement_fmt=None):
|
def import_test(replacement_data, replacement_fmt=None):
|
||||||
@ -253,9 +253,9 @@ class AddRemoveTest(BaseTest):
|
|||||||
table = c.fields['authors'].table
|
table = c.fields['authors'].table
|
||||||
self.assertNotIn(1, c.all_book_ids())
|
self.assertNotIn(1, c.all_book_ids())
|
||||||
self.assertNotIn('Author Two', set(table.id_map.values()))
|
self.assertNotIn('Author Two', set(table.id_map.values()))
|
||||||
self.assertNotIn(6, set(itervalues(c.fields['rating'].table.id_map)))
|
self.assertNotIn(6, set(c.fields['rating'].table.id_map.values()))
|
||||||
self.assertIn('A Series One', set(itervalues(c.fields['series'].table.id_map)))
|
self.assertIn('A Series One', set(c.fields['series'].table.id_map.values()))
|
||||||
self.assertNotIn('My Series Two', set(itervalues(c.fields['#series'].table.id_map)))
|
self.assertNotIn('My Series Two', set(c.fields['#series'].table.id_map.values()))
|
||||||
self.assertNotIn(item_id, c.fields['#series'].table.col_book_map)
|
self.assertNotIn(item_id, c.fields['#series'].table.col_book_map)
|
||||||
self.assertNotIn(1, c.fields['#series'].table.book_col_map)
|
self.assertNotIn(1, c.fields['#series'].table.book_col_map)
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ from time import time
|
|||||||
from calibre.db.tests.base import BaseTest
|
from calibre.db.tests.base import BaseTest
|
||||||
from calibre.utils.date import utc_tz
|
from calibre.utils.date import utc_tz
|
||||||
from calibre.utils.localization import calibre_langcode_to_name
|
from calibre.utils.localization import calibre_langcode_to_name
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
def p(x):
|
def p(x):
|
||||||
@ -502,7 +502,7 @@ class ReadingTest(BaseTest):
|
|||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
cache = self.init_cache()
|
cache = self.init_cache()
|
||||||
db = self.init_old()
|
db = self.init_old()
|
||||||
for title in itervalues(cache.fields['title'].table.book_col_map):
|
for title in cache.fields['title'].table.book_col_map.values():
|
||||||
for x in (db, cache):
|
for x in (db, cache):
|
||||||
self.assertTrue(x.has_book(Metadata(title)))
|
self.assertTrue(x.has_book(Metadata(title)))
|
||||||
self.assertTrue(x.has_book(Metadata(title.upper())))
|
self.assertTrue(x.has_book(Metadata(title.upper())))
|
||||||
|
|||||||
@ -16,7 +16,7 @@ from calibre.db.tests.base import IMG, BaseTest
|
|||||||
from calibre.ebooks.metadata import author_to_author_sort, title_sort
|
from calibre.ebooks.metadata import author_to_author_sort, title_sort
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.utils.date import UNDEFINED_DATE
|
from calibre.utils.date import UNDEFINED_DATE
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
class WritingTest(BaseTest):
|
class WritingTest(BaseTest):
|
||||||
@ -576,7 +576,7 @@ class WritingTest(BaseTest):
|
|||||||
for c in (cache, c2):
|
for c in (cache, c2):
|
||||||
self.assertEqual(c.field_for('tags', 1), ())
|
self.assertEqual(c.field_for('tags', 1), ())
|
||||||
self.assertEqual(c.field_for('tags', 2), ('b', 'a'))
|
self.assertEqual(c.field_for('tags', 2), ('b', 'a'))
|
||||||
self.assertNotIn('c', set(itervalues(c.get_id_map('tags'))))
|
self.assertNotIn('c', set(c.get_id_map('tags').values()))
|
||||||
self.assertEqual(c.field_for('series', 1), None)
|
self.assertEqual(c.field_for('series', 1), None)
|
||||||
self.assertEqual(c.field_for('series', 2), 'a')
|
self.assertEqual(c.field_for('series', 2), 'a')
|
||||||
self.assertEqual(c.field_for('series_index', 1), 1.0)
|
self.assertEqual(c.field_for('series_index', 1), 1.0)
|
||||||
|
|||||||
@ -17,7 +17,6 @@ from calibre.constants import __appname__, isxp, numeric_version
|
|||||||
from calibre.devices.errors import BlacklistedDevice, DeviceError, OpenFailed
|
from calibre.devices.errors import BlacklistedDevice, DeviceError, OpenFailed
|
||||||
from calibre.devices.mtp.base import MTPDeviceBase, debug
|
from calibre.devices.mtp.base import MTPDeviceBase, debug
|
||||||
from calibre.ptempfile import SpooledTemporaryFile
|
from calibre.ptempfile import SpooledTemporaryFile
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
null = object()
|
null = object()
|
||||||
|
|
||||||
@ -287,7 +286,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
for x in id_map.values():
|
for x in id_map.values():
|
||||||
x['storage_id'] = storage_id
|
x['storage_id'] = storage_id
|
||||||
all_storage.append(storage)
|
all_storage.append(storage)
|
||||||
items.append(itervalues(id_map))
|
items.append(id_map.values())
|
||||||
self._filesystem_cache = FilesystemCache(all_storage, chain(*items))
|
self._filesystem_cache = FilesystemCache(all_storage, chain(*items))
|
||||||
debug(f'Filesystem metadata loaded in {time.time()-st:g} seconds ({len(self._filesystem_cache)} objects)')
|
debug(f'Filesystem metadata loaded in {time.time()-st:g} seconds ({len(self._filesystem_cache)} objects)')
|
||||||
return self._filesystem_cache
|
return self._filesystem_cache
|
||||||
|
|||||||
@ -6,8 +6,6 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
NBSP = '\xa0'
|
NBSP = '\xa0'
|
||||||
|
|
||||||
|
|
||||||
@ -154,7 +152,7 @@ def cleanup_markup(log, root, styles, dest_dir, detect_cover, XPath, uuid):
|
|||||||
current_run = [span]
|
current_run = [span]
|
||||||
|
|
||||||
# Process dir attributes
|
# Process dir attributes
|
||||||
class_map = dict(itervalues(styles.classes))
|
class_map = dict(styles.classes.values())
|
||||||
parents = ('p', 'div') + tuple(f'h{i}' for i in range(1, 7))
|
parents = ('p', 'div') + tuple(f'h{i}' for i in range(1, 7))
|
||||||
for parent in root.xpath('//*[({})]'.format(' or '.join(f'name()="{t}"' for t in parents))):
|
for parent in root.xpath('//*[({})]'.format(' or '.join(f'name()="{t}"' for t in parents))):
|
||||||
# Ensure that children of rtl parents that are not rtl have an
|
# Ensure that children of rtl parents that are not rtl have an
|
||||||
|
|||||||
@ -44,7 +44,6 @@ from calibre.ebooks.lrf.pylrs.pylrs import (
|
|||||||
TextBlock,
|
TextBlock,
|
||||||
)
|
)
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
from polyglot.urllib import unquote
|
from polyglot.urllib import unquote
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -1782,7 +1781,7 @@ class HTMLConverter:
|
|||||||
self.book.renderLrs(path) if lrs else self.book.renderLrf(path)
|
self.book.renderLrs(path) if lrs else self.book.renderLrf(path)
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
for _file in chain(itervalues(self.scaled_images), itervalues(self.rotated_images)):
|
for _file in chain(self.scaled_images.values(), self.rotated_images.values()):
|
||||||
_file.__del__()
|
_file.__del__()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,6 @@ from calibre.ebooks.lrf.meta import LRFMetaFile
|
|||||||
from calibre.ebooks.lrf.objects import BookAttr, Font, PageTree, StyleObject, Text, TOCObject, get_object, ruby_tags
|
from calibre.ebooks.lrf.objects import BookAttr, Font, PageTree, StyleObject, Text, TOCObject, get_object, ruby_tags
|
||||||
from calibre.utils.config import OptionParser
|
from calibre.utils.config import OptionParser
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
class LRFDocument(LRFMetaFile):
|
class LRFDocument(LRFMetaFile):
|
||||||
@ -81,7 +80,7 @@ class LRFDocument(LRFMetaFile):
|
|||||||
yield from self.page_trees
|
yield from self.page_trees
|
||||||
|
|
||||||
def write_files(self):
|
def write_files(self):
|
||||||
for obj in chain(itervalues(self.image_map), itervalues(self.font_map)):
|
for obj in chain(self.image_map.values(), self.font_map.values()):
|
||||||
with open(obj.file, 'wb') as f:
|
with open(obj.file, 'wb') as f:
|
||||||
f.write(obj.stream)
|
f.write(obj.stream)
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@ from struct import pack
|
|||||||
|
|
||||||
from calibre.ebooks.mobi.utils import CNCX as CNCX_
|
from calibre.ebooks.mobi.utils import CNCX as CNCX_
|
||||||
from calibre.ebooks.mobi.utils import RECORD_SIZE, align_block, encint, encode_number_as_hex, encode_tbs
|
from calibre.ebooks.mobi.utils import RECORD_SIZE, align_block, encint, encode_number_as_hex, encode_tbs
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
class CNCX(CNCX_): # {{{
|
class CNCX(CNCX_): # {{{
|
||||||
@ -222,8 +221,7 @@ class SecondaryIndexEntry(IndexEntry):
|
|||||||
|
|
||||||
# The values for this index entry
|
# The values for this index entry
|
||||||
# I don't know what the 5 means, it is not the number of entries
|
# I don't know what the 5 means, it is not the number of entries
|
||||||
self.secondary = [5 if tag == min(
|
self.secondary = [5 if tag == min(self.INDEX_MAP.values()) else 0, 0, tag]
|
||||||
itervalues(self.INDEX_MAP)) else 0, 0, tag]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tag_nums(self):
|
def tag_nums(self):
|
||||||
|
|||||||
@ -45,7 +45,6 @@ from calibre.startup import connect_lambda
|
|||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.utils.icu import numeric_sort_key, sort_key
|
from calibre.utils.icu import numeric_sort_key, sort_key
|
||||||
from calibre.utils.localization import ngettext
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
def ask_about_cc_mismatch(gui, db, newdb, missing_cols, incompatible_cols): # {{{
|
def ask_about_cc_mismatch(gui, db, newdb, missing_cols, incompatible_cols): # {{{
|
||||||
@ -514,7 +513,7 @@ class CopyToLibraryAction(InterfaceAction):
|
|||||||
|
|
||||||
self.gui.status_bar.show_message(donemsg.format(num=len(self.worker.processed), loc=loc), 2000)
|
self.gui.status_bar.show_message(donemsg.format(num=len(self.worker.processed), loc=loc), 2000)
|
||||||
if self.worker.auto_merged_ids:
|
if self.worker.auto_merged_ids:
|
||||||
books = '\n'.join(itervalues(self.worker.auto_merged_ids))
|
books = '\n'.join(self.worker.auto_merged_ids.values())
|
||||||
info_dialog(self.gui, _('Auto merged'),
|
info_dialog(self.gui, _('Auto merged'),
|
||||||
_('Some books were automatically merged into existing '
|
_('Some books were automatically merged into existing '
|
||||||
'records in the target library. Click "Show '
|
'records in the target library. Click "Show '
|
||||||
|
|||||||
@ -12,7 +12,6 @@ from functools import partial
|
|||||||
from calibre.gui2 import Dispatcher, choose_dir, error_dialog
|
from calibre.gui2 import Dispatcher, choose_dir, error_dialog
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
class SaveToDiskAction(InterfaceAction):
|
class SaveToDiskAction(InterfaceAction):
|
||||||
@ -127,7 +126,7 @@ class SaveToDiskAction(InterfaceAction):
|
|||||||
def save_library_format_by_ids(self, book_ids, fmt, single_dir=True):
|
def save_library_format_by_ids(self, book_ids, fmt, single_dir=True):
|
||||||
if isinstance(book_ids, numbers.Integral):
|
if isinstance(book_ids, numbers.Integral):
|
||||||
book_ids = [book_ids]
|
book_ids = [book_ids]
|
||||||
rows = list(itervalues(self.gui.library_view.ids_to_rows(book_ids)))
|
rows = list(self.gui.library_view.ids_to_rows(book_ids).values())
|
||||||
rows = [self.gui.library_view.model().index(r, 0) for r in rows]
|
rows = [self.gui.library_view.model().index(r, 0) for r in rows]
|
||||||
self.save_to_disk(True, single_dir=single_dir, single_format=fmt,
|
self.save_to_disk(True, single_dir=single_dir, single_format=fmt,
|
||||||
rows=rows, write_opf=False, save_cover=False)
|
rows=rows, write_opf=False, save_cover=False)
|
||||||
|
|||||||
@ -45,7 +45,6 @@ from calibre.startup import connect_lambda
|
|||||||
from calibre.utils.date import now
|
from calibre.utils.date import now
|
||||||
from calibre.utils.filenames import make_long_path_useable
|
from calibre.utils.filenames import make_long_path_useable
|
||||||
from calibre.utils.icu import primary_sort_key, sort_key
|
from calibre.utils.icu import primary_sort_key, sort_key
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
class Preview(QLabel):
|
class Preview(QLabel):
|
||||||
@ -336,7 +335,7 @@ class CoverSettingsWidget(QWidget):
|
|||||||
li.setSelected(True)
|
li.setSelected(True)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
next(itervalues(self.colors_map)).setSelected(True)
|
next(iter(self.colors_map.values())).setSelected(True)
|
||||||
|
|
||||||
disabled = set(prefs['disabled_styles'])
|
disabled = set(prefs['disabled_styles'])
|
||||||
self.styles_list.clear()
|
self.styles_list.clear()
|
||||||
@ -354,7 +353,7 @@ class CoverSettingsWidget(QWidget):
|
|||||||
li.setSelected(True)
|
li.setSelected(True)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
next(itervalues(self.style_map)).setSelected(True)
|
next(iter(self.style_map.values())).setSelected(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_colors(self):
|
def current_colors(self):
|
||||||
|
|||||||
@ -9,7 +9,6 @@ from qt.core import QApplication, QEvent, QInputDevice, QMouseEvent, QObject, QP
|
|||||||
|
|
||||||
from calibre.startup import connect_lambda
|
from calibre.startup import connect_lambda
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
HOLD_THRESHOLD = 1.0 # seconds
|
HOLD_THRESHOLD = 1.0 # seconds
|
||||||
TAP_THRESHOLD = 50 # manhattan pixels
|
TAP_THRESHOLD = 50 # manhattan pixels
|
||||||
@ -96,14 +95,14 @@ class State(QObject):
|
|||||||
else:
|
else:
|
||||||
self.check_for_holds()
|
self.check_for_holds()
|
||||||
if Flick in self.possible_gestures:
|
if Flick in self.possible_gestures:
|
||||||
tp = next(itervalues(self.touch_points))
|
tp = next(iter(self.touch_points.values()))
|
||||||
self.flicking.emit(tp, False)
|
self.flicking.emit(tp, False)
|
||||||
|
|
||||||
def check_for_holds(self):
|
def check_for_holds(self):
|
||||||
if not {TapAndHold} & self.possible_gestures:
|
if not {TapAndHold} & self.possible_gestures:
|
||||||
return
|
return
|
||||||
now = monotonic()
|
now = monotonic()
|
||||||
tp = next(itervalues(self.touch_points))
|
tp = next(iter(self.touch_points.values()))
|
||||||
if now - tp.time_of_last_move < HOLD_THRESHOLD:
|
if now - tp.time_of_last_move < HOLD_THRESHOLD:
|
||||||
return
|
return
|
||||||
if self.hold_started:
|
if self.hold_started:
|
||||||
@ -121,20 +120,20 @@ class State(QObject):
|
|||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
if Tap in self.possible_gestures:
|
if Tap in self.possible_gestures:
|
||||||
tp = next(itervalues(self.touch_points))
|
tp = next(iter(self.touch_points.values()))
|
||||||
if tp.total_movement <= TAP_THRESHOLD:
|
if tp.total_movement <= TAP_THRESHOLD:
|
||||||
self.tapped.emit(tp)
|
self.tapped.emit(tp)
|
||||||
return
|
return
|
||||||
|
|
||||||
if Flick in self.possible_gestures:
|
if Flick in self.possible_gestures:
|
||||||
tp = next(itervalues(self.touch_points))
|
tp = next(iter(self.touch_points.values()))
|
||||||
self.flicking.emit(tp, True)
|
self.flicking.emit(tp, True)
|
||||||
|
|
||||||
if not self.hold_started:
|
if not self.hold_started:
|
||||||
return
|
return
|
||||||
|
|
||||||
if TapAndHold in self.possible_gestures:
|
if TapAndHold in self.possible_gestures:
|
||||||
tp = next(itervalues(self.touch_points))
|
tp = next(iter(self.touch_points.values()))
|
||||||
self.tap_hold_finished.emit(tp)
|
self.tap_hold_finished.emit(tp)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@ from calibre.gui2 import gui_prefs
|
|||||||
from calibre.gui2.complete2 import EditWithComplete
|
from calibre.gui2.complete2 import EditWithComplete
|
||||||
from calibre.utils.icu import lower, sort_key
|
from calibre.utils.icu import lower, sort_key
|
||||||
from calibre.utils.localization import lang_map_for_ui
|
from calibre.utils.localization import lang_map_for_ui
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
class LanguagesEdit(EditWithComplete):
|
class LanguagesEdit(EditWithComplete):
|
||||||
@ -33,7 +32,7 @@ class LanguagesEdit(EditWithComplete):
|
|||||||
self.lineEdit().set_use_startswith_search(False)
|
self.lineEdit().set_use_startswith_search(False)
|
||||||
|
|
||||||
def init_langs(self, db):
|
def init_langs(self, db):
|
||||||
self.update_items_cache(itervalues(self._lang_map))
|
self.update_items_cache(self._lang_map.values())
|
||||||
|
|
||||||
def refresh_recently_used(self):
|
def refresh_recently_used(self):
|
||||||
recently_used = self.prefs.get('recently_used_languages') or ()
|
recently_used = self.prefs.get('recently_used_languages') or ()
|
||||||
|
|||||||
@ -22,7 +22,7 @@ from calibre.utils.date import UNDEFINED_DATE, clean_date_for_sort, now, parse_d
|
|||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
from calibre.utils.localization import _, canonicalize_lang, get_udc, lang_map
|
from calibre.utils.localization import _, canonicalize_lang, get_udc, lang_map
|
||||||
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
||||||
from polyglot.builtins import cmp, itervalues
|
from polyglot.builtins import cmp
|
||||||
|
|
||||||
|
|
||||||
class MetadataBackup(Thread): # {{{
|
class MetadataBackup(Thread): # {{{
|
||||||
@ -947,8 +947,7 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
self.marked_ids_dict = dict.fromkeys(id_dict, 'true')
|
self.marked_ids_dict = dict.fromkeys(id_dict, 'true')
|
||||||
else:
|
else:
|
||||||
# Ensure that all the items in the dict are text
|
# Ensure that all the items in the dict are text
|
||||||
self.marked_ids_dict = dict(zip(iter(id_dict), map(str,
|
self.marked_ids_dict = dict(zip(iter(id_dict), map(str, id_dict.values())))
|
||||||
itervalues(id_dict))))
|
|
||||||
|
|
||||||
# Set the values in the cache
|
# Set the values in the cache
|
||||||
marked_col = self.FIELD_MAP['marked']
|
marked_col = self.FIELD_MAP['marked']
|
||||||
|
|||||||
@ -10,7 +10,6 @@ from collections import OrderedDict
|
|||||||
from calibre.utils.config_base import tweaks
|
from calibre.utils.config_base import tweaks
|
||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
from calibre.utils.localization import _, ngettext
|
from calibre.utils.localization import _, ngettext
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
category_icon_map = {
|
category_icon_map = {
|
||||||
'authors' : 'user_profile.png',
|
'authors' : 'user_profile.png',
|
||||||
@ -496,7 +495,7 @@ class FieldMetadata:
|
|||||||
yield from self._tb_cats
|
yield from self._tb_cats
|
||||||
|
|
||||||
def itervalues(self):
|
def itervalues(self):
|
||||||
return itervalues(self._tb_cats)
|
yield from self._tb_cats.values()
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
return list(self._tb_cats.values())
|
return list(self._tb_cats.values())
|
||||||
|
|||||||
@ -28,7 +28,6 @@ from calibre.utils.localization import _, get_lang, lang_code_for_user_manual, l
|
|||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_path as P
|
||||||
from calibre.utils.search_query_parser import ParseException
|
from calibre.utils.search_query_parser import ParseException
|
||||||
from calibre.utils.serialize import json_dumps
|
from calibre.utils.serialize import json_dumps
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
POSTABLE = frozenset({'GET', 'POST', 'HEAD'})
|
POSTABLE = frozenset({'GET', 'POST', 'HEAD'})
|
||||||
|
|
||||||
@ -466,7 +465,7 @@ def tag_browser(ctx, rd):
|
|||||||
def all_lang_names():
|
def all_lang_names():
|
||||||
ans = getattr(all_lang_names, 'ans', None)
|
ans = getattr(all_lang_names, 'ans', None)
|
||||||
if ans is None:
|
if ans is None:
|
||||||
ans = all_lang_names.ans = tuple(sorted(itervalues(lang_map_for_ui()), key=numeric_sort_key))
|
ans = all_lang_names.ans = tuple(sorted(lang_map_for_ui().values(), key=numeric_sort_key))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from calibre.srv.routes import Router
|
|||||||
from calibre.srv.users import UserManager
|
from calibre.srv.users import UserManager
|
||||||
from calibre.utils.date import utcnow
|
from calibre.utils.date import utcnow
|
||||||
from calibre.utils.search_query_parser import ParseException
|
from calibre.utils.search_query_parser import ParseException
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
class Context:
|
class Context:
|
||||||
@ -205,7 +204,7 @@ class Handler:
|
|||||||
self.router = Router(ctx=ctx, url_prefix=opts.url_prefix, auth_controller=self.auth_controller)
|
self.router = Router(ctx=ctx, url_prefix=opts.url_prefix, auth_controller=self.auth_controller)
|
||||||
for module in SRV_MODULES:
|
for module in SRV_MODULES:
|
||||||
module = import_module('calibre.srv.' + module)
|
module = import_module('calibre.srv.' + module)
|
||||||
self.router.load_routes(itervalues(vars(module)))
|
self.router.load_routes(vars(module).values())
|
||||||
self.router.finalize()
|
self.router.finalize()
|
||||||
self.router.ctx.url_for = self.router.url_for
|
self.router.ctx.url_for = self.router.url_for
|
||||||
self.dispatch = self.router.dispatch
|
self.dispatch = self.router.dispatch
|
||||||
|
|||||||
@ -18,7 +18,6 @@ from urllib.parse import quote as urlquote
|
|||||||
from calibre.srv.errors import HTTPNotFound, HTTPSimpleResponse, RouteError
|
from calibre.srv.errors import HTTPNotFound, HTTPSimpleResponse, RouteError
|
||||||
from calibre.srv.utils import http_date
|
from calibre.srv.utils import http_date
|
||||||
from calibre.utils.serialize import MSGPACK_MIME, json_dumps, msgpack_dumps
|
from calibre.utils.serialize import MSGPACK_MIME, json_dumps, msgpack_dumps
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
default_methods = frozenset(('HEAD', 'GET'))
|
default_methods = frozenset(('HEAD', 'GET'))
|
||||||
|
|
||||||
@ -255,7 +254,7 @@ class Router:
|
|||||||
self.add(item)
|
self.add(item)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return itervalues(self.routes)
|
yield from self.routes.values()
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -20,7 +20,6 @@ from calibre.srv.errors import HTTPForbidden
|
|||||||
from calibre.srv.routes import Router, endpoint
|
from calibre.srv.routes import Router, endpoint
|
||||||
from calibre.srv.tests.base import BaseTest, TestServer
|
from calibre.srv.tests.base import BaseTest, TestServer
|
||||||
from polyglot.binary import as_base64_bytes
|
from polyglot.binary import as_base64_bytes
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
REALM = 'calibre-test'
|
REALM = 'calibre-test'
|
||||||
is_ci = os.environ.get('CI', '').lower() == 'true'
|
is_ci = os.environ.get('CI', '').lower() == 'true'
|
||||||
@ -48,7 +47,7 @@ def android2(ctx, data):
|
|||||||
|
|
||||||
def router(prefer_basic_auth=False, ban_for=0, ban_after=5):
|
def router(prefer_basic_auth=False, ban_for=0, ban_after=5):
|
||||||
from calibre.srv.auth import AuthController
|
from calibre.srv.auth import AuthController
|
||||||
return Router(itervalues(globals()), auth_controller=AuthController(
|
return Router(globals().values(), auth_controller=AuthController(
|
||||||
{'testuser':'testpw', '!@#$%^&*()-=_+':'!@#$%^&*()-=_+'},
|
{'testuser':'testpw', '!@#$%^&*()-=_+':'!@#$%^&*()-=_+'},
|
||||||
ban_time_in_minutes=ban_for, ban_after=ban_after,
|
ban_time_in_minutes=ban_for, ban_after=ban_after,
|
||||||
prefer_basic_auth=prefer_basic_auth, realm=REALM, max_age_seconds=1))
|
prefer_basic_auth=prefer_basic_auth, realm=REALM, max_age_seconds=1))
|
||||||
|
|||||||
@ -15,7 +15,6 @@ from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
|||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_path as P
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
|
|
||||||
class NoFonts(ValueError):
|
class NoFonts(ValueError):
|
||||||
@ -188,8 +187,7 @@ def build_families(cached_fonts, folders, family_attr='font-family'):
|
|||||||
fonts.sort(key=font_priority)
|
fonts.sort(key=font_priority)
|
||||||
|
|
||||||
font_family_map = dict.copy(families)
|
font_family_map = dict.copy(families)
|
||||||
font_families = tuple(sorted((f[0]['font-family'] for f in
|
font_families = tuple(sorted((f[0]['font-family'] for f in font_family_map.values()), key=sort_key))
|
||||||
itervalues(font_family_map)), key=sort_key))
|
|
||||||
return font_family_map, font_families
|
return font_family_map, font_families
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from calibre.utils.fonts.sfnt.container import Sfnt
|
|||||||
from calibre.utils.fonts.sfnt.errors import NoGlyphs, UnsupportedFont
|
from calibre.utils.fonts.sfnt.errors import NoGlyphs, UnsupportedFont
|
||||||
from calibre.utils.icu import ord_string, safe_chr
|
from calibre.utils.icu import ord_string, safe_chr
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_path as P
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
# TrueType outlines {{{
|
# TrueType outlines {{{
|
||||||
|
|
||||||
@ -162,7 +161,7 @@ def subset(raw, individual_chars, ranges=(), warnings=None):
|
|||||||
gsub = sfnt[b'GSUB']
|
gsub = sfnt[b'GSUB']
|
||||||
try:
|
try:
|
||||||
gsub.decompile()
|
gsub.decompile()
|
||||||
extra_glyphs = gsub.all_substitutions(itervalues(character_map))
|
extra_glyphs = gsub.all_substitutions(character_map.values())
|
||||||
except UnsupportedFont as e:
|
except UnsupportedFont as e:
|
||||||
warn(f'Usupported GSUB table: {e}')
|
warn(f'Usupported GSUB table: {e}')
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@ -21,7 +21,7 @@ from calibre.constants import filesystem_encoding
|
|||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
from calibre.utils.icu import primary_collator, primary_find, primary_sort_key
|
from calibre.utils.icu import primary_collator, primary_find, primary_sort_key
|
||||||
from calibre.utils.icu import upper as icu_upper
|
from calibre.utils.icu import upper as icu_upper
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
DEFAULT_LEVEL1 = '/'
|
DEFAULT_LEVEL1 = '/'
|
||||||
DEFAULT_LEVEL2 = '-_ 0123456789'
|
DEFAULT_LEVEL2 = '-_ 0123456789'
|
||||||
@ -313,7 +313,7 @@ def test(return_tests=False):
|
|||||||
def test_non_bmp(self):
|
def test_non_bmp(self):
|
||||||
raw = '_\U0001f431-'
|
raw = '_\U0001f431-'
|
||||||
m = Matcher([raw], scorer=CScorer)
|
m = Matcher([raw], scorer=CScorer)
|
||||||
positions = next(itervalues(m(raw)))
|
positions = next(iter(m(raw).values()))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
positions, (0, 1, 2)
|
positions, (0, 1, 2)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,8 +8,6 @@ import numbers
|
|||||||
from ctypes import POINTER, WINFUNCTYPE, byref, c_char_p, c_ulong, c_void_p, windll
|
from ctypes import POINTER, WINFUNCTYPE, byref, c_char_p, c_ulong, c_void_p, windll
|
||||||
from ctypes.wintypes import BOOL, DWORD, LPCWSTR, UINT
|
from ctypes.wintypes import BOOL, DWORD, LPCWSTR, UINT
|
||||||
|
|
||||||
from polyglot.builtins import itervalues
|
|
||||||
|
|
||||||
HCONV = c_void_p # = DECLARE_HANDLE(HCONV)
|
HCONV = c_void_p # = DECLARE_HANDLE(HCONV)
|
||||||
HDDEDATA = c_void_p # = DECLARE_HANDLE(HDDEDATA)
|
HDDEDATA = c_void_p # = DECLARE_HANDLE(HDDEDATA)
|
||||||
HSZ = c_void_p # = DECLARE_HANDLE(HSZ)
|
HSZ = c_void_p # = DECLARE_HANDLE(HSZ)
|
||||||
@ -55,7 +53,7 @@ DML_ERRORS = {
|
|||||||
|
|
||||||
'UNFOUND_QUEUE_ID': (0x4011, 'An invalid transaction identifier was passed to a DDEML function. Once the application has returned from an XTYP_XACT_COMPLETE callback, the transaction identifier for that callback function is no longer valid.'), # noqa: E501
|
'UNFOUND_QUEUE_ID': (0x4011, 'An invalid transaction identifier was passed to a DDEML function. Once the application has returned from an XTYP_XACT_COMPLETE callback, the transaction identifier for that callback function is no longer valid.'), # noqa: E501
|
||||||
}
|
}
|
||||||
DML_ERROR_TEXT = dict(itervalues(DML_ERRORS))
|
DML_ERROR_TEXT = dict(DML_ERRORS.values())
|
||||||
|
|
||||||
user32 = windll.user32
|
user32 = windll.user32
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user