Use enumerate instead of range+len for loops.
This commit is contained in:
parent
ab614f636e
commit
13f120b029
3 changed files with 17 additions and 16 deletions
|
@ -166,6 +166,7 @@ enable=F, # Fatal
|
||||||
consider-using-in,
|
consider-using-in,
|
||||||
consider-using-join,
|
consider-using-join,
|
||||||
consider-merging-isinstance,
|
consider-merging-isinstance,
|
||||||
|
consider-using-enumerate,
|
||||||
isinstance-second-argument-not-valid-type,
|
isinstance-second-argument-not-valid-type,
|
||||||
unidiomatic-typecheck,
|
unidiomatic-typecheck,
|
||||||
use-list-literal,
|
use-list-literal,
|
||||||
|
|
|
@ -221,9 +221,9 @@ class pesterQuirks:
|
||||||
# print("excludes: " + str(excludes))
|
# print("excludes: " + str(excludes))
|
||||||
# print("sendparts: " + str(sendparts))
|
# print("sendparts: " + str(sendparts))
|
||||||
# print("recvparts: " + str(recvparts))
|
# print("recvparts: " + str(recvparts))
|
||||||
for part in range(0, len(excludes)):
|
for part, exclude in enumerate(excludes):
|
||||||
string += recvparts[part]
|
string += recvparts[part]
|
||||||
string += excludes[part].group()
|
string += exclude.group()
|
||||||
string += recvparts[-1]
|
string += recvparts[-1]
|
||||||
else:
|
else:
|
||||||
# No split, apply like normal.
|
# No split, apply like normal.
|
||||||
|
|
|
@ -3880,8 +3880,8 @@ class PesterWindow(MovingWindow):
|
||||||
read_file = server_file.read()
|
read_file = server_file.read()
|
||||||
server_file.close()
|
server_file.close()
|
||||||
server_list_obj = json.loads(read_file)
|
server_list_obj = json.loads(read_file)
|
||||||
for i in range(len(server_list_obj)):
|
for server in server_list_obj:
|
||||||
server_list_items.append(server_list_obj[i]["server"])
|
server_list_items.append(server["server"])
|
||||||
except:
|
except:
|
||||||
if not self.chooseServerAskedToReset:
|
if not self.chooseServerAskedToReset:
|
||||||
self.chooseServerAskedToReset = True
|
self.chooseServerAskedToReset = True
|
||||||
|
@ -3898,8 +3898,8 @@ class PesterWindow(MovingWindow):
|
||||||
selected_entry = self.removeServerBox.currentIndex()
|
selected_entry = self.removeServerBox.currentIndex()
|
||||||
except (IndexError, AssertionError) as e:
|
except (IndexError, AssertionError) as e:
|
||||||
PchumLog.warning(e)
|
PchumLog.warning(e)
|
||||||
for i in range(len(server_list_obj)):
|
for i, server in enumerate(server_list_obj):
|
||||||
if server_list_obj[i]["server"] == self.removeServerBox.currentText():
|
if server["server"] == self.removeServerBox.currentText():
|
||||||
selected_entry = i
|
selected_entry = i
|
||||||
|
|
||||||
if selected_entry is not None:
|
if selected_entry is not None:
|
||||||
|
@ -3994,8 +3994,8 @@ class PesterWindow(MovingWindow):
|
||||||
with open(_datadir + "serverlist.json") as server_file:
|
with open(_datadir + "serverlist.json") as server_file:
|
||||||
read_file = server_file.read()
|
read_file = server_file.read()
|
||||||
server_obj = json.loads(read_file)
|
server_obj = json.loads(read_file)
|
||||||
for i in range(len(server_obj)):
|
for server in server_obj:
|
||||||
server_list_items.append(server_obj[i]["server"])
|
server_list_items.append(server["server"])
|
||||||
except:
|
except:
|
||||||
if not self.chooseServerAskedToReset:
|
if not self.chooseServerAskedToReset:
|
||||||
self.chooseServerAskedToReset = True
|
self.chooseServerAskedToReset = True
|
||||||
|
@ -4010,8 +4010,8 @@ class PesterWindow(MovingWindow):
|
||||||
# removeServerBox
|
# removeServerBox
|
||||||
self.removeServerBox = QtWidgets.QComboBox()
|
self.removeServerBox = QtWidgets.QComboBox()
|
||||||
|
|
||||||
for i in range(len(server_list_items)):
|
for server in server_list_items:
|
||||||
self.removeServerBox.addItem(server_list_items[i])
|
self.removeServerBox.addItem(server)
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
cancel = QtWidgets.QPushButton("CANCEL")
|
cancel = QtWidgets.QPushButton("CANCEL")
|
||||||
|
@ -4069,8 +4069,8 @@ class PesterWindow(MovingWindow):
|
||||||
except (IndexError, AssertionError) as e:
|
except (IndexError, AssertionError) as e:
|
||||||
# fallback using 'server' as primary key
|
# fallback using 'server' as primary key
|
||||||
PchumLog.warning(e)
|
PchumLog.warning(e)
|
||||||
for i in range(len(server_obj)):
|
for i, server in enumerate(server_obj):
|
||||||
if server_obj[i]["server"] == self.serverBox.currentText():
|
if server["server"] == self.serverBox.currentText():
|
||||||
selected_entry = i
|
selected_entry = i
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -4116,8 +4116,8 @@ class PesterWindow(MovingWindow):
|
||||||
with open(_datadir + "serverlist.json") as server_file:
|
with open(_datadir + "serverlist.json") as server_file:
|
||||||
read_file = server_file.read()
|
read_file = server_file.read()
|
||||||
server_obj = json.loads(read_file)
|
server_obj = json.loads(read_file)
|
||||||
for i in range(len(server_obj)):
|
for server in server_obj:
|
||||||
server_list_items.append(server_obj[i]["server"])
|
server_list_items.append(server["server"])
|
||||||
except:
|
except:
|
||||||
PchumLog.exception("")
|
PchumLog.exception("")
|
||||||
if not self.chooseServerAskedToReset:
|
if not self.chooseServerAskedToReset:
|
||||||
|
@ -4133,8 +4133,8 @@ class PesterWindow(MovingWindow):
|
||||||
# Serverbox
|
# Serverbox
|
||||||
self.serverBox = QtWidgets.QComboBox()
|
self.serverBox = QtWidgets.QComboBox()
|
||||||
|
|
||||||
for i in range(len(server_list_items)):
|
for server in server_list_items:
|
||||||
self.serverBox.addItem(server_list_items[i])
|
self.serverBox.addItem(server)
|
||||||
|
|
||||||
self.serverBox.addItem("Add a server [Prompt]")
|
self.serverBox.addItem("Add a server [Prompt]")
|
||||||
self.serverBox.addItem("Remove a server [Prompt]")
|
self.serverBox.addItem("Remove a server [Prompt]")
|
||||||
|
|
Loading…
Reference in a new issue