Refactor most of the shadowing from outer scopes. This is a super simple change, just changing the variable used inside (mostly) lambdas.
This commit is contained in:
@@ -431,7 +431,7 @@ class FittingView(d.Display):
|
||||
|
||||
if fit is not None:
|
||||
self.mods = fit.modules[:]
|
||||
self.mods.sort(key=lambda mod: (slotOrder.index(mod.slot), mod.position))
|
||||
self.mods.sort(key=lambda _mod: (slotOrder.index(_mod.slot), _mod.position))
|
||||
|
||||
# Blanks is a list of indexes that mark non-module positions (such
|
||||
# as Racks and tactical Modes. This allows us to skip over common
|
||||
|
||||
@@ -629,17 +629,17 @@ class ItemCompare(wx.Panel):
|
||||
|
||||
if sort is not None:
|
||||
if sort == 0: # Name sort
|
||||
func = lambda x: x.name
|
||||
func = lambda _val: _val.name
|
||||
else:
|
||||
try:
|
||||
# Remember to reduce by 1, because the attrs array
|
||||
# starts at 0 while the list has the item name as column 0.
|
||||
attr = str(self.attrs.keys()[sort - 1])
|
||||
func = lambda x: x.attributes[attr].value if attr in x.attributes else None
|
||||
func = lambda _val: _val.attributes[attr].value if attr in _val.attributes else None
|
||||
except IndexError:
|
||||
# Clicked on a column that's not part of our array (price most likely)
|
||||
self.sortReverse = False
|
||||
func = lambda x: x.attributes['metaLevel'].value if 'metaLevel' in x.attributes else None
|
||||
func = lambda _val: _val.attributes['metaLevel'].value if 'metaLevel' in _val.attributes else None
|
||||
|
||||
self.items = sorted(self.items, key=func, reverse=self.sortReverse)
|
||||
|
||||
|
||||
@@ -685,7 +685,7 @@ class ShipBrowser(wx.Panel):
|
||||
if len(self.categoryList) == 0:
|
||||
# set cache of category list
|
||||
self.categoryList = list(sMkt.getShipRoot())
|
||||
self.categoryList.sort(key=lambda ship: ship.name)
|
||||
self.categoryList.sort(key=lambda _ship: _ship.name)
|
||||
|
||||
# set map & cache of fittings per category
|
||||
for cat in self.categoryList:
|
||||
@@ -928,7 +928,7 @@ class ShipBrowser(wx.Panel):
|
||||
fits = event.fits
|
||||
|
||||
# sort by ship name, then fit name
|
||||
fits.sort(key=lambda fit: (fit.ship.item.name, fit.name))
|
||||
fits.sort(key=lambda _fit: (_fit.ship.item.name, _fit.name))
|
||||
|
||||
self.lastdata = fits
|
||||
self.lpane.Freeze()
|
||||
|
||||
@@ -169,7 +169,7 @@ class exportHtmlThread(threading.Thread):
|
||||
""" % (time.time(), dnaUrl, localDate)
|
||||
HTML += ' <ul data-role="listview" class="ui-listview-outer" data-inset="true" data-filter="true">\n'
|
||||
categoryList = list(sMkt.getShipRoot())
|
||||
categoryList.sort(key=lambda ship: ship.name)
|
||||
categoryList.sort(key=lambda _ship: _ship.name)
|
||||
|
||||
count = 0
|
||||
|
||||
@@ -178,7 +178,7 @@ class exportHtmlThread(threading.Thread):
|
||||
HTMLgroup = ''
|
||||
|
||||
ships = list(sMkt.getShipList(group.ID))
|
||||
ships.sort(key=lambda ship: ship.name)
|
||||
ships.sort(key=lambda _ship: _ship.name)
|
||||
|
||||
# Keep track of how many ships per group
|
||||
groupFits = 0
|
||||
@@ -248,7 +248,7 @@ class exportHtmlThread(threading.Thread):
|
||||
def generateMinimalHTML(self, sMkt, sFit, dnaUrl):
|
||||
""" Generate a minimal HTML version of the fittings, without any javascript or styling"""
|
||||
categoryList = list(sMkt.getShipRoot())
|
||||
categoryList.sort(key=lambda ship: ship.name)
|
||||
categoryList.sort(key=lambda _ship: _ship.name)
|
||||
|
||||
count = 0
|
||||
HTML = ''
|
||||
@@ -256,9 +256,9 @@ class exportHtmlThread(threading.Thread):
|
||||
# init market group string to give ships something to attach to
|
||||
|
||||
ships = list(sMkt.getShipList(group.ID))
|
||||
ships.sort(key=lambda ship: ship.name)
|
||||
ships.sort(key=lambda _ship: _ship.name)
|
||||
|
||||
ships.sort(key=lambda ship: ship.name)
|
||||
ships.sort(key=lambda _ship: _ship.name)
|
||||
|
||||
for ship in ships:
|
||||
fits = sFit.getFitsWithShip(ship.ID)
|
||||
|
||||
Reference in New Issue
Block a user