Skip to content

Commit

Permalink
Checks: fix flake8 E741 in gui/wxpython directory (OSGeo#3926)
Browse files Browse the repository at this point in the history
* Rename self.l to self.item_attr when using self.l as an argument to wx.ItemAttr().

* Rename l to layer when using l for loop through layer list.

* Rename l to new_layer_lst when using l as an argument to self._tree.AddLayer().

* Rename l to rli_conf when looping through the configuration files in self.rlipath.

* Rename l to layer when looping through the self.map_.GetListOfLayers().

* Rename l to dataset_info when sorting `allDatasets` with the lambda function.

* Rename l to layer_num when looping through `catsDict.items()`.

* Rename l to layer when retrieving layer information in a function.

* Rename l to curr when looping through the `curr_sel_ls`.

* Remove E741 for files in gui/wxpython directory.
  • Loading branch information
mshukuno authored Jun 29, 2024
1 parent 9e87f51 commit b5bfcd5
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 48 deletions.
16 changes: 6 additions & 10 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ per-file-ignores =
gui/wxpython/gui_core/widgets.py: F841, E722, E266
gui/wxpython/image2target/*: F841, E722, E265
gui/wxpython/image2target/g.gui.image2target.py: E501, E265, F841
gui/wxpython/iscatt/*: F841, E722, E741, F405, F403
gui/wxpython/lmgr/giface.py: E741
gui/wxpython/iscatt/*: F841, E722, F405, F403
gui/wxpython/lmgr/frame.py: F841, E722
# layertree still includes some formatting issues (it is ignored by Black)
gui/wxpython/lmgr/layertree.py: E722, E266, W504, E225
Expand All @@ -82,16 +81,15 @@ per-file-ignores =
gui/wxpython/photo2image/*: F841, E722, E265
gui/wxpython/photo2image/g.gui.photo2image.py: E501, F841
gui/wxpython/psmap/*: F841, E266, E722, F405, F403
gui/wxpython/vdigit/*: F841, E722, E741, F405, F403
gui/wxpython/vdigit/*: F841, E722, F405, F403
gui/wxpython/vnet/*: F841
gui/wxpython/wxgui.py: F841
gui/wxpython/animation/g.gui.animation.py: E501
gui/wxpython/animation/mapwindow.py: F841
gui/wxpython/animation/provider.py: F841
gui/wxpython/tplot/frame.py: F841, E722, E741
gui/wxpython/tplot/frame.py: F841, E722
gui/wxpython/tplot/g.gui.tplot.py: E501
gui/wxpython/rdigit/g.gui.rdigit.py: F841
gui/wxpython/iclass/dialogs.py: E741
gui/wxpython/iclass/digit.py: F405, F403
gui/wxpython/iclass/frame.py: F405, F403
gui/wxpython/iclass/g.gui.iclass.py: E501
Expand All @@ -109,14 +107,12 @@ per-file-ignores =
gui/wxpython/mapwin/buffered.py: E722
gui/wxpython/mapwin/graphics.py: E722
gui/wxpython/startup/locdownload.py: E722, E402
gui/wxpython/timeline/g.gui.timeline.py: E501, E741
gui/wxpython/timeline/frame.py: E741
gui/wxpython/timeline/g.gui.timeline.py: E501
gui/wxpython/tools/build_modules_xml.py: E722
gui/wxpython/web_services/cap_interface.py: E501
gui/wxpython/web_services/widgets.py: F841, E741, E402
gui/wxpython/rlisetup/frame.py: E741
gui/wxpython/web_services/widgets.py: F841, E402
gui/wxpython/rlisetup/sampling_frame.py: F841
gui/wxpython/rlisetup/wizard.py: E722, E741
gui/wxpython/rlisetup/wizard.py: E722
# Generated file
gui/wxpython/menustrings.py: E501
# F821 undefined name 'cmp'
Expand Down
8 changes: 4 additions & 4 deletions gui/wxpython/iclass/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ def OnGetItemAttr(self, item):
text_c = wx.Colour(*ContrastColor(back_c))

# if it is in scope of the method, gui falls, using self solved it
self.l = wx.ItemAttr()
self.l.SetBackgroundColour(back_c)
self.l.SetTextColour(text_c)
return self.l
self.item_attr = wx.ItemAttr()
self.item_attr.SetBackgroundColour(back_c)
self.item_attr.SetTextColour(text_c)
return self.item_attr


def ContrastColor(color):
Expand Down
8 changes: 4 additions & 4 deletions gui/wxpython/iscatt/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ def OnGetItemAttr(self, item):
text_c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_INACTIVECAPTIONTEXT)

# if it is in scope of the method, gui falls, using self solved it
self.l = wx.ItemAttr()
self.l.SetBackgroundColour(back_c)
self.l.SetTextColour(text_c)
return self.l
self.item_attr = wx.ItemAttr()
self.item_attr.SetBackgroundColour(back_c)
self.item_attr.SetTextColour(text_c)
return self.item_attr

def OnCategoryRightUp(self, event):
"""Show context menu on right click"""
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/lmgr/giface.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __iter__(self):

def __getitem__(self, index):
"""Select a layer from the LayerList using the index."""
return [l for l in self][index]
return [layer for layer in self][index]

def __repr__(self):
"""Return a representation of the object."""
Expand Down Expand Up @@ -105,10 +105,10 @@ def AddLayer(self, ltype, name=None, checked=None, opacity=1.0, cmd=None):
:param opacity: layer opacity level
:param cmd: command (given as a list)
"""
l = self._tree.AddLayer(
new_layer_lst = self._tree.AddLayer(
ltype=ltype, lname=name, lchecked=checked, lopacity=opacity, lcmd=cmd
)
return Layer(l, self._tree.GetPyData(l))
return Layer(new_layer_lst, self._tree.GetPyData(new_layer_lst))

def DeleteLayer(self, layer):
"""Remove layer from layer list"""
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/rlisetup/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def ListFiles(self):
listfiles = []
# return all the configuration files in self.rlipath, check if there are
# link or directory and doesn't add them
for l in os.listdir(self.rlipath):
if os.path.isfile(os.path.join(self.rlipath, l)):
listfiles.append(l)
for rli_conf in os.listdir(self.rlipath):
if os.path.isfile(os.path.join(self.rlipath, rli_conf)):
listfiles.append(rli_conf)
return sorted(listfiles)

def OnClose(self, event):
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/rlisetup/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1888,13 +1888,13 @@ def newCat(self):
opacity=1.0,
render=True,
)
for l in self.map_.GetListOfLayers():
if l.name == self.outname:
for layer in self.map_.GetListOfLayers():
if layer.name == self.outname:
self.mapPanel.mapWindow.ZoomToMap(
layers=[l], render=True, ignoreNulls=True
layers=[layer], render=True, ignoreNulls=True
)
elif l.name != self.rast:
self.map_.DeleteLayer(l)
elif layer.name != self.rast:
self.map_.DeleteLayer(layer)
self.areaText.SetLabel("Is this area (cat={n}) ok?".format(n=cat))

def OnEnterPage(self, event):
Expand Down
5 changes: 4 additions & 1 deletion gui/wxpython/timeline/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,10 @@ def _checkDatasets(self, datasets):
)
mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
allDatasets = [
i for i in sorted(allDatasets, key=lambda l: mapsets.index(l[1]))
i
for i in sorted(
allDatasets, key=lambda dataset_info: mapsets.index(dataset_info[1])
)
]

for dataset in datasets:
Expand Down
5 changes: 4 additions & 1 deletion gui/wxpython/tplot/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,10 @@ def _checkDatasets(self, datasets, typ):
)
mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
allDatasets = [
i for i in sorted(allDatasets, key=lambda l: mapsets.index(l[1]))
i
for i in sorted(
allDatasets, key=lambda dataset_info: mapsets.index(dataset_info[1])
)
]

for dataset in datasets:
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/vdigit/wxdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,8 @@ def _getCatString(self, line):
catsDict[layer].append(cats.cat[i])

catsStr = ""
for l, c in catsDict.items():
catsStr = "%d: (%s)" % (l, ",".join(map(str, c)))
for layer_num, c in catsDict.items():
catsStr = "%d: (%s)" % (layer_num, ",".join(map(str, c)))

return catsStr

Expand Down
30 changes: 15 additions & 15 deletions gui/wxpython/web_services/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,20 @@ def OnDown(self, event):
def _updateLayerOrderList(self, selected=None):
"""Update order in list."""

def getlayercaption(l):
if l["title"]:
cap = l["title"]
def getlayercaption(layer):
if layer["title"]:
cap = layer["title"]
else:
cap = l["name"]
cap = layer["name"]

if l["style"]:
if l["style"]["title"]:
cap += " / " + l["style"]["title"]
if layer["style"]:
if layer["style"]["title"]:
cap += " / " + layer["style"]["title"]
else:
cap += " / " + l["style"]["name"]
cap += " / " + layer["style"]["name"]
return cap

layer_capts = [getlayercaption(l) for l in self.sel_layers]
layer_capts = [getlayercaption(sel_layer) for sel_layer in self.sel_layers]
self.l_odrder_list.Set(layer_capts)
if self.l_odrder_list.IsEmpty():
self.enableButtons(False)
Expand Down Expand Up @@ -634,7 +634,7 @@ def UpdateWidgetsByCmd(self, cmd):

# WMS standard - first layer in params is most bottom...
# therefore layers order need to be reversed
l_st_list = [l for l in reversed(l_st_list)]
l_st_list = [layer for layer in reversed(l_st_list)]
self.list.SelectLayers(l_st_list)

params = {}
Expand Down Expand Up @@ -744,9 +744,9 @@ def OnListSelChanged(self, event):
if sel_l not in curr_sel_ls:
self.sel_layers.remove(sel_l)

for l in curr_sel_ls:
if l not in self.sel_layers:
self.sel_layers.append(l)
for curr in curr_sel_ls:
if curr not in self.sel_layers:
self.sel_layers.append(curr)

self._updateLayerOrderList()
else:
Expand All @@ -759,8 +759,8 @@ def OnListSelChanged(self, event):

intersect_proj = []
first = True
for l in curr_sel_ls:
layer_projs = l["cap_intf_l"].GetLayerData("srs")
for curr in curr_sel_ls:
layer_projs = curr["cap_intf_l"].GetLayerData("srs")
if first:
projs_list = layer_projs
first = False
Expand Down

0 comments on commit b5bfcd5

Please sign in to comment.