mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix breakage caused by dict_six auto-fixes
This commit is contained in:
parent
5d46f5fbeb
commit
b0d6aec8ed
@ -10,7 +10,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import sys, os, textwrap
|
import sys, os, textwrap
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from polyglot.builtins import iteritems, map, unicode_type, range
|
from polyglot.builtins import map, unicode_type, range
|
||||||
|
|
||||||
from PyQt5.Qt import (QPushButton, QFrame, QMenu, QInputDialog, QCheckBox,
|
from PyQt5.Qt import (QPushButton, QFrame, QMenu, QInputDialog, QCheckBox,
|
||||||
QDialog, QVBoxLayout, QDialogButtonBox, QSize, QStackedWidget, QWidget,
|
QDialog, QVBoxLayout, QDialogButtonBox, QSize, QStackedWidget, QWidget,
|
||||||
@ -401,13 +401,13 @@ class TreeWidget(QTreeWidget): # {{{
|
|||||||
self.push_history()
|
self.push_history()
|
||||||
return QTreeWidget.commitData(self, editor)
|
return QTreeWidget.commitData(self, editor)
|
||||||
|
|
||||||
def iteritems(self, parent=None):
|
def iter_items(self, parent=None):
|
||||||
if parent is None:
|
if parent is None:
|
||||||
parent = self.invisibleRootItem()
|
parent = self.invisibleRootItem()
|
||||||
for i in range(parent.childCount()):
|
for i in range(parent.childCount()):
|
||||||
child = parent.child(i)
|
child = parent.child(i)
|
||||||
yield child
|
yield child
|
||||||
for gc in self.iteritems(parent=child):
|
for gc in self.iter_items(parent=child):
|
||||||
yield gc
|
yield gc
|
||||||
|
|
||||||
def update_status_tip(self, item):
|
def update_status_tip(self, item):
|
||||||
@ -469,7 +469,7 @@ class TreeWidget(QTreeWidget): # {{{
|
|||||||
# For order to be be preserved when moving by drag and drop, we
|
# For order to be be preserved when moving by drag and drop, we
|
||||||
# have to ensure that selectedIndexes returns an ordered list of
|
# have to ensure that selectedIndexes returns an ordered list of
|
||||||
# indexes.
|
# indexes.
|
||||||
sort_map = {self.indexFromItem(item):i for i, item in enumerate(iteritems(self))}
|
sort_map = {self.indexFromItem(item):i for i, item in enumerate(self.iter_items())}
|
||||||
ans = sorted(ans, key=lambda x:sort_map.get(x, -1))
|
ans = sorted(ans, key=lambda x:sort_map.get(x, -1))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ class TreeWidget(QTreeWidget): # {{{
|
|||||||
|
|
||||||
def bulk_rename(self):
|
def bulk_rename(self):
|
||||||
from calibre.gui2.tweak_book.file_list import get_bulk_rename_settings
|
from calibre.gui2.tweak_book.file_list import get_bulk_rename_settings
|
||||||
sort_map = {item:i for i, item in enumerate(iteritems(self))}
|
sort_map = {item:i for i, item in enumerate(self.iter_items())}
|
||||||
items = sorted(self.selectedItems(), key=lambda x:sort_map.get(x, -1))
|
items = sorted(self.selectedItems(), key=lambda x:sort_map.get(x, -1))
|
||||||
settings = get_bulk_rename_settings(self, len(items), prefix=_('Chapter '), msg=_(
|
settings = get_bulk_rename_settings(self, len(items), prefix=_('Chapter '), msg=_(
|
||||||
'All selected items will be renamed to the form prefix-number'), sanitize=lambda x:x, leading_zeros=False)
|
'All selected items will be renamed to the form prefix-number'), sanitize=lambda x:x, leading_zeros=False)
|
||||||
@ -775,8 +775,8 @@ class TOCView(QWidget): # {{{
|
|||||||
p = item.parent() or self.root
|
p = item.parent() or self.root
|
||||||
p.removeChild(item)
|
p.removeChild(item)
|
||||||
|
|
||||||
def iteritems(self, parent=None):
|
def iter_items(self, parent=None):
|
||||||
for item in self.tocw.iteritems(parent=parent):
|
for item in self.tocw.iter_items(parent=parent):
|
||||||
yield item
|
yield item
|
||||||
|
|
||||||
def flatten_toc(self):
|
def flatten_toc(self):
|
||||||
@ -784,7 +784,7 @@ class TOCView(QWidget): # {{{
|
|||||||
found = True
|
found = True
|
||||||
while found:
|
while found:
|
||||||
found = False
|
found = False
|
||||||
for item in iteritems(self):
|
for item in self.iter_items():
|
||||||
if item.childCount() > 0:
|
if item.childCount() > 0:
|
||||||
self._flatten_item(item)
|
self._flatten_item(item)
|
||||||
found = True
|
found = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user