浏览代码

wxGUI: fix some flake8 issues (#538)

* wxGUI: fix some flake8 issues

* ignore error W605
Anna Petrasova 5 年之前
父节点
当前提交
1c7ef34ca0
共有 43 个文件被更改,包括 91 次插入116 次删除
  1. 1 9
      gui/wxpython/.flake8
  2. 1 1
      gui/wxpython/core/gcmd.py
  3. 1 1
      gui/wxpython/core/globalvar.py
  4. 0 1
      gui/wxpython/core/utils.py
  5. 2 2
      gui/wxpython/dbmgr/dialogs.py
  6. 2 2
      gui/wxpython/dbmgr/sqlbuilder.py
  7. 1 1
      gui/wxpython/dbmgr/vinfo.py
  8. 11 11
      gui/wxpython/gcp/manager.py
  9. 1 1
      gui/wxpython/gcp/mapdisplay.py
  10. 1 1
      gui/wxpython/gmodeler/model.py
  11. 8 8
      gui/wxpython/gui_core/forms.py
  12. 5 5
      gui/wxpython/gui_core/gselect.py
  13. 1 1
      gui/wxpython/gui_core/toolbars.py
  14. 1 1
      gui/wxpython/gui_core/treeview.py
  15. 0 3
      gui/wxpython/iclass/dialogs.py
  16. 0 1
      gui/wxpython/iclass/frame.py
  17. 11 11
      gui/wxpython/image2target/ii2t_manager.py
  18. 1 1
      gui/wxpython/image2target/ii2t_mapdisplay.py
  19. 2 2
      gui/wxpython/iscatt/controllers.py
  20. 0 1
      gui/wxpython/iscatt/frame.py
  21. 0 1
      gui/wxpython/iscatt/toolbars.py
  22. 2 2
      gui/wxpython/lmgr/layertree.py
  23. 2 3
      gui/wxpython/location_wizard/dialogs.py
  24. 3 3
      gui/wxpython/location_wizard/wizard.py
  25. 1 1
      gui/wxpython/mapdisp/statusbar.py
  26. 2 2
      gui/wxpython/mapwin/buffered.py
  27. 1 1
      gui/wxpython/mapwin/graphics.py
  28. 1 1
      gui/wxpython/modules/colorrules.py
  29. 0 8
      gui/wxpython/modules/import_export.py
  30. 1 1
      gui/wxpython/nviz/mapwindow.py
  31. 2 2
      gui/wxpython/nviz/tools.py
  32. 10 10
      gui/wxpython/photo2image/ip2i_manager.py
  33. 1 1
      gui/wxpython/photo2image/ip2i_mapdisplay.py
  34. 2 2
      gui/wxpython/psmap/dialogs.py
  35. 0 1
      gui/wxpython/psmap/utils.py
  36. 3 3
      gui/wxpython/tools/build_modules_xml.py
  37. 1 1
      gui/wxpython/vdigit/toolbars.py
  38. 1 1
      gui/wxpython/vdigit/wxdisplay.py
  39. 1 1
      gui/wxpython/vnet/dialogs.py
  40. 2 2
      gui/wxpython/web_services/widgets.py
  41. 2 2
      gui/wxpython/wxplot/base.py
  42. 2 2
      gui/wxpython/wxplot/dialogs.py
  43. 1 1
      gui/wxpython/wxplot/scatter.py

+ 1 - 9
gui/wxpython/.flake8

@@ -1,15 +1,9 @@
 [flake8]
 ignore =
-    E114, # indentation is not a multiple of four (comment)
-    E115, # expected an indented block (comment)
-    E262, # inline comment should start with '# '
+    W605, # invalid escape sequence '\.'
     E265, # block comment should start with '# '
     E266, # too many leading '#' for block comment
-    W605, # invalid escape sequence '\.'
     E402, # module level import not at top of file
-    E502, # the backslash is redundant between brackets
-    E712, # comparison to False should be 'if cond is False:' or 'if not cond:'
-    E713, # test for membership should be 'not in'
     E722, # do not use bare 'except'
     E731, # do not assign a lambda expression, use a def
     E741, # ambiguous variable name 'l'
@@ -17,7 +11,6 @@ ignore =
     F401, # 'animation.utils.getCpuCount' imported but unused
     F403, # 'from gmodeler.model import *' used; unable to detect undefined names
     F405, # '_' may be undefined, or defined from star imports: gmodeler.model
-    F811, # redefinition of unused 'wx' from line 106
     F821, # undefined name '_'
     F841, # local variable 'dc' is assigned to but never used
     E117, # over-indented
@@ -45,7 +38,6 @@ ignore =
     E303, # too many blank lines (3)
     E305, # expected 2 blank lines after class or function definition, found 1
     E306, # expected 1 blank line before a nested definition, found 0
-    E401, # multiple imports on one line
     E501, # line too long (96 > 79 characters)
     W291, # trailing whitespace
     W293, # blank line contains whitespace

+ 1 - 1
gui/wxpython/core/gcmd.py

@@ -183,7 +183,7 @@ class Popen(subprocess.Popen):
                         # If there are spaces, the argument was already
                         # esscaped with double quotes, so don't escape it
                         # again.
-                        if c in v and not " " in v:
+                        if c in v and " " not in v:
                             # Here, we escape each ^ in ^^^ with ^^ and a
                             # <special character> with ^ + <special character>,
                             # so we need 7 carets.

+ 1 - 1
gui/wxpython/core/globalvar.py

@@ -108,7 +108,7 @@ def CheckForWx(forceVersion=os.getenv('GRASS_WXVERSION', None)):
         if forceVersion:
             wxversion.select(forceVersion)
         wxversion.ensureMinimal(str(minVersion[0]) + '.' + str(minVersion[1]))
-        import wx
+        import wx  # noqa: F811
         version = parse_version_string(wx.__version__)
 
         if version < minVersion:

+ 0 - 1
gui/wxpython/core/utils.py

@@ -15,7 +15,6 @@ This program is free software under the GNU General Public License
 import os
 import sys
 import platform
-import string
 import glob
 import shlex
 import re

+ 2 - 2
gui/wxpython/dbmgr/dialogs.py

@@ -421,9 +421,9 @@ class DisplayAttributesDialog(wx.Dialog):
                         tfid = int(data['Id'][idx])
                     else:
                         tfid = 0  # Area / Volume
-                    if not tfid in self.cats:
+                    if tfid not in self.cats:
                         self.cats[tfid] = {}
-                    if not layer in self.cats[tfid]:
+                    if layer not in self.cats[tfid]:
                         self.cats[tfid][layer] = []
                     cat = int(data['Category'][idx])
                     self.cats[tfid][layer].append(cat)

+ 2 - 2
gui/wxpython/dbmgr/sqlbuilder.py

@@ -58,7 +58,7 @@ class SQLBuilder(wx.Frame):
 
         # variables
         self.vectmap = vectmap  # fullname
-        if not "@" in self.vectmap:
+        if "@" not in self.vectmap:
             self.vectmap = grass.find_file(
                 self.vectmap, element='vector')['fullname']
             if not self.vectmap:
@@ -380,7 +380,7 @@ class SQLBuilder(wx.Frame):
 
         i = 0
         items = []
-        for item in data: #sorted(set(map(lambda x: desc['ctype'](x[0]), data))):
+        for item in data: # sorted(set(map(lambda x: desc['ctype'](x[0]), data))):
             if desc['type'] not in ('character', 'text'):
                 items.append(str(item[0]))
             else:

+ 1 - 1
gui/wxpython/dbmgr/vinfo.py

@@ -149,7 +149,7 @@ class VectorDBInfo(VectorDBInfoBase):
             ret[key] = list()
 
         for record in data:
-            if not 'Table' in record:
+            if 'Table' not in record:
                 continue
 
             table = record['Table']

+ 11 - 11
gui/wxpython/gcp/manager.py

@@ -180,7 +180,7 @@ class GCPWizard(object):
         #
         if self.wizard.RunWizard(self.startpage):
             success = self.OnWizFinished()
-            if success == False:
+            if not success:
                 GMessage(parent=self.parent,
                          message=_("Georectifying setup canceled."))
                 self.Cleanup()
@@ -192,7 +192,7 @@ class GCPWizard(object):
         #
         # start GCP display
         #
-        if success != False:
+        if success:
             # instance of render.Map to be associated with display
             self.SwitchEnv('source')
             self.SrcMap = Map(gisrc=self.source_gisrc)
@@ -1304,7 +1304,7 @@ class GCP(MapFrame, ColumnSorterMixin):
 
         else:
             item.SetPropertyVal('hide', False)
-            if self.highest_only == True:
+            if self.highest_only:
                 if itemIndex == self.highest_key:
                     wxPen = "highest"
                 else:
@@ -1395,7 +1395,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                 "#-----------------------     -----------------------     ---------------\n")
 
             for index in range(self.list.GetItemCount()):
-                if self.list.IsChecked(index) == True:
+                if self.list.IsChecked(index):
                     check = "1"
                     self.GCPcount += 1
                 else:
@@ -1585,7 +1585,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         global maptype
         self.SaveGCPs(None)
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             return
 
         if maptype == 'raster':
@@ -1700,7 +1700,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                 key = self.list.GetItemData(index)
                 fwd_err = self.mapcoordlist[key][5]
 
-                if self.highest_only == True:
+                if self.highest_only:
                     self.list.SetItemTextColour(index, wx.BLACK)
                     if highest_fwd_err < fwd_err:
                         highest_fwd_err = fwd_err
@@ -1791,7 +1791,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         self.SaveGCPs(None)
         # self.SetStatusText('')
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             return
 
         # get list of forward and reverse rms error values for each point
@@ -1901,7 +1901,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         order = self.gr_order
         self.gr_order = 1
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             self.gr_order = order
             return
 
@@ -2697,7 +2697,7 @@ class GrSettingsDialog(wx.Dialog):
         self.rmsWin = TextCtrl(parent=panel, id=wx.ID_ANY,
                                size=(70, -1), style=wx.TE_NOHIDESEL)
         self.rmsWin.SetValue("%s" % str(sdfactor))
-        if (self.parent.highest_only == True):
+        if (self.parent.highest_only):
             self.rmsWin.Disable()
 
         self.symbol['sdfactor'] = self.rmsWin.GetId()
@@ -3181,7 +3181,7 @@ class GrSettingsDialog(wx.Dialog):
                 tgtrenderVector = True
 
         if tgt_map['raster'] == '' and tgt_map['vector'] == '':
-            if self.parent.show_target == True:
+            if self.parent.show_target:
                 self.parent.show_target = False
                 self.parent._mgr.GetPane("target").Hide()
                 self.parent._mgr.Update()
@@ -3189,7 +3189,7 @@ class GrSettingsDialog(wx.Dialog):
                 self.parent.activemap.Enable(False)
                 self.parent.GetMapToolbar().Enable('zoommenu', enable=False)
         else:
-            if self.parent.show_target == False:
+            if not self.parent.show_target:
                 self.parent.show_target = True
                 self.parent._mgr.GetPane("target").Show()
                 self.parent._mgr.Update()

+ 1 - 1
gui/wxpython/gcp/mapdisplay.py

@@ -278,7 +278,7 @@ class MapFrame(SingleMapFrame):
                               BottomDockable(False).TopDockable(True).
                               CloseButton(False).Layer(2))
 
-            if self.show_target == False:
+            if not self.show_target:
                 self.toolbars['gcpdisp'].Enable('zoommenu', enable=False)
 
             self.toolbars['gcpman'] = GCPManToolbar(self)

+ 1 - 1
gui/wxpython/gmodeler/model.py

@@ -2332,7 +2332,7 @@ class WriteModelFile:
                 for f in val:
                     if f.get('value', False) or f.get('parameterized', False):
                         if f.get('parameterized', False):
-                            if f.get('value', False) == False:
+                            if f.get('value', False) is False:
                                 self.fd.write(
                                     '%s<flag name="%s" value="0" parameterized="1" />\n' %
                                     (' ' *

+ 8 - 8
gui/wxpython/gui_core/forms.py

@@ -159,7 +159,7 @@ class UpdateThread(Thread):
         # get widget id
         if not self.eventId:
             for p in self.task.params:
-                if p.get('gisprompt', False) == False:
+                if p.get('gisprompt', False) is False:
                     continue
                 prompt = p.get('element', '')
                 if prompt == 'vector':
@@ -971,7 +971,7 @@ class CmdPanel(wx.Panel):
             p for p in self.task.params +
             self.task.flags if not p.get(
                 'hidden',
-                False) == True]
+                False) is True]
 
         self.label_id = []  # wrap titles on resize
 
@@ -1039,7 +1039,7 @@ class CmdPanel(wx.Panel):
         #
         visible_flags = [
             f for f in self.task.flags if not f.get(
-                'hidden', False) == True]
+                'hidden', False) is True]
         for f in visible_flags:
             # we don't want another help (checkbox appeared in r58783)
             if f['name'] == 'help':
@@ -1110,7 +1110,7 @@ class CmdPanel(wx.Panel):
         #
         visible_params = [
             p for p in self.task.params if not p.get(
-                'hidden', False) == True]
+                'hidden', False) is True]
 
         try:
             first_param = visible_params[0]
@@ -1134,7 +1134,7 @@ class CmdPanel(wx.Panel):
             # title sizer (description, name, type)
             if (len(p.get('values', [])) > 0) and \
                     p.get('multiple', False) and \
-                    p.get('gisprompt', False) == False and \
+                    p.get('gisprompt', False) is False and \
                     p.get('type', '') == 'string':
                 title_txt = StaticBox(parent=which_panel, id=wx.ID_ANY)
             else:
@@ -1178,7 +1178,7 @@ class CmdPanel(wx.Panel):
                 valuelist_desc = list(map(unicode, p.get('values_desc', [])))
                 required_text = "*" if p.get('required', False) else ""
                 if p.get('multiple', False) and \
-                        p.get('gisprompt', False) == False and \
+                        p.get('gisprompt', False) is False and \
                         p.get('type', '') == 'string':
                     title_txt.SetLabel(
                         " %s:%s  (%s=%s) " %
@@ -1317,7 +1317,7 @@ class CmdPanel(wx.Panel):
             # text entry
             if (p.get('type', 'string') in ('string', 'integer', 'float')
                     and len(p.get('values', [])) == 0
-                    and p.get('gisprompt', False) == False
+                    and p.get('gisprompt', False) is False
                     and p.get('prompt', '') != 'color'):
 
                 title_txt.SetLabel(title + ':')
@@ -2161,7 +2161,7 @@ class CmdPanel(wx.Panel):
                             p['wxId-bind'] = list()
                         p['wxId-bind'] += pOpt['wxId']
                 continue
-            if p.get('gisprompt', False) == False:
+            if p.get('gisprompt', False) is False:
                 continue
 
             prompt = p.get('prompt', '')

+ 5 - 5
gui/wxpython/gui_core/gselect.py

@@ -2418,9 +2418,9 @@ class CoordinatesSelect(Panel):
         if self.buttonInsCoords.GetToggle() and self.mapWin:
             switcher = self._giface.GetMapDisplay().GetToolSwitcher()
             switcher.ToolChanged(self.buttonInsCoords.GetId())
-            if self.mapWin.RegisterMouseEventHandler(wx.EVT_LEFT_DOWN,
-                                                     self._onMapClickHandler,
-                                                     'cross') == False:
+            if not self.mapWin.RegisterMouseEventHandler(wx.EVT_LEFT_DOWN,
+                                                         self._onMapClickHandler,
+                                                         'cross'):
                 return
 
             self.registered = True
@@ -2591,8 +2591,8 @@ class VectorCategorySelect(wx.Panel):
 
                 self._vectorSelect = VectorSelectBase(
                     self.mapdisp, self.giface)
-                if self.mapdisp.GetWindow().RegisterMouseEventHandler(
-                        wx.EVT_LEFT_DOWN, self._onMapClickHandler, 'cross') == False:
+                if not self.mapdisp.GetWindow().RegisterMouseEventHandler(
+                        wx.EVT_LEFT_DOWN, self._onMapClickHandler, 'cross'):
                     return
                 self.registered = True
                 self.mapdisp.Raise()

+ 1 - 1
gui/wxpython/gui_core/toolbars.py

@@ -309,7 +309,7 @@ class ToolSwitcher:
 
         :param tool: id of the button
         """
-        if not tool in self._toolsGroups:
+        if tool not in self._toolsGroups:
             return
         for group in self._toolsGroups[tool]:
             self._groups[group]['custom'] = \

+ 1 - 1
gui/wxpython/gui_core/treeview.py

@@ -263,7 +263,7 @@ class TreeFrame(wx.Frame):
         szr.SetSizeHints(self)
 
     def OnSelChanged(self):
-        print('selected items: ' + \
+        print('selected items: ' +
               str([node.label for node in self.tree.GetSelected()]))
 
     def OnItemActivated(self, node):

+ 0 - 3
gui/wxpython/iclass/dialogs.py

@@ -571,9 +571,6 @@ class CategoryListCtrl(ListCtrl,
         return -1
 
     def OnGetItemAttr(self, item):
-        return None
-
-    def OnGetItemAttr(self, item):
         """Set correct class color for a item"""
         back_c = wx.Colour(*map(int, self.OnGetItemText(item, 1).split(':')))
         text_c = wx.Colour(*ContrastColor(back_c))

+ 0 - 1
gui/wxpython/iclass/frame.py

@@ -50,7 +50,6 @@ from gui_core.dialogs import SetOpacityDialog
 from gui_core.wrap import Menu
 from mapwin.base import MapWindowProperties
 from dbmgr.vinfo import VectorDBInfo
-import grass.script as grass
 
 from iclass.digit import IClassVDigitWindow, IClassVDigit
 from iclass.toolbars    import IClassMapToolbar, IClassMiscToolbar,\

+ 11 - 11
gui/wxpython/image2target/ii2t_manager.py

@@ -209,7 +209,7 @@ class GCPWizard(object):
         #
         if self.wizard.RunWizard(self.startpage):
             success = self.OnWizFinished()
-            if success == False:
+            if not success:
                 GMessage(parent=self.parent,
                          message=_("Georectifying setup canceled."))
                 self.Cleanup()
@@ -221,7 +221,7 @@ class GCPWizard(object):
         #
         # start GCP display
         #
-        if success != False:
+        if success:
             # instance of render.Map to be associated with display
             self.SwitchEnv('source')
             self.SrcMap = Map(gisrc=self.source_gisrc)
@@ -1336,7 +1336,7 @@ class GCP(MapFrame, ColumnSorterMixin):
 
         else:
             item.SetPropertyVal('hide', False)
-            if self.highest_only == True:
+            if self.highest_only:
                 if itemIndex == self.highest_key:
                     wxPen = "highest"
                 else:
@@ -1453,7 +1453,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                 "#----------------------------     ---------------------------     ---------------\n")
 
             for index in range(self.list.GetItemCount()):
-                if self.list.IsChecked(index) == True:
+                if self.list.IsChecked(index):
                     check = "1"
                     self.GCPcount += 1
                 else:
@@ -1651,7 +1651,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         global maptype
         self.SaveGCPs(None)
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             return
 
         if maptype == 'raster':
@@ -1767,7 +1767,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                 key = self.list.GetItemData(index)
                 fwd_err = self.mapcoordlist[key][5]
 
-                if self.highest_only == True:
+                if self.highest_only:
                     self.list.SetItemTextColour(index, wx.BLACK)
                     if highest_fwd_err < fwd_err:
                         highest_fwd_err = fwd_err
@@ -1857,7 +1857,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         self.SaveGCPs(None)
         # self.SetStatusText('')
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             return
 
         # get list of forward and reverse rms error values for each point
@@ -1966,7 +1966,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         order = self.gr_order
         self.gr_order = 1
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             self.gr_order = order
             return
 
@@ -2771,7 +2771,7 @@ class GrSettingsDialog(wx.Dialog):
         self.rmsWin = TextCtrl(parent=panel, id=wx.ID_ANY,
                                size=(70, -1), style=wx.TE_NOHIDESEL)
         self.rmsWin.SetValue("%s" % str(sdfactor))
-        if (self.parent.highest_only == True):
+        if (self.parent.highest_only):
             self.rmsWin.Disable()
 
         self.symbol['sdfactor'] = self.rmsWin.GetId()
@@ -3255,7 +3255,7 @@ class GrSettingsDialog(wx.Dialog):
                 tgtrenderVector = True
 
         if tgt_map['raster'] == '' and tgt_map['vector'] == '':
-            if self.parent.show_target == True:
+            if self.parent.show_target:
                 self.parent.show_target = False
                 self.parent._mgr.GetPane("target").Hide()
                 self.parent._mgr.Update()
@@ -3263,7 +3263,7 @@ class GrSettingsDialog(wx.Dialog):
                 self.parent.activemap.Enable(False)
                 self.parent.GetMapToolbar().Enable('zoommenu', enable=False)
         else:
-            if self.parent.show_target == False:
+            if not self.parent.show_target:
                 self.parent.show_target = True
                 self.parent._mgr.GetPane("target").Show()
                 self.parent._mgr.Update()

+ 1 - 1
gui/wxpython/image2target/ii2t_mapdisplay.py

@@ -278,7 +278,7 @@ class MapFrame(SingleMapFrame):
                               BottomDockable(False).TopDockable(True).
                               CloseButton(False).Layer(2))
 
-            if self.show_target == False:
+            if not self.show_target:
                 self.toolbars['gcpdisp'].Enable('zoommenu', enable=False)
 
             self.toolbars['gcpman'] = GCPManToolbar(self)

+ 2 - 2
gui/wxpython/iscatt/controllers.py

@@ -976,7 +976,7 @@ class IMapDispConnection:
 
     def RenderCatRast(self, cat_id):
 
-        if not cat_id in six.iterkeys(self.added_cats_rasts):
+        if cat_id not in six.iterkeys(self.added_cats_rasts):
             cat_rast = self.scatt_mgr.core.GetCatRast(cat_id)
 
             cat_name = self.cats_mgr.GetCategoryAttrs(cat_id)['name']
@@ -1053,7 +1053,7 @@ class IClassConnection:
     def RenderCatRast(self, cat_id):
 
         train_mgr, preview_mgr = self.iclass_frame.GetMapManagers()
-        if not cat_id in self.added_cats_rasts:
+        if cat_id not in self.added_cats_rasts:
             cat_rast = self.scatt_mgr.core.GetCatRast(cat_id)
 
             cat_name = self.cats_mgr.GetCategoryAttrs(cat_id)['name']

+ 0 - 1
gui/wxpython/iscatt/frame.py

@@ -408,7 +408,6 @@ class ScatterPlotsPanel(scrolled.ScrolledPanel):
 
 class CategoryListCtrl(ListCtrl,
                        listmix.ListCtrlAutoWidthMixin):
-                       # listmix.TextEditMixin):
 
     def __init__(self, parent, cats_mgr, sel_cats_in_iscatt, id=wx.ID_ANY):
 

+ 0 - 1
gui/wxpython/iscatt/toolbars.py

@@ -17,7 +17,6 @@ import wx
 
 from icons.icon import MetaIcon
 from gui_core.toolbars import BaseToolbar, BaseIcons
-from core.gcmd import RunCommand
 from core.gcmd import GException, GError, RunCommand
 from iscatt.iscatt_core import idBandsToidScatt
 from iscatt.dialogs import SettingsDialog

+ 2 - 2
gui/wxpython/lmgr/layertree.py

@@ -1342,7 +1342,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
 
         selectedLayer = self.GetSelectedLayer()
         # deselect active item
-        if lchecked != False and selectedLayer:
+        if lchecked is not False and selectedLayer:
             self.SelectItem(selectedLayer, select=False)
 
         Debug.msg(3, "LayerTree().AddLayer(): ltype=%s" % (ltype))
@@ -1509,7 +1509,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                                    None))
 
         # select new item
-        if lchecked != False:
+        if lchecked is not False:
             self.SelectItem(layer, select=True)
 
         # use predefined layer name if given

+ 2 - 3
gui/wxpython/location_wizard/dialogs.py

@@ -688,13 +688,12 @@ class SelectTransformDialog(wx.Dialog):
 
 
 def testRegionDef():
-    import sys
     import wx.lib.inspection
-    import grass.script as grass
+    import grass.script as gscript
 
     app = wx.App()
 
-    dlg = RegionDef(None, location=grass.gisenv()["LOCATION_NAME"])
+    dlg = RegionDef(None, location=gscript.gisenv()["LOCATION_NAME"])
     dlg.Show()
     wx.lib.inspection.InspectionTool().Show()
     app.MainLoop()

+ 3 - 3
gui/wxpython/location_wizard/wizard.py

@@ -803,7 +803,7 @@ class ProjParamsPage(TitledPage):
                                         label=_("Ellipsoid only"))
 
         # default button setting
-        if self.radio1.GetValue() == False and self.radioEpsg.GetValue() == False:
+        if self.radio1.GetValue() is False and self.radioEpsg.GetValue() is False:
             self.radio1.SetValue(True)
             self.SetNext(self.parent.datumpage)
             #            self.parent.sumpage.SetPrev(self.parent.datumpage)
@@ -850,7 +850,7 @@ class ProjParamsPage(TitledPage):
             self.p4projparams = ''
             for id, param in six.iteritems(self.pparam):
                 if param['type'] == 'bool':
-                    if param['value'] == False:
+                    if param['value'] is False:
                         continue
                     else:
                         self.p4projparams += (' +' + param['proj4'])
@@ -2563,7 +2563,7 @@ class LocationWizard(wx.Object):
         current_gdb = decode(grass.gisenv()['GISDBASE'])
         if current_gdb != database:
             # change to new GISDbase or create new one
-            if os.path.isdir(database) != True:
+            if not os.path.isdir(database):
                 # create new directory
                 try:
                     os.mkdir(database)

+ 1 - 1
gui/wxpython/mapdisp/statusbar.py

@@ -48,7 +48,7 @@ class SbException(Exception):
     """Exception class used in SbManager and SbItems"""
 
     def __init__(self, message):
-#        Exception.__init__(self, message)
+        # Exception.__init__(self, message)
         self.message = message
 
     def __str__(self):

+ 2 - 2
gui/wxpython/mapwin/buffered.py

@@ -1597,8 +1597,8 @@ class BufferedMapWindow(MapWindowBase, Window):
             # redraw map
             self.UpdateMap(render=False)
 
-       # TODO: decide which coordinates to send (e, n, mouse['begin'],
-       # mouse['end'])
+        # TODO: decide which coordinates to send (e, n, mouse['begin'],
+        # mouse['end'])
         self.mouseLeftUp.emit(x=coordinates[0], y=coordinates[1])
 
     def OnButtonDClick(self, event):

+ 1 - 1
gui/wxpython/mapwin/graphics.py

@@ -414,7 +414,7 @@ class GraphicsSetItem:
         :param propName - name of the newly defined property
         :type propName: str
         """
-        if not propName in self.properties:
+        if propName not in self.properties:
             self.properties[propName] = None
 
     def SetPropertyVal(self, propName, propVal):

+ 1 - 1
gui/wxpython/modules/colorrules.py

@@ -1614,7 +1614,7 @@ class VectorColorTable(ColorTable):
                 colvallist.append(col1)
                 i += 1
 
-            if i > limit and readvals == False:
+            if i > limit and readvals is False:
                 dlg = wx.MessageDialog(parent=self, message=_(
                     "Number of loaded records reached %d, "
                     "displaying all the records will be time-consuming "

+ 0 - 8
gui/wxpython/modules/import_export.py

@@ -780,14 +780,6 @@ class DxfImportDialog(ImportDialog):
 
         self.doLayout()
 
-    def _getCommand(self):
-        """Get command"""
-        return 'v.in.dxf'
-
-    def _getBlackListedParameters(self):
-
-        return ['input', 'output', 'layers']
-
     def OnRun(self, event):
         """Import/Link data (each layes as separate vector map)"""
         data = self.list.GetLayers()

+ 1 - 1
gui/wxpython/nviz/mapwindow.py

@@ -1424,7 +1424,7 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
             except ValueError:
                 continue
             if key == 'color':
-                if not ':' in value:
+                if ':' not in value:
                     value = ':'.join(map(str, str2rgb[value]))
                 data['lines']['color']['value'] = value
                 data['points']['color']['value'] = value

+ 2 - 2
gui/wxpython/nviz/tools.py

@@ -53,7 +53,7 @@ from core.settings import UserSettings
 from gui_core.widgets import ScrolledPanel, NumTextCtrl, FloatSlider, SymbolButton
 from gui_core.gselect import Select
 from gui_core.wrap import Window, SpinCtrl, PseudoDC, ToggleButton, Button, \
-    TextCtrl, ToggleButton, StaticText, StaticBox, CheckListBox, ColourSelect
+    TextCtrl, StaticText, StaticBox, CheckListBox, ColourSelect
 from core.debug import Debug
 try:
     from nviz.mapwindow import wxUpdateProperties, wxUpdateView,\
@@ -2753,7 +2753,7 @@ class NvizToolWindow(FN.FlatNotebook):
         data['constant']['transp'] = self._getPercent(
             data['constant']['transp'], toPercent=False)
 
-       # update properties
+        # update properties
         event = wxUpdateProperties(data=data)
         wx.PostEvent(self.mapWindow, event)
         if self.mapDisplay.IsAutoRendered():

+ 10 - 10
gui/wxpython/photo2image/ip2i_manager.py

@@ -376,7 +376,7 @@ class GCP(MapFrame, ColumnSorterMixin):
             GMessage (_("A POINTS file exists, renaming it to POINTS_BAK"))
 
         #"""Make a POINTS file """
-        import re,sys
+        import re
         try:
             fc = open(self.file['camera'], mode='r')
             fc_count=0
@@ -720,7 +720,7 @@ class GCP(MapFrame, ColumnSorterMixin):
 
         else:
             item.SetPropertyVal('hide', False)
-            if self.highest_only == True:
+            if self.highest_only:
                 if itemIndex == self.highest_key:
                     wxPen = "highest"
                 else:
@@ -811,7 +811,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                 "#-----------------------     -----------------------     ---------------\n")
 
             for index in range(self.list.GetItemCount()):
-                if self.list.IsChecked(index) == True:
+                if self.list.IsChecked(index):
                     check = "1"
                     self.GCPcount += 1
                 else:
@@ -1002,7 +1002,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         global maptype
         self.SaveGCPs(None)
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             return
 
         if maptype == 'raster':
@@ -1084,7 +1084,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                 key = self.list.GetItemData(index)
                 fwd_err = self.mapcoordlist[key][5]
 
-                if self.highest_only == True:
+                if self.highest_only:
                     self.list.SetItemTextColour(index, wx.BLACK)
                     if highest_fwd_err < fwd_err:
                         highest_fwd_err = fwd_err
@@ -1171,7 +1171,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         self.SaveGCPs(None)
         # self.SetStatusText('')
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             return
 
         # get list of forward and reverse rms error values for each point
@@ -1281,7 +1281,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         order = self.gr_order
         self.gr_order = 1
 
-        if self.CheckGCPcount(msg=True) == False:
+        if not self.CheckGCPcount(msg=True):
             self.gr_order = order
             return
 
@@ -1937,7 +1937,7 @@ class GrSettingsDialog(wx.Dialog):
         self.rmsWin = TextCtrl(parent=panel, id=wx.ID_ANY,
                                size=(70, -1), style=wx.TE_NOHIDESEL)
         self.rmsWin.SetValue("%s" % str(sdfactor))
-        if (self.parent.highest_only == True):
+        if (self.parent.highest_only):
             self.rmsWin.Disable()
 
         self.symbol['sdfactor'] = self.rmsWin.GetId()
@@ -2378,7 +2378,7 @@ class GrSettingsDialog(wx.Dialog):
                 tgtrender = True
 
         if tgt_map['raster'] == '':
-            if self.parent.show_target == True:
+            if self.parent.show_target:
                 self.parent.show_target = False
                 self.parent._mgr.GetPane("target").Hide()
                 self.parent._mgr.Update()
@@ -2386,7 +2386,7 @@ class GrSettingsDialog(wx.Dialog):
                 self.parent.activemap.Enable(False)
                 self.parent.GetMapToolbar().Enable('zoommenu', enable=False)
         else:
-            if self.parent.show_target == False:
+            if not self.parent.show_target:
                 self.parent.show_target = True
                 self.parent._mgr.GetPane("target").Show()
                 self.parent._mgr.Update()

+ 1 - 1
gui/wxpython/photo2image/ip2i_mapdisplay.py

@@ -277,7 +277,7 @@ class MapFrame(SingleMapFrame):
                               BottomDockable(False).TopDockable(True).
                               CloseButton(False).Layer(2))
 
-            if self.show_target == False:
+            if self.show_target is False:
                 self.toolbars['gcpdisp'].Enable('zoommenu', enable=False)
 
             self.toolbars['gcpman'] = GCPManToolbar(self)

+ 2 - 2
gui/wxpython/psmap/dialogs.py

@@ -4293,7 +4293,7 @@ class LegendDialog(PsmapDialog):
             self.vLegendDict['vLegend'] = False
         else:
             self.vLegendDict['vLegend'] = True
-        if self.vLegendDict['vLegend'] == True and self.vectorId is not None:
+        if self.vLegendDict['vLegend'] and self.vectorId is not None:
             # labels
             # reindex order
             idx = 1
@@ -5663,7 +5663,7 @@ class TextDialog(PsmapDialog):
             self.textDict['rotate'] = None
         # reference point
         for radio in self.radio:
-            if radio.GetValue() == True:
+            if radio.GetValue():
                 self.textDict['ref'] = radio.GetName()
 
         if self.id not in self.instruction:

+ 0 - 1
gui/wxpython/psmap/utils.py

@@ -472,7 +472,6 @@ def GhostscriptForWindows(tile, size, fp):
     length, bbox = data
 
     import tempfile
-    import os
 
     file = tempfile.mkstemp()[1]
 

+ 3 - 3
gui/wxpython/tools/build_modules_xml.py

@@ -121,13 +121,13 @@ def doc_test():
 
 def module_test():
     grass_commands = gcore.get_commands()[0]
-    if not 'g.region' in grass_commands:
+    if 'g.region' not in grass_commands:
         print("No g.region")
         return 1
-    if not 'm.proj' in grass_commands:
+    if 'm.proj' not in grass_commands:
         print("No m.proj")
         return 1
-    if not 't.rast.univar' in grass_commands:
+    if 't.rast.univar' not in grass_commands:
         print("No t.rast.univar")
         return 1
     print(get_module_metadata('g.region'))

+ 1 - 1
gui/wxpython/vdigit/toolbars.py

@@ -1090,7 +1090,7 @@ class VDigitToolbar(BaseToolbar):
                                                mapset=grass.gisenv()['MAPSET'])
 
         for layer in self.layers:
-            if not layer.name in layerNameList:  # do not duplicate layer
+            if layer.name not in layerNameList:  # do not duplicate layer
                 layerNameList.append(layer.GetName())
 
         if updateTool:  # update toolbar

+ 1 - 1
gui/wxpython/vdigit/wxdisplay.py

@@ -1021,7 +1021,7 @@ class DisplayDriver:
         ret = open_fn(self.poMapInfo, name, mapset)
 
         if ret == -1:
-             # fatal error detected
+            # fatal error detected
             del self.mapInfo
             self.poMapInfo = self.mapInfo = None
         elif ret < 2:

+ 1 - 1
gui/wxpython/vnet/dialogs.py

@@ -836,7 +836,7 @@ class VNETDialog(wx.Dialog):
 
     def OnDefIsecTurnCosts(self, event):
         """Registers/unregisters mouse handler into map window"""
-        if self.defIsecTurnsHndlrReg == False:
+        if not self.defIsecTurnsHndlrReg:
             self.mapWin.RegisterMouseEventHandler(wx.EVT_LEFT_DOWN,
                                                   self.OnDefIsecTurnCost,
                                                   'cross')

+ 2 - 2
gui/wxpython/web_services/widgets.py

@@ -298,7 +298,7 @@ class WSPanel(wx.Panel):
         self.params['maxrows'].SetValue(val)
 
         self.flags['o'] = self.params['bgcolor'] = None
-        if not 'o' in self.drv_props['ignored_flags']:
+        if 'o' not in self.drv_props['ignored_flags']:
             self.flags['o'] = wx.CheckBox(
                 parent=adv_setts_panel, id=wx.ID_ANY,
                 label=_("Do not request transparent data"))
@@ -713,7 +713,7 @@ class WSPanel(wx.Panel):
         i_method = self.params['method'].GetSelection()
         lcmd.append('method=' + self.reproj_methods[i_method])
 
-        if not 'o' in self.drv_props['ignored_flags'] and \
+        if 'o' not in self.drv_props['ignored_flags'] and \
                 self.flags['o'].IsChecked():
             lcmd.append('-o')
 

+ 2 - 2
gui/wxpython/wxplot/base.py

@@ -376,10 +376,10 @@ class BasePlotFrame(wx.Frame):
         else:
             self.properties['y-axis']['axis'] = None
 
-        if self.properties['x-axis']['prop']['log'] == True:
+        if self.properties['x-axis']['prop']['log']:
             self.properties['x-axis']['axis'] = None
             self.client.xSpec = 'min'
-        if self.properties['y-axis']['prop']['log'] == True:
+        if self.properties['y-axis']['prop']['log']:
             self.properties['y-axis']['axis'] = None
             self.client.ySpec = 'min'
 

+ 2 - 2
gui/wxpython/wxplot/dialogs.py

@@ -469,7 +469,7 @@ class HistRasterDialog(wx.Dialog):
         self.rselection = Select(self, id=wx.ID_ANY,
                                  size=globalvar.DIALOG_GSELECT_SIZE,
                                  type='cell')
-        if self.groupRadio.GetValue() == True:
+        if self.groupRadio.GetValue():
             self.rselection.Disable()
         else:
             rastText = ''
@@ -488,7 +488,7 @@ class HistRasterDialog(wx.Dialog):
         self.gselection = Select(self, id=wx.ID_ANY,
                                  size=globalvar.DIALOG_GSELECT_SIZE,
                                  type='group')
-        if self.rasterRadio.GetValue() == True:
+        if self.rasterRadio.GetValue():
             self.gselection.Disable()
         else:
             if self.group is not None:

+ 1 - 1
gui/wxpython/wxplot/scatter.py

@@ -260,7 +260,7 @@ class ScatterFrame(BasePlotFrame):
         title = _('Regression Statistics for Scatterplot(s)')
 
         for rpair in self.rasterList:
-            if isinstance(rpair, tuple) == False:
+            if not isinstance(rpair, tuple):
                 continue
             rast1, rast2 = rpair
             rast1 = rast1.split('@')[0]