Correct enumerations unpacking.

This commit is contained in:
Baizley 2020-02-01 00:28:59 +01:00 committed by Nick Hall
parent a9a1b7b57e
commit 6d1105da81
10 changed files with 26 additions and 26 deletions

View File

@ -81,12 +81,12 @@ class Rule:
if self.nrprepare == 0:
if self.use_regex:
self.regex = [None]*len(self.labels)
for i in enumerate(self.labels):
if self.list[i]:
for index, label in enumerate(self.labels):
if self.list[index]:
try:
self.regex[i] = re.compile(self.list[i], re.I)
self.regex[index] = re.compile(self.list[index], re.I)
except re.error:
self.regex[i] = re.compile('')
self.regex[index] = re.compile('')
self.match_substring = self.match_regex
self.prepare(db, user)
self.nrprepare += 1

View File

@ -235,8 +235,8 @@ class ParserDateTest(BaseDateTest):
Date displayer and parser tests.
"""
def do_case(self, testset):
for date_format in enumerate(get_date_formats()):
set_format(date_format)
for index, date_format in enumerate(get_date_formats()):
set_format(index)
for dateval in date_tests[testset]:
datestr = _dd.display(dateval)
@ -245,7 +245,7 @@ class ParserDateTest(BaseDateTest):
"dateval fails is_equal in format %d:\n"
" '%s' != '%s'\n"
" '%s' != '%s'\n" %
(date_format, dateval, ndate,
(index, dateval, ndate,
dateval.__dict__, ndate.__dict__))
def test_basic(self):

View File

@ -556,7 +556,7 @@ class BookList:
b_f.write(' <size value="%f %f"/>'
'\n' % (size[0], size[1]))
if book.get_margins():
for pos in enumerate(book.get_margins()):
for pos, margin in enumerate(book.get_margins()):
b_f.write(' <margin number="%s" '
'value="%f"/>\n' % (
pos, book.get_margin(pos)))

View File

@ -497,9 +497,9 @@ class OptionListCollection(_options.OptionListCollection):
% (size[0], size[1]))
if option_list.get_margins():
margins = option_list.get_margins()
for pos in enumerate(margins):
for pos, margin in enumerate(margins):
file.write(' <margin number="%s" value="%f"/>\n'
% (pos, margins[pos]))
% (pos, margin))
if option_list.get_style_name():
file.write(' <style name="%s"/>\n'

View File

@ -178,7 +178,7 @@ class SurnameTab(EmbeddedList):
the model
"""
new_list = []
for idx in enumerate(self.model):
for idx, value in enumerate(self.model):
node = self.model.get_iter(idx)
surn = self.model.get_value(node, 5)
surn.set_prefix(self.model.get_value(node, 0))
@ -310,7 +310,7 @@ class SurnameTab(EmbeddedList):
#obtain current value
node = self.model.get_iter(path)
old_val = self.model.get_value(node, colnr)
for nr in enumerate(self.obj.get_surname_list()):
for nr, surname in enumerate(self.obj.get_surname_list()):
if nr == int(path[0]):
if old_val:
#True remains True

View File

@ -149,7 +149,7 @@ class BaseSelector(ManagedWindow):
parent_path = self.model.get_path(parent_iter)
if parent_path:
parent_path_list = parent_path.get_indices()
for i in enumerate(parent_path_list):
for i, value in enumerate(parent_path_list):
expand_path = Gtk.TreePath(
tuple([x for x in parent_path_list[:i+1]]))
self.tree.expand_row(expand_path, False)
@ -301,9 +301,9 @@ class BaseSelector(ManagedWindow):
#sorting arrow in column header (not on start, only on click)
if not self.setupcols :
for i in enumerate(self.columns):
for i, column in enumerate(self.columns):
enable_sort_flag = (i==self.sort_col)
self.columns[i].set_sort_indicator(enable_sort_flag)
column.set_sort_indicator(enable_sort_flag)
self.columns[self.sort_col].set_sort_order(self.sortorder)
# set the search column to be the sorted column

View File

@ -423,7 +423,7 @@ class ListView(NavigationView):
parent_path = self.model.get_path(parent_iter)
if parent_path:
parent_path_list = parent_path.get_indices()
for i in enumerate(parent_path_list):
for i, value in enumerate(parent_path_list):
expand_path = Gtk.TreePath(
tuple([x for x in parent_path_list[:i+1]]))
self.list.expand_row(expand_path, False)

View File

@ -397,9 +397,9 @@ class FanChartBaseWidget(Gtk.DrawingArea):
divs = [x/(steps-1) for x in range(steps)]
self.gradval = ['%d' % int(self.minperiod + x *
periodrange) for x in divs]
for i in range(len(self.gradval)):
if i % 2 == 1:
self.gradval[i] = ''
for index, value in enumerate(self.gradval):
if index % 2 == 1:
self.gradval[index] = ''
self.gradcol = [colorsys.hsv_to_rgb(
(1-div) * self.cstart_hsv[0] + div * self.cend_hsv[0],
(1-div) * self.cstart_hsv[1] + div * self.cend_hsv[1],
@ -422,9 +422,9 @@ class FanChartBaseWidget(Gtk.DrawingArea):
divs = [x/(steps-1) for x in range(steps)]
self.gradval = ['%d' % int(x * MAX_AGE) for x in divs]
self.gradval[-1] = '%d+' % MAX_AGE
for i in enumerate(self.gradval):
if i % 2 == 1:
self.gradval[i] = ''
for index, value in enumerate(self.gradval):
if index % 2 == 1:
self.gradval[index] = ''
self.gradcol = [colorsys.hsv_to_rgb(
(1-div) * self.cstart_hsv[0] + div * self.cend_hsv[0],
(1-div) * self.cstart_hsv[1] + div * self.cend_hsv[1],
@ -1397,7 +1397,7 @@ class FanChartWidget(FanChartBaseWidget):
"""
#compute the number of generations present
for generation in range(self.generations - 1, 0, -1):
for (person, *rest) in self.data[generation]:
for person, *rest in self.data[generation]:
if person:
return generation
return 1
@ -1421,7 +1421,7 @@ class FanChartWidget(FanChartBaseWidget):
a generator over all people outside of the core person
"""
for generation in range(self.generations):
for (person, dummy_parents, dummy_child, userdata) in self.data[generation]:
for person, dummy_parents, dummy_child, userdata in self.data[generation]:
yield person, userdata
def innerpeople_generator(self):

View File

@ -1309,7 +1309,7 @@ class GrampletPane(Gtk.ScrolledWindow):
x = sx - x
# first, find column:
col = 0
for i in enumerate(self.columns):
for i, column in enumerate(self.columns):
if x < (sx/len(self.columns) * (i + 1)):
col = i
break

View File

@ -184,7 +184,7 @@ class CairoDocgen(libcairodoc.CairoDoc):
body_pages = body_pages[:index_page] + index_pages + \
body_pages[index_page+1:]
self._pages = body_pages
for page_nr in enumerate(self._pages):
for page_nr, page in enumerate(self._pages):
cr.save()
cr.translate(left_margin, top_margin)
self.draw_page(page_nr, cr, layout,