mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
do not use a side effect of allocating list(map(...)) to execute functions for each member of a list
This commit is contained in:
parent
d76bf7a13d
commit
da8092c58a
@ -182,7 +182,8 @@ class Convert:
|
||||
indent = float(style.text_indent[:-2]) + indent
|
||||
style.text_indent = '%.3gpt' % indent
|
||||
parent.text = tabs[-1].tail or ''
|
||||
list(map(parent.remove, tabs))
|
||||
for i in tabs:
|
||||
parent.remove(i)
|
||||
|
||||
self.images.rid_map = orig_rid_map
|
||||
|
||||
|
@ -65,8 +65,8 @@ class TAGX: # {{{
|
||||
'''
|
||||
TAGX block for the Primary index header of a periodical
|
||||
'''
|
||||
list(map(self.add_tag, (1, 2, 3, 4, 5, 21, 22, 23, 0, 69, 70, 71, 72,
|
||||
73, 0)))
|
||||
for i in (1, 2, 3, 4, 5, 21, 22, 23, 0, 69, 70, 71, 72,73, 0):
|
||||
self.add_tag(i)
|
||||
return self.header(2) + bytes(self.byts)
|
||||
|
||||
@property
|
||||
@ -74,7 +74,8 @@ class TAGX: # {{{
|
||||
'''
|
||||
TAGX block for the secondary index header of a periodical
|
||||
'''
|
||||
list(map(self.add_tag, (11, 0)))
|
||||
for i in (11, 0):
|
||||
self.add_tag(i)
|
||||
return self.header(1) + bytes(self.byts)
|
||||
|
||||
@property
|
||||
@ -82,7 +83,8 @@ class TAGX: # {{{
|
||||
'''
|
||||
TAGX block for the primary index header of a flat book
|
||||
'''
|
||||
list(map(self.add_tag, (1, 2, 3, 4, 0)))
|
||||
for i in (1, 2, 3, 4, 0):
|
||||
self.add_tag(i)
|
||||
return self.header(1) + bytes(self.byts)
|
||||
|
||||
|
||||
|
@ -65,7 +65,8 @@ def merge_multiple_html_heads_and_bodies(root, log=None):
|
||||
for b in bodies:
|
||||
for x in b:
|
||||
body.append(x)
|
||||
tuple(map(root.append, (head, body)))
|
||||
for x in (head, body):
|
||||
root.append(x)
|
||||
if log is not None:
|
||||
log.warn('Merging multiple <head> and <body> sections')
|
||||
return root
|
||||
|
@ -221,7 +221,8 @@ class Pool:
|
||||
if not sip.isdeleted(x):
|
||||
sip.delete(x)
|
||||
|
||||
tuple(map(safe_delete, self.workers))
|
||||
for i in self.workers:
|
||||
safe_delete(i)
|
||||
self.workers = []
|
||||
|
||||
|
||||
|
@ -410,7 +410,8 @@ def check_external_links(container, progress_callback=(lambda num, total:None),
|
||||
return []
|
||||
items = Queue()
|
||||
ans = []
|
||||
tuple(map(items.put, iteritems(external_links)))
|
||||
for el in iteritems(external_links):
|
||||
items.put(el)
|
||||
progress_callback(0, len(external_links))
|
||||
done = []
|
||||
downloaded_html_ids = {}
|
||||
|
@ -825,7 +825,8 @@ class Container(ContainerBase): # {{{
|
||||
imap = {name:item_id for item_id, name in iteritems(imap)}
|
||||
items = [item for item, name, linear in self.spine_iter]
|
||||
tail, last_tail = (items[0].tail, items[-1].tail) if items else ('\n ', '\n ')
|
||||
tuple(map(self.remove_from_xml, items))
|
||||
for i in items:
|
||||
self.remove_from_xml(i)
|
||||
spine = self.opf_xpath('//opf:spine')[0]
|
||||
spine.text = tail
|
||||
for name, linear in spine_items:
|
||||
|
@ -384,7 +384,8 @@ def remove_links_to(container, predicate):
|
||||
removed = remove_links_in_sheet(partial(container.href_to_name, base=name), container.parsed(name), predicate)
|
||||
if removed:
|
||||
changed.add(name)
|
||||
tuple(map(container.dirty, changed))
|
||||
for i in changed:
|
||||
container.dirty(i)
|
||||
return changed
|
||||
|
||||
|
||||
|
@ -456,7 +456,8 @@ def add_anchors_markup(root, uuid, anchors):
|
||||
a.tail = '\n'
|
||||
div.append(a)
|
||||
a.count = 0
|
||||
tuple(map(a, anchors))
|
||||
for anchor in anchors:
|
||||
a(anchor)
|
||||
a(uuid)
|
||||
|
||||
|
||||
|
@ -490,7 +490,8 @@ def get_cover(metadata):
|
||||
|
||||
def get_covers(themes, dialog, num_of_workers=8):
|
||||
items = Queue()
|
||||
tuple(map(items.put, themes))
|
||||
for i in themes:
|
||||
items.put(i)
|
||||
|
||||
def callback(metadata, x):
|
||||
if not sip.isdeleted(dialog) and not dialog.dialog_closed:
|
||||
|
@ -217,7 +217,7 @@ class Choices(QComboBox):
|
||||
self.setEditable(False)
|
||||
opt = options[name]
|
||||
self.choices = opt.choices
|
||||
tuple(map(self.addItem, opt.choices))
|
||||
self.addItems(opt.choices)
|
||||
self.currentIndexChanged.connect(self.changed_signal.emit)
|
||||
init_opt(self, opt, layout)
|
||||
|
||||
|
@ -600,8 +600,8 @@ class TagBrowserBar(QWidget): # {{{
|
||||
find_shown = self.toggle_search_button.isChecked()
|
||||
self.toggle_search_button.setVisible(not find_shown)
|
||||
l = self.layout()
|
||||
items = [l.itemAt(i) for i in range(l.count())]
|
||||
tuple(map(l.removeItem, items))
|
||||
for i in (l.itemAt(i) for i in range(l.count())):
|
||||
l.removeItem(i)
|
||||
if find_shown:
|
||||
l.addWidget(self.alter_tb)
|
||||
self.alter_tb.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly)
|
||||
|
@ -391,7 +391,8 @@ class Boss(QObject):
|
||||
if ef:
|
||||
if isinstance(ef, str):
|
||||
ef = [ef]
|
||||
tuple(map(self.gui.file_list.request_edit, ef))
|
||||
for i in ef:
|
||||
self.gui.file_list.request_edit(i)
|
||||
else:
|
||||
if tprefs['restore_book_state']:
|
||||
self.restore_book_edit_state()
|
||||
|
@ -1129,7 +1129,8 @@ class MergeDialog(QDialog): # {{{
|
||||
|
||||
buttons = self.buttons = [QRadioButton(n) for n in names]
|
||||
buttons[0].setChecked(True)
|
||||
tuple(map(w.l.addWidget, buttons))
|
||||
for i in buttons:
|
||||
w.l.addWidget(i)
|
||||
sa.setWidget(w)
|
||||
|
||||
self.resize(self.sizeHint() + QSize(150, 20))
|
||||
|
@ -254,7 +254,8 @@ class RequestData: # {{{
|
||||
|
||||
def filesystem_file_with_custom_etag(self, output, *etag_parts):
|
||||
etag = hashlib.sha1()
|
||||
tuple(map(lambda x:etag.update(str(x).encode('utf-8')), etag_parts))
|
||||
for i in etag_parts:
|
||||
etag.update(str(i).encode('utf-8'))
|
||||
return ETaggedFile(output, etag.hexdigest())
|
||||
|
||||
def filesystem_file_with_constant_etag(self, output, etag_as_hexencoded_string):
|
||||
|
@ -194,7 +194,8 @@ def toc_anchor_map(toc):
|
||||
if name and node['id'] not in seen_map[name]:
|
||||
ans[name].append({'id':node['id'], 'frag':node['frag']})
|
||||
seen_map[name].add(node['id'])
|
||||
tuple(map(process_node, node['children']))
|
||||
for i in node['children']:
|
||||
process_node(i)
|
||||
|
||||
process_node(toc)
|
||||
return dict(ans)
|
||||
|
@ -272,7 +272,8 @@ def main(args):
|
||||
raise SystemExit(1)
|
||||
if opts.codes:
|
||||
parts = tuple(map(conv_code, parts))
|
||||
tuple(map(not_single, parts))
|
||||
for i in parts:
|
||||
not_single(i)
|
||||
ranges.add(tuple(parts))
|
||||
else:
|
||||
if opts.codes:
|
||||
|
Loading…
x
Reference in New Issue
Block a user