diff --git a/recipes/animal_politico.recipe b/recipes/animal_politico.recipe index 5d23429f2a..c356126d64 100644 --- a/recipes/animal_politico.recipe +++ b/recipes/animal_politico.recipe @@ -32,14 +32,11 @@ class AnimalPolitico(BasicNewsRecipe): def parse_index(self): soup = self.index_to_soup('http://www.animalpolitico.com/') articles = [] - for a in soup(**{ - 'name': 'a', - 'attrs': { + for a in soup(name='a', attrs={ 'href': True, 'title': True, 'data-author': True, 'data-type': True, 'data-home-title': True - } - }): + }): title = a['title'] url = a['href'] author = a['data-author'] diff --git a/recipes/brewiarz.recipe b/recipes/brewiarz.recipe index 98a3413440..d666d4835a 100644 --- a/recipes/brewiarz.recipe +++ b/recipes/brewiarz.recipe @@ -32,7 +32,7 @@ class brewiarz(BasicNewsRecipe): now = datetime.datetime.now() feeds = [] - for i in range(0, self.next_days): + for i in range(self.next_days): url_date = now + datetime.timedelta(days=i) url_date_month = url_date.strftime('%m') url_date_month_roman = dec2rom_dict[url_date_month] diff --git a/recipes/expansion_spanish.recipe b/recipes/expansion_spanish.recipe index 783bcffc49..61f35e2241 100644 --- a/recipes/expansion_spanish.recipe +++ b/recipes/expansion_spanish.recipe @@ -142,7 +142,7 @@ class expansion_spanish(BasicNewsRecipe): link = link.split('/')[-2] a = ['0B', '0C', '0D', '0E', '0F', '0G', '0N', '0L0S', '0A'] b = ['.', '/', '?', '-', '=', '&', '.com', 'www.', '0'] - for i in range(0, len(a)): + for i in range(len(a)): link = link.replace(a[i], b[i]) link = 'http://' + link diff --git a/recipes/ilsole24ore.recipe b/recipes/ilsole24ore.recipe index 2bfaaac747..38a5f8d77b 100644 --- a/recipes/ilsole24ore.recipe +++ b/recipes/ilsole24ore.recipe @@ -48,7 +48,7 @@ class IlSole24Ore(BasicNewsRecipe): link = link.split('/')[-2] a = ['0B', '0C', '0D', '0E', '0F', '0G', '0N', '0L0S', '0A'] b = ['.', '/', '?', '-', '=', '&', '.com', 'www.', '0'] - for i in range(0, len(a)): + for i in range(len(a)): link = link.replace(a[i], b[i]) link = 'http://' + link return link diff --git a/recipes/oc_register.recipe b/recipes/oc_register.recipe index ec3179bab9..d0799cf17b 100644 --- a/recipes/oc_register.recipe +++ b/recipes/oc_register.recipe @@ -126,7 +126,7 @@ class OrangeCountyRegister(BasicNewsRecipe): # articleList = [] ans = [] feedsCount = len(self.feeds) - for x in range(0, feedsCount - 1): # should be ,4 + for x in range(feedsCount - 1): # should be ,4 feedarticles = self.parsePage(x) if feedarticles is not None: ans.append((self.feeds[x][0], feedarticles)) diff --git a/recipes/real_clear.recipe b/recipes/real_clear.recipe index 4a36bf6b68..60e2c51460 100644 --- a/recipes/real_clear.recipe +++ b/recipes/real_clear.recipe @@ -84,7 +84,7 @@ class RealClear(BasicNewsRecipe): baseParse = urlparse(pageURL) baseURL = baseParse[0] + '://' + baseParse[1] hintsCount = len(self.printhints) - for x in range(0, hintsCount): + for x in range(hintsCount): if pageURL.find(self.printhints[x][0]) == -1: continue print('Trying ' + self.printhints[x][0]) @@ -218,7 +218,7 @@ class RealClear(BasicNewsRecipe): # articleList = [] ans = [] feedsCount = len(self.feedsets) - for x in range(0, feedsCount): # should be ,4 + for x in range(feedsCount): # should be ,4 feedarticles = self.parseRSS(x) if feedarticles is not None: ans.append((self.feedsets[x][0], feedarticles)) diff --git a/ruff-strict-pep8.toml b/ruff-strict-pep8.toml index 4aca737742..62eb3e1300 100644 --- a/ruff-strict-pep8.toml +++ b/ruff-strict-pep8.toml @@ -22,14 +22,14 @@ quote-style = 'single' explicit-preview-rules = true ignore = [ 'E402', 'E722', 'E741', - 'UP012', 'UP030', 'UP032', 'UP038', 'C413', 'C420', + 'UP012', 'UP030', 'UP032', 'UP038', 'C413', 'C420', 'PIE790', 'PIE794', 'PIE810', 'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF100', 'F841', # because in preview, unused tuple unpacking variable that not use dummy syntax (prefix '_' underscore) # raise error 'unused-variable', sigh (https://github.com/astral-sh/ruff/issues/8884) ] select = [ 'E', 'F', 'I', 'W', 'INT', - 'Q', 'UP', 'YTT', 'TID', 'C4', 'COM818', + 'Q', 'UP', 'YTT', 'TID', 'C4', 'COM818', 'PIE', 'RUF', # nota: RUF can flag many unsolicited errors # preview rules 'RUF051', 'RUF056', # useless dict operation diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py index eb6aff4439..0ad6ba8d38 100644 --- a/src/calibre/devices/smart_device_app/driver.py +++ b/src/calibre/devices/smart_device_app/driver.py @@ -1303,7 +1303,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): if will_use_cache: books_on_device = [] self._debug('caching. count=', count) - for i in range(0, count): + for i in range(count): opcode, result = self._receive_from_client(print_debug_info=False) books_on_device.append(result) @@ -1356,7 +1356,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): self._call_client('NOOP', {'priKey':priKey}, print_debug_info=False, wait_for_response=False) - for i in range(0, count): + for i in range(count): if (i % 100) == 0: self._debug('getting book metadata. Done', i, 'of', count) opcode, result = self._receive_from_client(print_debug_info=False) @@ -1539,7 +1539,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): for path in paths: new_paths.append(self._strip_prefix(path)) opcode, result = self._call_client('DELETE_BOOK', {'lpaths': new_paths}) - for i in range(0, len(new_paths)): + for i in range(len(new_paths)): opcode, result = self._receive_from_client(False) self._debug('removed book with UUID', result['uuid']) self._debug('removed', len(new_paths), 'books') diff --git a/src/calibre/devices/usbms/deviceconfig.py b/src/calibre/devices/usbms/deviceconfig.py index 87309988a3..6d488f631d 100644 --- a/src/calibre/devices/usbms/deviceconfig.py +++ b/src/calibre/devices/usbms/deviceconfig.py @@ -98,7 +98,7 @@ class DeviceConfig: if cls.EXTRA_CUSTOMIZATION_MESSAGE: if isinstance(cls.EXTRA_CUSTOMIZATION_MESSAGE, list): ec = [] - for i in range(0, len(cls.EXTRA_CUSTOMIZATION_MESSAGE)): + for i in range(len(cls.EXTRA_CUSTOMIZATION_MESSAGE)): if config_widget.opt_extra_customization[i] is None: ec.append(None) continue diff --git a/src/calibre/ebooks/compression/tcr.py b/src/calibre/ebooks/compression/tcr.py index e509e19d69..e5ffb65bc0 100644 --- a/src/calibre/ebooks/compression/tcr.py +++ b/src/calibre/ebooks/compression/tcr.py @@ -105,7 +105,7 @@ class TCRCompressor: # Generate the code dictionary. code_dict = [] - for i in range(0, 256): + for i in range(256): if i in self.unused_codes: code_dict.append(b'\0') else: diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 89c66cb011..3a9bc01b99 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -151,7 +151,7 @@ class DocAnalysis: # max = l # print('max line found is '+str(max)) # Build the line length histogram - hRaw = [0 for i in range(0,buckets)] + hRaw = [0 for i in range(buckets)] for line in self.lines: l = len(line) if l > minLineLength and l < maxLineLength: @@ -170,7 +170,7 @@ class DocAnalysis: # Find the biggest bucket maxValue = 0 - for i in range(0,len(h)): + for i in range(len(h)): if h[i] > maxValue: maxValue = h[i] diff --git a/src/calibre/ebooks/lit/mssha1.py b/src/calibre/ebooks/lit/mssha1.py index 3370484862..2a5eb6a721 100644 --- a/src/calibre/ebooks/lit/mssha1.py +++ b/src/calibre/ebooks/lit/mssha1.py @@ -164,7 +164,7 @@ class mssha1: D = self.H3 E = self.H4 - for t in range(0, 80): + for t in range(80): TEMP = _rotateLeft(A, 5) + f[t](B, C, D) + E + W[t] + K[t//20] E = D D = C diff --git a/src/calibre/ebooks/lrf/html/table.py b/src/calibre/ebooks/lrf/html/table.py index 166bf94ebc..1f968601ca 100644 --- a/src/calibre/ebooks/lrf/html/table.py +++ b/src/calibre/ebooks/lrf/html/table.py @@ -244,7 +244,7 @@ class Row: i = -1 cell = None for cell in self.cells: - for k in range(0, cell.colspan): + for k in range(cell.colspan): if i == col: break i += 1 diff --git a/src/calibre/ebooks/metadata/ereader.py b/src/calibre/ebooks/metadata/ereader.py index 20aa4743ce..92c2a01b4f 100644 --- a/src/calibre/ebooks/metadata/ereader.py +++ b/src/calibre/ebooks/metadata/ereader.py @@ -68,7 +68,7 @@ def set_metadata(stream, mi): if pheader.section_data(0) != 132: return - sections = [pheader.section_data(x) for x in range(0, pheader.section_count())] + sections = [pheader.section_data(x) for x in range(pheader.section_count())] hr = HeaderRecord(sections[0]) if hr.compression not in (2, 10): diff --git a/src/calibre/ebooks/metadata/txt.py b/src/calibre/ebooks/metadata/txt.py index de0421cb74..a4887b8667 100644 --- a/src/calibre/ebooks/metadata/txt.py +++ b/src/calibre/ebooks/metadata/txt.py @@ -22,7 +22,7 @@ def get_metadata(stream, extract_cover=True): stream.seek(0) mdata = '' - for x in range(0, 4): + for x in range(4): line = stream.readline().decode('utf-8', 'replace') if not line: break diff --git a/src/calibre/ebooks/pdb/ereader/inspector.py b/src/calibre/ebooks/pdb/ereader/inspector.py index 975c413467..3c344e0292 100644 --- a/src/calibre/ebooks/pdb/ereader/inspector.py +++ b/src/calibre/ebooks/pdb/ereader/inspector.py @@ -114,7 +114,7 @@ def section_lengths(header): print('Section Sizes') print('') - for i in range(0, header.section_count()): + for i in range(header.section_count()): size = len(header.section_data(i)) if size > 65505: message = '<--- Over!' diff --git a/src/calibre/ebooks/pdb/ereader/reader132.py b/src/calibre/ebooks/pdb/ereader/reader132.py index c57225dbac..8fff1709ea 100644 --- a/src/calibre/ebooks/pdb/ereader/reader132.py +++ b/src/calibre/ebooks/pdb/ereader/reader132.py @@ -157,7 +157,7 @@ class Reader132(FormatReader): os.makedirs(os.path.join(output_dir, 'images/')) images = [] with CurrentDir(os.path.join(output_dir, 'images/')): - for i in range(0, self.header_record.num_image_pages): + for i in range(self.header_record.num_image_pages): name, img = self.get_image(self.header_record.image_data_offset + i) images.append(name) with open(name, 'wb') as imgf: @@ -210,7 +210,7 @@ class Reader132(FormatReader): os.makedirs(output_dir) with CurrentDir(output_dir): - for i in range(0, self.header_record.num_image_pages): + for i in range(self.header_record.num_image_pages): name, img = self.get_image(self.header_record.image_data_offset + i) with open(name, 'wb') as imgf: imgf.write(img) diff --git a/src/calibre/ebooks/pdb/ereader/reader202.py b/src/calibre/ebooks/pdb/ereader/reader202.py index 152b3d17e9..def1e4272f 100644 --- a/src/calibre/ebooks/pdb/ereader/reader202.py +++ b/src/calibre/ebooks/pdb/ereader/reader202.py @@ -160,7 +160,7 @@ class Reader202(FormatReader): os.makedirs(output_dir) with CurrentDir(output_dir): - for i in range(0, self.header_record.num_image_pages): + for i in range(self.header_record.num_image_pages): name, img = self.get_image(self.header_record.image_data_offset + i) with open(name, 'wb') as imgf: imgf.write(img) diff --git a/src/calibre/ebooks/pdb/palmdoc/writer.py b/src/calibre/ebooks/pdb/palmdoc/writer.py index b2f659d6d7..8d6e4e1504 100644 --- a/src/calibre/ebooks/pdb/palmdoc/writer.py +++ b/src/calibre/ebooks/pdb/palmdoc/writer.py @@ -32,7 +32,7 @@ class Writer(FormatWriter): section_lengths = [len(header_record)] self.log.info('Compessing data...') - for i in range(0, len(txt_records)): + for i in range(len(txt_records)): self.log.debug('\tCompressing record %i' % i) txt_records[i] = compress_doc(txt_records[i]) section_lengths.append(len(txt_records[i])) @@ -55,7 +55,7 @@ class Writer(FormatWriter): txt_length = len(txt) txt_records = [] - for i in range(0, (len(txt) // MAX_RECORD_SIZE) + 1): + for i in range((len(txt) // MAX_RECORD_SIZE) + 1): txt_records.append(txt[i * MAX_RECORD_SIZE: (i * MAX_RECORD_SIZE) + MAX_RECORD_SIZE]) return txt_records, txt_length diff --git a/src/calibre/ebooks/pdb/ztxt/writer.py b/src/calibre/ebooks/pdb/ztxt/writer.py index 01ce97c517..c9e8f81d51 100644 --- a/src/calibre/ebooks/pdb/ztxt/writer.py +++ b/src/calibre/ebooks/pdb/ztxt/writer.py @@ -32,7 +32,7 @@ class Writer(FormatWriter): section_lengths = [] compressor = zlib.compressobj(9) self.log.info('Compressing data...') - for i in range(0, len(txt_records)): + for i in range(len(txt_records)): self.log.debug('\tCompressing record %i' % i) txt_records[i] = compressor.compress(txt_records[i]) txt_records[i] = txt_records[i] + compressor.flush(zlib.Z_FULL_FLUSH) @@ -60,7 +60,7 @@ class Writer(FormatWriter): txt_length = len(txt) txt_records = [] - for i in range(0, (len(txt) / MAX_RECORD_SIZE) + 1): + for i in range((len(txt) / MAX_RECORD_SIZE) + 1): txt_records.append(txt[i * MAX_RECORD_SIZE : (i * MAX_RECORD_SIZE) + MAX_RECORD_SIZE]) return txt_records, txt_length diff --git a/src/calibre/ebooks/pdf/html_writer.py b/src/calibre/ebooks/pdf/html_writer.py index 2deb7d7c24..08f9087d1f 100644 --- a/src/calibre/ebooks/pdf/html_writer.py +++ b/src/calibre/ebooks/pdf/html_writer.py @@ -47,7 +47,7 @@ from polyglot.urllib import urlparse # }}} -OK, KILL_SIGNAL = range(0, 2) +OK, KILL_SIGNAL = range(2) HANG_TIME = 60 # seconds diff --git a/src/calibre/ebooks/pdf/reflow.py b/src/calibre/ebooks/pdf/reflow.py index d26a8620bb..6f9bb2b545 100644 --- a/src/calibre/ebooks/pdf/reflow.py +++ b/src/calibre/ebooks/pdf/reflow.py @@ -517,7 +517,7 @@ class Column: def collect_stats(self): if len(self.elements) > 1: gaps = [self.elements[i+1].top - self.elements[i].bottom for i in - range(0, len(self.elements)-1)] + range(len(self.elements)-1)] self.average_line_separation = sum(gaps)/len(gaps) for i, elem in enumerate(self.elements): left_margin = elem.left - self.left diff --git a/src/calibre/ebooks/rb/__init__.py b/src/calibre/ebooks/rb/__init__.py index f7169e9583..7ca8e66cc7 100644 --- a/src/calibre/ebooks/rb/__init__.py +++ b/src/calibre/ebooks/rb/__init__.py @@ -18,7 +18,7 @@ def unique_name(name, used_names): else: ext = os.path.splitext(name)[1][:3] base_name = name[:22] - for i in range(0, 9999): + for i in range(9999): name = '{}-{}.{}'.format(str(i).rjust('0', 4)[:4], base_name, ext) if name not in used_names: break diff --git a/src/calibre/ebooks/rb/rbml.py b/src/calibre/ebooks/rb/rbml.py index 908982269d..47994fc395 100644 --- a/src/calibre/ebooks/rb/rbml.py +++ b/src/calibre/ebooks/rb/rbml.py @@ -211,7 +211,7 @@ class RBMLizer: text += self.dump_text(item, stylizer, page, tag_stack) close_tag_list = [] - for i in range(0, tag_count): + for i in range(tag_count): close_tag_list.insert(0, tag_stack.pop()) text += self.close_tags(close_tag_list) @@ -223,7 +223,7 @@ class RBMLizer: def close_tags(self, tags): text = [''] - for i in range(0, len(tags)): + for i in range(len(tags)): tag = tags.pop() text.append('' % tag) diff --git a/src/calibre/ebooks/rb/writer.py b/src/calibre/ebooks/rb/writer.py index 5c2bf7396a..fd7e5088f9 100644 --- a/src/calibre/ebooks/rb/writer.py +++ b/src/calibre/ebooks/rb/writer.py @@ -100,7 +100,7 @@ class RBWriter: size = len(text) pages = [] - for i in range(0, (len(text) + TEXT_RECORD_SIZE-1) // TEXT_RECORD_SIZE): + for i in range((len(text) + TEXT_RECORD_SIZE-1) // TEXT_RECORD_SIZE): zobj = zlib.compressobj(9, zlib.DEFLATED, 13, 8, 0) pages.append(zobj.compress(text[i * TEXT_RECORD_SIZE : (i * TEXT_RECORD_SIZE) + TEXT_RECORD_SIZE]) + zobj.flush()) diff --git a/src/calibre/ebooks/rtf/rtfml.py b/src/calibre/ebooks/rtf/rtfml.py index a79fa4bd73..10359a01f1 100644 --- a/src/calibre/ebooks/rtf/rtfml.py +++ b/src/calibre/ebooks/rtf/rtfml.py @@ -278,7 +278,7 @@ class RTFMLizer: for item in elem: text += self.dump_text(item, stylizer, tag_stack) - for i in range(0, tag_count): + for i in range(tag_count): end_tag = tag_stack.pop() if end_tag != 'block': if tag in BLOCK_TAGS: diff --git a/src/calibre/gui2/actions/all_actions.py b/src/calibre/gui2/actions/all_actions.py index f060182d59..aa2544d0a4 100644 --- a/src/calibre/gui2/actions/all_actions.py +++ b/src/calibre/gui2/actions/all_actions.py @@ -69,7 +69,7 @@ class AllGUIActions(InterfaceAction): # 'toolbar-device' depending on whether a device is connected. location = 'toolbar' + ('-device' if self.gui.location_manager.has_device else '') for model in (AllModel(location, self.gui), CurrentModel(location, self.gui)): - for i in range(0, model.rowCount(None)): + for i in range(model.rowCount(None)): dex = model.index(i) name = model.names((dex,))[0] # this is the action name if name is not None and not name.startswith('---'): diff --git a/src/calibre/gui2/actions/mark_books.py b/src/calibre/gui2/actions/mark_books.py index 49ffa9f93f..acdb7cd800 100644 --- a/src/calibre/gui2/actions/mark_books.py +++ b/src/calibre/gui2/actions/mark_books.py @@ -37,7 +37,7 @@ class MarkWithTextDialog(QDialog): history = textbox.all_items button_rows = min(4, len(history)-1) - for i in range(0, button_rows): + for i in range(button_rows): if i == 0: layout.addWidget(QLabel(_('Recently used values:')), 0, 0, 1, 2) button = QPushButton() diff --git a/src/calibre/gui2/convert/search_and_replace.py b/src/calibre/gui2/convert/search_and_replace.py index 1eabfc756b..f0dd310601 100644 --- a/src/calibre/gui2/convert/search_and_replace.py +++ b/src/calibre/gui2/convert/search_and_replace.py @@ -139,7 +139,7 @@ class SearchAndReplaceWidget(Widget, Ui_Form): def cell_rearrange(self, i): row = self.search_replace.currentRow() - for col in range(0, self.search_replace.columnCount()): + for col in range(self.search_replace.columnCount()): item1 = self.search_replace.item(row, col) item2 = self.search_replace.item(row+i, col) value = item1.text() @@ -227,9 +227,9 @@ class SearchAndReplaceWidget(Widget, Ui_Form): def get_definitions(self): ans = [] - for row in range(0, self.search_replace.rowCount()): + for row in range(self.search_replace.rowCount()): colItems = [] - for col in range(0, self.search_replace.columnCount()): + for col in range(self.search_replace.columnCount()): colItems.append(str(self.search_replace.item(row, col).text())) ans.append(colItems) return ans diff --git a/src/calibre/gui2/device_drivers/tabbed_device_config.py b/src/calibre/gui2/device_drivers/tabbed_device_config.py index 990b3ac5f4..d8bae0d0ee 100644 --- a/src/calibre/gui2/device_drivers/tabbed_device_config.py +++ b/src/calibre/gui2/device_drivers/tabbed_device_config.py @@ -166,7 +166,7 @@ class TabbedDeviceConfig(QTabWidget): try: return super().__getattr__(attr_name) except AttributeError as ae: - for i in range(0, self.count()): + for i in range(self.count()): atab = self.widget(i) try: return getattr(atab, attr_name) @@ -346,7 +346,7 @@ class ExtraCustomization(DeviceConfigTab): # {{{ ec = [] if self.extra_customization_message: if isinstance(self.extra_customization_message, list): - for i in range(0, len(self.extra_customization_message)): + for i in range(len(self.extra_customization_message)): if self.opt_extra_customization[i] is None: ec.append(None) continue diff --git a/src/calibre/gui2/dialogs/check_library.py b/src/calibre/gui2/dialogs/check_library.py index f36c37eed7..06bb3f8952 100644 --- a/src/calibre/gui2/dialogs/check_library.py +++ b/src/calibre/gui2/dialogs/check_library.py @@ -421,14 +421,14 @@ class CheckLibraryDialog(QDialog): self.log.blockSignals(True) if col: node.setCheckState(col, to_what) - for i in range(0, node.childCount()): + for i in range(node.childCount()): node.child(i).setCheckState(2, to_what) self.log.blockSignals(False) def is_child_delete_checked(node): checked = False all_checked = True - for i in range(0, node.childCount()): + for i in range(node.childCount()): c = node.child(i).checkState(2) checked = checked or c == Qt.CheckState.Checked all_checked = all_checked and c == Qt.CheckState.Checked @@ -522,7 +522,7 @@ class CheckLibraryDialog(QDialog): def fix_missing_formats(self): tl = self.top_level_items['missing_formats'] child_count = tl.childCount() - for i in range(0, child_count): + for i in range(child_count): item = tl.child(i) id = int(item.data(0, Qt.ItemDataRole.UserRole)) all = self.db.formats(id, index_is_id=True, verify_formats=False) @@ -535,7 +535,7 @@ class CheckLibraryDialog(QDialog): def fix_missing_covers(self): tl = self.top_level_items['missing_covers'] child_count = tl.childCount() - for i in range(0, child_count): + for i in range(child_count): item = tl.child(i) id = int(item.data(0, Qt.ItemDataRole.UserRole)) self.db.set_has_cover(id, False) @@ -543,7 +543,7 @@ class CheckLibraryDialog(QDialog): def fix_extra_covers(self): tl = self.top_level_items['extra_covers'] child_count = tl.childCount() - for i in range(0, child_count): + for i in range(child_count): item = tl.child(i) id = int(item.data(0, Qt.ItemDataRole.UserRole)) self.db.set_has_cover(id, True) diff --git a/src/calibre/gui2/dialogs/edit_authors_dialog.py b/src/calibre/gui2/dialogs/edit_authors_dialog.py index b7e1663821..75a5062870 100644 --- a/src/calibre/gui2/dialogs/edit_authors_dialog.py +++ b/src/calibre/gui2/dialogs/edit_authors_dialog.py @@ -346,7 +346,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): select_item = None if id_to_select: use_as = tweaks['categories_use_field_for_author_name'] == 'author_sort' - for row in range(0, len(auts_to_show)): + for row in range(len(auts_to_show)): if is_first_letter: item_txt = str(self.table.item(row, AUTHOR_SORT_COLUMN).text() if use_as else self.table.item(row, AUTHOR_COLUMN).text()) @@ -382,7 +382,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): def save_state(self): self.table_column_widths = [] - for c in range(0, self.table.columnCount()): + for c in range(self.table.columnCount()): self.table_column_widths.append(self.table.columnWidth(c)) gprefs['general_category_editor_row_height'] = self.table.verticalHeader().sectionSize(0) gprefs['manage_authors_table_widths'] = self.table_column_widths @@ -390,7 +390,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): def table_column_resized(self, col, old, new): self.table_column_widths = [] - for c in range(0, self.table.columnCount()): + for c in range(self.table.columnCount()): self.table_column_widths.append(self.table.columnWidth(c)) def resizeEvent(self, *args): @@ -404,7 +404,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): # widths will be remembered w = self.table.width() - 25 - self.table.verticalHeader().width() w //= self.table.columnCount() - for c in range(0, self.table.columnCount()): + for c in range(self.table.columnCount()): self.table.setColumnWidth(c, w) self.save_state() @@ -543,7 +543,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): st = icu_lower(str(self.find_box.currentText())) if not st: return - for _ in range(0, self.table.rowCount()*2): + for _ in range(self.table.rowCount()*2): self.start_find_pos = (self.start_find_pos + 1) % (self.table.rowCount()*2) r = (self.start_find_pos//2) % self.table.rowCount() c = self.start_find_pos % 2 @@ -600,7 +600,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): def do_recalc_author_sort(self): with self.no_cell_changed(): - for row in range(0,self.table.rowCount()): + for row in range(self.table.rowCount()): item_aut = self.table.item(row, AUTHOR_COLUMN) id_ = int(item_aut.data(Qt.ItemDataRole.UserRole)) aut = str(item_aut.text()).strip() @@ -620,7 +620,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog): def do_auth_sort_to_author(self): with self.no_cell_changed(): - for row in range(0,self.table.rowCount()): + for row in range(self.table.rowCount()): aus = str(self.table.item(row, AUTHOR_SORT_COLUMN).text()).strip() item_aut = self.table.item(row, AUTHOR_COLUMN) id_ = int(item_aut.data(Qt.ItemDataRole.UserRole)) diff --git a/src/calibre/gui2/dialogs/enum_values_edit.py b/src/calibre/gui2/dialogs/enum_values_edit.py index 552b23cd95..3ccb496dbd 100644 --- a/src/calibre/gui2/dialogs/enum_values_edit.py +++ b/src/calibre/gui2/dialogs/enum_values_edit.py @@ -238,7 +238,7 @@ class EnumValuesEdit(QDialog): values = [] colors = [] id_map = {} - for i in range(0, self.table.rowCount()): + for i in range(self.table.rowCount()): it = self.table.item(i, self.VALUE_COLUMN) v = str(it.text()) if not v: diff --git a/src/calibre/gui2/dialogs/match_books.py b/src/calibre/gui2/dialogs/match_books.py index 4eef521bf6..da5288101f 100644 --- a/src/calibre/gui2/dialogs/match_books.py +++ b/src/calibre/gui2/dialogs/match_books.py @@ -169,7 +169,7 @@ class MatchBooks(QDialog, Ui_MatchBooks): # widths will be remembered w = self.books_table.width() - 25 - self.books_table.verticalHeader().width() w //= self.books_table.columnCount() - for c in range(0, self.books_table.columnCount()): + for c in range(self.books_table.columnCount()): self.books_table.setColumnWidth(c, w) self.save_state() @@ -184,7 +184,7 @@ class MatchBooks(QDialog, Ui_MatchBooks): def save_state(self): self.books_table_column_widths = [] - for c in range(0, self.books_table.columnCount()): + for c in range(self.books_table.columnCount()): self.books_table_column_widths.append(self.books_table.columnWidth(c)) gprefs['match_books_dialog_books_table_widths'] = self.books_table_column_widths self.save_geometry(gprefs, 'match_books_dialog_geometry') diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 6c069f7d25..8035a9c4e9 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -990,7 +990,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): self.s_r_src_ident_label.setVisible(True) self.s_r_src_ident.setVisible(True) - for i in range(0, self.s_r_number_of_books): + for i in range(self.s_r_number_of_books): w = getattr(self, 'book_%d_text'%(i+1)) mi = self.db.get_metadata(self.ids[i], index_is_id=True) src = self.s_r_sf_itemdata(idx) @@ -1060,7 +1060,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): tt = error_message(self.s_r_error) self.test_result.setText(tt) update_status_actions(self.test_result, self.s_r_error is None, tt) - for i in range(0,self.s_r_number_of_books): + for i in range(self.s_r_number_of_books): getattr(self, 'book_%d_result'%(i+1)).setText('') def s_r_func(self, match): @@ -1184,7 +1184,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): self.s_r_set_colors() return - for i in range(0,self.s_r_number_of_books): + for i in range(self.s_r_number_of_books): mi = self.db.get_metadata(self.ids[i], index_is_id=True) wr = getattr(self, 'book_%d_result'%(i+1)) try: diff --git a/src/calibre/gui2/dialogs/quickview.py b/src/calibre/gui2/dialogs/quickview.py index 4974b39bf0..67f1951ca0 100644 --- a/src/calibre/gui2/dialogs/quickview.py +++ b/src/calibre/gui2/dialogs/quickview.py @@ -728,7 +728,7 @@ class Quickview(QDialog, Ui_Quickview): # widths will be remembered w = self.books_table.width() - 25 - self.books_table.verticalHeader().width() w //= self.books_table.columnCount() - for c in range(0, self.books_table.columnCount()): + for c in range(self.books_table.columnCount()): self.books_table.setColumnWidth(c, w) self.save_state() @@ -852,7 +852,7 @@ class Quickview(QDialog, Ui_Quickview): if self.is_closed: return self.books_table_column_widths = [] - for c in range(0, self.books_table.columnCount()): + for c in range(self.books_table.columnCount()): self.books_table_column_widths.append(self.books_table.columnWidth(c)) gprefs['quickview_dialog_books_table_widths'] = self.books_table_column_widths if not self.is_pane: diff --git a/src/calibre/gui2/dialogs/search.py b/src/calibre/gui2/dialogs/search.py index d5fb9bd5b4..783710d123 100644 --- a/src/calibre/gui2/dialogs/search.py +++ b/src/calibre/gui2/dialogs/search.py @@ -409,7 +409,7 @@ class SearchDialog(QDialog): template, sep, query = re.split(r'#@#:([tdnb]):', self.current_search_text, flags=re.IGNORECASE) self.template_value_box.setText(query) cb = self.template_test_type_box - for idx in range(0, cb.count()): + for idx in range(cb.count()): if sep == str(cb.itemData(idx)): cb.setCurrentIndex(idx) break diff --git a/src/calibre/gui2/dialogs/tag_list_editor.py b/src/calibre/gui2/dialogs/tag_list_editor.py index 410c37fa07..ef3458de1f 100644 --- a/src/calibre/gui2/dialogs/tag_list_editor.py +++ b/src/calibre/gui2/dialogs/tag_list_editor.py @@ -605,7 +605,7 @@ class TagListEditor(QDialog, Ui_TagListEditor): find_text = str(self.search_box.currentText()) if not find_text: return - for _ in range(0, self.table.rowCount()): + for _ in range(self.table.rowCount()): r = self.search_item_row = (self.search_item_row + 1) % self.table.rowCount() if self.string_contains(find_text, self.table.item(r, VALUE_COLUMN).text()): self.table.setCurrentItem(self.table.item(r, VALUE_COLUMN)) @@ -849,7 +849,7 @@ class TagListEditor(QDialog, Ui_TagListEditor): def table_column_resized(self, *args): self.table_column_widths = [] - for c in range(0, self.table.columnCount()): + for c in range(self.table.columnCount()): self.table_column_widths.append(self.table.columnWidth(c)) def resizeEvent(self, *args): @@ -863,7 +863,7 @@ class TagListEditor(QDialog, Ui_TagListEditor): # widths will be remembered w = self.table.width() - 25 - self.table.verticalHeader().width() w //= self.table.columnCount() - for c in range(0, self.table.columnCount()): + for c in range(self.table.columnCount()): self.table.setColumnWidth(c, w) def start_editing(self, on_row): diff --git a/src/calibre/gui2/dialogs/template_dialog.py b/src/calibre/gui2/dialogs/template_dialog.py index da84004ea2..1a7b05eaca 100644 --- a/src/calibre/gui2/dialogs/template_dialog.py +++ b/src/calibre/gui2/dialogs/template_dialog.py @@ -770,7 +770,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): tv.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows) tv.setRowCount(len(mi)) # Use our own widget to get rid of elision. setTextElideMode() doesn't work - for r in range(0, len(mi)): + for r in range(len(mi)): w = QLineEdit(tv) w.setReadOnly(True) w.setText(mi[r].get('title', _('No title provided'))) @@ -1145,7 +1145,7 @@ def evaluate(book, context): def table_column_resized(self, col, old, new): self.table_column_widths = [] - for c in range(0, self.template_value.columnCount()): + for c in range(self.template_value.columnCount()): self.table_column_widths.append(self.template_value.columnWidth(c)) def save_geometry(self): @@ -1289,7 +1289,7 @@ class BreakReporterBase(QDialog): def table_column_resized(self, col, old, new): self.table_column_widths = [] - for c in range(0, self.table.columnCount()): + for c in range(self.table.columnCount()): self.table_column_widths.append(self.table.columnWidth(c)) def get_field_keys(self): diff --git a/src/calibre/gui2/jobs.py b/src/calibre/gui2/jobs.py index fe3e8dbd6f..f299c76328 100644 --- a/src/calibre/gui2/jobs.py +++ b/src/calibre/gui2/jobs.py @@ -732,8 +732,7 @@ class JobsDialog(QDialog, Ui_JobsDialog): self.proxy_model.beginResetModel(), self.proxy_model.endResetModel() def hide_all(self, *args): - self.model.hide_jobs(list(range(0, - self.model.rowCount(QModelIndex())))) + self.model.hide_jobs(list(range(self.model.rowCount(QModelIndex())))) self.proxy_model.beginResetModel(), self.proxy_model.endResetModel() def show_hidden(self, *args): diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index d1bbcf5cea..a4600bfaf1 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -1366,7 +1366,7 @@ class OnDeviceSearch(SearchQueryParser): # {{{ self.model = model def universal_set(self): - return set(range(0, len(self.model.db))) + return set(range(len(self.model.db))) def get_matches(self, location, query): location = location.lower().strip() @@ -1533,7 +1533,7 @@ class DeviceBooksModel(BooksModel): # {{{ self.count_changed() def paths_deleted(self, paths): - self.map = list(range(0, len(self.db))) + self.map = list(range(len(self.db))) self.resort(False) self.research(True) self.count_changed() @@ -1669,7 +1669,7 @@ class DeviceBooksModel(BooksModel): # {{{ def set_database(self, db): self.custom_columns = {} self.db = db - self.map = list(range(0, len(db))) + self.map = list(range(len(db))) self.research(reset=False) self.resort() self.count_changed() diff --git a/src/calibre/gui2/preferences/columns.py b/src/calibre/gui2/preferences/columns.py index 7fb66a17a2..6889c15ed4 100644 --- a/src/calibre/gui2/preferences/columns.py +++ b/src/calibre/gui2/preferences/columns.py @@ -87,7 +87,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): self.opt_columns.setColumnCount(6) # Set up the columns in logical index order - for p in range(0, len(self.column_headings)): + for p in range(len(self.column_headings)): self.opt_columns.setHorizontalHeaderItem(p, QTableWidgetItem(self.column_headings[p])) # Now reorder the columns into the desired visual order. Note: ignore @@ -125,7 +125,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def header_moved(self, log_index, old_v_index, new_v_index): self.column_positions = [] - for vi in range(0, self.opt_columns.columnCount()): + for vi in range(self.opt_columns.columnCount()): self.column_positions.append(self.opt_columns.horizontalHeader().logicalIndex(vi)) self.save_geometry() @@ -158,7 +158,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def save_geometry(self): # Save both the column widths and the column order widths = [] - for i in range(0, self.opt_columns.columnCount()): + for i in range(self.opt_columns.columnCount()): widths.append(self.opt_columns.columnWidth(i)) gprefs.set('custcol-prefs-table-geometry', widths) gprefs.set('custcol-prefs-column_order', self.column_positions) @@ -168,7 +168,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): geom = gprefs.get('custcol-prefs-table-geometry', None) if geom is not None and len(geom) == self.opt_columns.columnCount(): with suppress(Exception): - for i in range(0, self.opt_columns.columnCount()): + for i in range(self.opt_columns.columnCount()): self.opt_columns.setColumnWidth(i, geom[i]) return self.opt_columns.resizeColumnsToContents() @@ -292,11 +292,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def up_column(self): count = self.get_move_count() - for _ in range(0, count): + for _ in range(count): row = self.opt_columns.currentRow() if row > 0: self.opt_columns.setSortingEnabled(False) - for i in range(0, self.opt_columns.columnCount()): + for i in range(self.opt_columns.columnCount()): lower = self.opt_columns.takeItem(row-1, i) upper = self.opt_columns.takeItem(row, i) self.opt_columns.setItem(row, i, lower) @@ -309,11 +309,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def down_column(self): count = self.get_move_count() - for _ in range(0, count): + for _ in range(count): row = self.opt_columns.currentRow() if row < self.opt_columns.rowCount()-1: self.opt_columns.setSortingEnabled(False) - for i in range(0, self.opt_columns.columnCount()): + for i in range(self.opt_columns.columnCount()): lower = self.opt_columns.takeItem(row, i) upper = self.opt_columns.takeItem(row+1, i) self.opt_columns.setItem(row+1, i, lower) @@ -365,7 +365,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): o.setRowCount(row + 1) self.setup_row(row, self.cc_column_key, row) # We need to find the new item after sorting - for i in range(0, o.rowCount()): + for i in range(o.rowCount()): if self.column_order_val(i) == row: o.setCurrentCell(i, 1) o.scrollTo(o.currentIndex()) diff --git a/src/calibre/gui2/preferences/ignored_devices.py b/src/calibre/gui2/preferences/ignored_devices.py index 1cc65acbbe..bad9f8cf5d 100644 --- a/src/calibre/gui2/preferences/ignored_devices.py +++ b/src/calibre/gui2/preferences/ignored_devices.py @@ -90,7 +90,7 @@ class ConfigWidget(ConfigWidgetBase): def commit(self): devs = {} - for i in range(0, self.devices.count()): + for i in range(self.devices.count()): e = self.devices.item(i) dev, uid = e.data(Qt.ItemDataRole.UserRole) if dev not in devs: diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py index be00accbcb..36a4efb42e 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py @@ -126,7 +126,7 @@ class TbHierarchyTab(ConfigTabWidget, Ui_Form): # Walk the items in the list box building the (node -> node) graph of # the option order node = 0 - for i in range(0, 4): + for i in range(4): v = self.tb_search_order.item(i).data(Qt.ItemDataRole.UserRole) # JSON dumps converts integer keys to strings, so do it explicitly t[str(node)] = v diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py index 0e35bfa260..5b9f7bed85 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py @@ -115,7 +115,7 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form): self.rules_table.customContextMenuRequested.connect(self.show_context_menu) self.rules_table.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) - for i in range(0, HEADER_SECTION_COUNT): + for i in range(HEADER_SECTION_COUNT): item = self.rules_table.horizontalHeaderItem(i) if i == DELETED_COLUMN: item.setIcon(QIcon.cached_icon('trash.png')) @@ -221,7 +221,7 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form): def table_column_resized(self, col, old, new): self.table_column_widths = [] - for c in range(0, self.rules_table.columnCount()): + for c in range(self.rules_table.columnCount()): self.table_column_widths.append(self.rules_table.columnWidth(c)) gprefs['tag_browser_rules_dialog_table_widths'] = self.table_column_widths @@ -236,7 +236,7 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form): # widths will be remembered. w = self.tb_icon_rules_groupbox.width() - 25 - self.rules_table.verticalHeader().width() w //= self.rules_table.columnCount() - for c in range(0, self.rules_table.columnCount()): + for c in range(self.rules_table.columnCount()): self.rules_table.setColumnWidth(c, w) self.table_column_widths.append(self.rules_table.columnWidth(c)) gprefs['tag_browser_rules_dialog_table_widths'] = self.table_column_widths @@ -258,7 +258,7 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form): def commit(self): rr = ConfigWidgetBase.commit(self) v = copy.deepcopy(gprefs['tags_browser_value_icons']) - for r in range(0, self.rules_table.rowCount()): + for r in range(self.rules_table.rowCount()): cat_item = self.rules_table.item(r, CATEGORY_COLUMN) if cat_item.is_deleted: val = self.rules_table.item(r, VALUE_COLUMN).real_value diff --git a/src/calibre/gui2/preferences/plugboard.py b/src/calibre/gui2/preferences/plugboard.py index dab3835321..7c7be43daa 100644 --- a/src/calibre/gui2/preferences/plugboard.py +++ b/src/calibre/gui2/preferences/plugboard.py @@ -87,7 +87,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): self.source_widgets = [] self.dest_widgets = [] - for i in range(0, len(self.dest_fields)-1): + for i in range(len(self.dest_fields)-1): w = TemplateLineEditor(self) self.source_widgets.append(w) self.fields_layout.addWidget(w, 5+i, 0, 1, 1) @@ -290,7 +290,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): def ok_clicked(self): pb = [] comments_in_dests = False - for i in range(0, len(self.source_widgets)): + for i in range(len(self.source_widgets)): s = str(self.source_widgets[i].text()) if s: d = self.dest_widgets[i].currentIndex() diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index 579a94bca1..2ff3aeb686 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -797,7 +797,7 @@ class TagsModel(QAbstractItemModel): # {{{ cur_idx = 0 for interval in intervals: first_chr, last_chr, length = interval - for i in range(0, length): + for i in range(length): if first_chr == last_chr: cl_list[cur_idx] = first_chr else: diff --git a/src/calibre/gui2/tag_browser/ui.py b/src/calibre/gui2/tag_browser/ui.py index 5981cd2258..92bb001ac4 100644 --- a/src/calibre/gui2/tag_browser/ui.py +++ b/src/calibre/gui2/tag_browser/ui.py @@ -97,7 +97,7 @@ class TagBrowserMixin: # {{{ if idx is not None and idx.isValid(): col = idx.column() model = self.library_view.model() - if col in range(0, len(model.column_map)): + if col in range(len(model.column_map)): current_cat = model.column_map[col] if current_cat in ('authors', 'series', 'publisher', 'tags') or current_cat in cust_cats: cdn = cat_display_name(current_cat) or current_cat diff --git a/src/calibre/gui2/viewer/highlights.py b/src/calibre/gui2/viewer/highlights.py index b0d223549f..612ea7b8b2 100644 --- a/src/calibre/gui2/viewer/highlights.py +++ b/src/calibre/gui2/viewer/highlights.py @@ -441,7 +441,7 @@ class Highlights(QTreeWidget): else: if cr < 0: cr = -1 - indices = chain(range(cr + 1, count), range(0, cr + 1)) + indices = chain(range(cr + 1, count), range(cr + 1)) for i in indices: h = items[i].data(0, highlight_role) if pat.search(h['highlighted_text']) is not None or pat.search(h.get('notes') or '') is not None: diff --git a/src/calibre/utils/formatter_functions.py b/src/calibre/utils/formatter_functions.py index c1b220f020..1d58f06576 100644 --- a/src/calibre/utils/formatter_functions.py +++ b/src/calibre/utils/formatter_functions.py @@ -389,7 +389,7 @@ arguments.[/] Can take any number of arguments. In most cases you can use the def evaluate(self, formatter, kwargs, mi, locals, *args): i = 0 res = '' - for i in range(0, len(args)): + for i in range(len(args)): res += args[i] return res @@ -1054,7 +1054,7 @@ program: re_group(field('series'), "(\S* )(.*)", "{$:uppercase()}", "{$}")'} def repl(mo): res = '' if mo and mo.lastindex: - for dex in range(0, mo.lastindex): + for dex in range(mo.lastindex): gv = mo.group(dex+1) if gv is None: continue @@ -2114,7 +2114,7 @@ uses ``re_group(item, search_re, template ...)`` when doing the replacements. def repl(mo): newval = '' if mo and mo.lastindex: - for dex in range(0, mo.lastindex): + for dex in range(mo.lastindex): gv = mo.group(dex+1) if gv is None: continue diff --git a/src/calibre/utils/zipfile.py b/src/calibre/utils/zipfile.py index a7ed737fa8..de1983afef 100644 --- a/src/calibre/utils/zipfile.py +++ b/src/calibre/utils/zipfile.py @@ -924,7 +924,7 @@ class ZipFile: def delete(self, name): '''Delete the file from the archive. If it appears multiple times only the first instance will be deleted.''' - for i in range(0, len(self.filelist)): + for i in range(len(self.filelist)): if self.filelist[i].filename == name: if self.debug: print('Removing', name) diff --git a/src/calibre/web/feeds/recipes/collection.py b/src/calibre/web/feeds/recipes/collection.py index 9f211c08c2..25ef7d4e37 100644 --- a/src/calibre/web/feeds/recipes/collection.py +++ b/src/calibre/web/feeds/recipes/collection.py @@ -75,15 +75,7 @@ def serialize_recipe(urn, recipe_class): if rso: options = f' options={quoteattr(json.dumps(rso))}' return (' ').format(**{ - 'id' : quoteattr(str(urn)), - 'title' : attr('title', _('Unknown')), - 'author' : attr('__author__', default_author), - 'language' : attr('language', 'und', normalize_language), - 'needs_subscription' : quoteattr(ns), - 'description' : attr('description', ''), - 'options' : options, - }) + ' needs_subscription={needs_subscription} description={description}{options}/>').format(id=quoteattr(str(urn)), title=attr('title', _('Unknown')), author=attr('__author__', default_author), language=attr('language', 'und', normalize_language), needs_subscription=quoteattr(ns), description=attr('description', ''), options=options) def serialize_collection(mapping_of_recipe_classes):