mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
more misc recomendation (auto-fix)
ruff 'PIE'
This commit is contained in:
parent
b2c90ff460
commit
e006114716
@ -32,13 +32,10 @@ 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']
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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!'
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -47,7 +47,7 @@ from polyglot.urllib import urlparse
|
||||
|
||||
# }}}
|
||||
|
||||
OK, KILL_SIGNAL = range(0, 2)
|
||||
OK, KILL_SIGNAL = range(2)
|
||||
HANG_TIME = 60 # seconds
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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('</%s>' % tag)
|
||||
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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('---'):
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -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:
|
||||
|
@ -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')
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
@ -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())
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -75,15 +75,7 @@ def serialize_recipe(urn, recipe_class):
|
||||
if rso:
|
||||
options = f' options={quoteattr(json.dumps(rso))}'
|
||||
return (' <recipe id={id} title={title} author={author} language={language}'
|
||||
' 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,
|
||||
})
|
||||
' 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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user