The start parameter for enumerate()

Since python version 2.6 the start parameter was added and can be used
This commit is contained in:
deix
2017-08-28 18:14:09 +02:00
parent 00e5246f96
commit dbc0d995e3
5 changed files with 12 additions and 14 deletions

View File

@@ -24,8 +24,8 @@ class Airmon(object):
def print_menu(self):
''' Prints menu '''
print Interface.menu_header()
for (index, iface) in enumerate(self.interfaces):
Color.pl(" {G}%d{W}. %s" % (index + 1, iface))
for idx, iface in enumerate(self.interfaces, start=1):
Color.pl(" {G}%d{W}. %s" % (idx, iface))
def get(self, index):
''' Gets interface at index (starts at 1) '''

View File

@@ -298,9 +298,8 @@ if __name__ == '__main__':
targets = airodump.get_targets()
Target.print_header()
for (index, target) in enumerate(targets):
index += 1
Color.pl(' {G}%s %s' % (str(index).rjust(3), target))
for idx, target in enumerate(targets, start=1):
Color.pl(' {G}%s %s' % (str(idx).rjust(3), target))
Configuration.delete_temp()

View File

@@ -74,11 +74,11 @@ class CrackHandshake(object):
Color.p(" " + ("-" * 17))
Color.p(" " + ("-" * 19) + "\n")
# Print all handshakes
for index, hs in enumerate(handshakes):
for idx, hs in enumerate(handshakes, start=1):
bssid = hs["bssid"]
essid = hs["essid"]
date = datetime.strftime(datetime.fromtimestamp(hs["date"]), "%Y-%m-%dT%H:%M:%S")
Color.p(" {G}%s{W}" % str(index + 1).rjust(3))
Color.p(" {G}%s{W}" % str(idx).rjust(3))
Color.p(" {C}%s{W}" % essid.ljust(max_essid_len))
Color.p(" {C}%s{W}" % bssid)
Color.p(" {C}%s{W}\n" % date)

View File

@@ -125,10 +125,9 @@ class Scanner(object):
Color.p('\r')
Target.print_header()
for (index, target) in enumerate(self.targets):
index += 1
for idx, target in enumerate(self.targets, start=1):
Color.clear_entire_line()
Color.pl(' {G}%s %s' % (str(index).rjust(3), target))
Color.pl(' {G}%s %s' % (str(idx).rjust(3), target))
@staticmethod
def get_terminal_height():