Bläddra i källkod

wxGUI loc wizard: Correct errors according to flake 8 in wizard.py (#728)

* wxGUI/Location Wizard: Corrected errors according to flake8 (errors E402,E821,E722 ignored).

Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Linda Kladivova 4 år sedan
förälder
incheckning
cade4ace98
1 ändrade filer med 80 tillägg och 85 borttagningar
  1. 80 85
      gui/wxpython/location_wizard/wizard.py

+ 80 - 85
gui/wxpython/location_wizard/wizard.py

@@ -56,7 +56,6 @@ from core.gcmd import RunCommand, GError, GMessage, GWarning
 from gui_core.widgets import GenericValidator
 from gui_core.wrap import SpinCtrl, SearchCtrl, StaticText, \
     TextCtrl, Button, CheckBox, StaticBox, NewId, ListCtrl, HyperlinkCtrl
-from location_wizard.base import BaseClass
 from location_wizard.dialogs import SelectTransformDialog
 
 from grass.script import decode
@@ -90,7 +89,6 @@ class TitledPage(WizardPageSimple):
 
     def DoLayout(self):
         """Do page layout"""
-        
         self.pagesizer.Add(self.title, proportion=0,
                            flag=wx.EXPAND | wx.ALL,
                            border=5)
@@ -110,7 +108,7 @@ class TitledPage(WizardPageSimple):
         if not parent:
             parent = self
         label = StaticText(parent=parent, id=wx.ID_ANY, label=text,
-                              style=style)
+                           style=style)
         if tooltip:
             label.SetToolTip(tooltip)
         return label
@@ -121,7 +119,7 @@ class TitledPage(WizardPageSimple):
         if not parent:
             parent = self
         textCtrl = TextCtrl(parent=parent, id=wx.ID_ANY, value=text,
-                               size=size, style=style)
+                            size=size, style=style)
         if tooltip:
             textCtrl.SetToolTip(tooltip)
         return textCtrl
@@ -132,7 +130,7 @@ class TitledPage(WizardPageSimple):
         if not parent:
             parent = self
         button = Button(parent=parent, id=id, label=text,
-                           size=size)
+                        size=size)
         if tooltip:
             button.SetToolTip(tooltip)
         return button
@@ -143,7 +141,7 @@ class TitledPage(WizardPageSimple):
         if not parent:
             parent = self
         chbox = CheckBox(parent=parent, id=id, label=text,
-                            size=size)
+                         size=size)
         if tooltip:
             chbox.SetToolTip(tooltip)
         return chbox
@@ -156,18 +154,21 @@ class DatabasePage(TitledPage):
         TitledPage.__init__(self, wizard, _(
             "Define new GRASS Location"))
 
+        # grid definition
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
+        # definition of variables
         self.grassdatabase = grassdatabase
         self.location = ''
         self.locTitle = ''
-        
+
+        # browse button
         self.bbrowse = self.MakeButton(_("Change"))
 
         # text controls
-        self.tgisdbase = self.MakeLabel(grassdatabase)    
+        self.tgisdbase = self.MakeLabel(grassdatabase)
         self.tlocation = self.MakeTextCtrl("newLocation", size=(400, -1))
         self.tlocation.SetFocus()
         self.tlocation.SetValidator(
@@ -175,17 +176,18 @@ class DatabasePage(TitledPage):
                 grass.legal_name,
                 self._nameValidationFailed))
         self.tlocTitle = self.MakeTextCtrl(size=(400, -1))
-        
+
         # text for required options
         required_txt = self.MakeLabel("*")
         required_txt.SetForegroundColour(wx.RED)
         required_txt.SetToolTip(_("This option is required"))
-        
+
         # text for optional options
         optional_txt = self.MakeLabel(_("(optional)"))
         italics = wx.Font(10, wx.DEFAULT, wx.ITALIC, wx.NORMAL)
         optional_txt.SetFont(italics)
-        optional_txt.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
+        optional_txt.SetForegroundColour(wx.SystemSettings.GetColour(
+                                         wx.SYS_COLOUR_GRAYTEXT))
 
         # layout
         self.sizer.Add(
@@ -228,7 +230,7 @@ class DatabasePage(TitledPage):
                        wx.ALIGN_CENTER_VERTICAL |
                        wx.ALL, border=5,
                        pos=(4, 2))
-        
+
         self.sizer.Add(self.MakeLabel(_("Location will be created in GRASS database:")),
                        flag=wx.ALIGN_LEFT |
                        wx.ALIGN_CENTER_VERTICAL |
@@ -273,7 +275,7 @@ class DatabasePage(TitledPage):
             nextButton.Disable()
 
         event.Skip()
-        
+
     def OnBrowse(self, event):
         """Choose GRASS data directory"""
         dlg = wx.DirDialog(self, _("Choose GRASS data directory:"),
@@ -319,18 +321,18 @@ class CoordinateSystemPage(TitledPage):
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _(
             "Select Coordinate Reference System (CRS)"))
-        
+
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
         self.parent = parent
         global coordsys
 
         # toggles
         self.radioEpsg = wx.RadioButton(parent=self, id=wx.ID_ANY, label=_(
             "Select CRS from a list by EPSG or description"), style=wx.RB_GROUP)
-        #self.radioIau = wx.RadioButton(
+        # self.radioIau = wx.RadioButton(
         #    parent=self, id=wx.ID_ANY,
         #    label=_("Select IAU code of spatial reference system"))
         self.radioFile = wx.RadioButton(
@@ -351,7 +353,7 @@ class CoordinateSystemPage(TitledPage):
         self.sizer.SetVGap(10)
         self.sizer.Add(self.radioEpsg,
                        flag=wx.ALIGN_LEFT, pos=(1, 1))
-        #self.sizer.Add(self.radioIau,
+        # self.sizer.Add(self.radioIau,
         #               flag=wx.ALIGN_LEFT, pos=(1, 1))
         self.sizer.Add(self.radioFile,
                        flag=wx.ALIGN_LEFT, pos=(2, 1))
@@ -369,7 +371,7 @@ class CoordinateSystemPage(TitledPage):
 
         # bindings
         self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radioEpsg.GetId())
-        #self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radioIau.GetId())
+        # self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radioIau.GetId())
         self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radioFile.GetId())
         self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radioWkt.GetId())
         self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radioSrs.GetId())
@@ -388,7 +390,7 @@ class CoordinateSystemPage(TitledPage):
                 self.radioSrs.SetValue(True)
             if coordsys == "epsg":
                 self.radioEpsg.SetValue(True)
-            #if coordsys == "iau":
+            # if coordsys == "iau":
             #    self.radioIau.SetValue(True)
             if coordsys == "file":
                 self.radioFile.SetValue(True)
@@ -406,7 +408,7 @@ class CoordinateSystemPage(TitledPage):
             if coordsys == "epsg":
                 self.SetNext(self.parent.epsgpage)
                 self.parent.sumpage.SetPrev(self.parent.epsgpage)
-            #if coordsys == "iau":
+            # if coordsys == "iau":
             #    self.SetNext(self.parent.iaupage)
             #    self.parent.sumpage.SetPrev(self.parent.iaupage)
             if coordsys == "file":
@@ -432,7 +434,7 @@ class CoordinateSystemPage(TitledPage):
             coordsys = "proj"
             self.SetNext(self.parent.projpage)
             self.parent.sumpage.SetPrev(self.parent.datumpage)
-        #elif event.GetId() == self.radioIau.GetId():
+        # elif event.GetId() == self.radioIau.GetId():
         #    coordsys = "iau"
         #    self.SetNext(self.parent.iaupage)
         #    self.parent.sumpage.SetPrev(self.parent.iaupage)
@@ -463,11 +465,11 @@ class ProjectionsPage(TitledPage):
 
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Define custom CRS"))
-        
+
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
         self.parent = parent
         self.proj = ''
         self.projdesc = ''
@@ -555,7 +557,6 @@ class ProjectionsPage(TitledPage):
 
     def OnSearch(self, event):
         """Search projection by desc"""
-        str = event.GetString()
         try:
             self.proj, self.projdesc = self.projlist.Search(
                 index=[0, 1], pattern=event.GetString())
@@ -582,12 +583,12 @@ class ItemList(ListCtrl,
 
     def __init__(self, parent, columns, data=None):
         ListCtrl.__init__(self, parent=parent, id=wx.ID_ANY,
-                             style=wx.LC_REPORT |
-                             wx.LC_VIRTUAL |
-                             wx.LC_HRULES |
-                             wx.LC_VRULES |
-                             wx.LC_SINGLE_SEL |
-                             wx.LC_SORT_ASCENDING, size=(550, 125))
+                          style=wx.LC_REPORT |
+                          wx.LC_VIRTUAL |
+                          wx.LC_HRULES |
+                          wx.LC_VRULES |
+                          wx.LC_SINGLE_SEL |
+                          wx.LC_SORT_ASCENDING, size=(550, 125))
 
         # original data or None
         self.sourceData = data
@@ -727,7 +728,6 @@ class ItemList(ListCtrl,
         self.Refresh()
 
     def Sorter(self, key1, key2):
-        colName = self.GetColumn(self._col).GetText()
         ascending = self._colSortFlag[self._col]
         # convert always string
         item1 = self.itemDataMap[key1][self._col]
@@ -799,7 +799,7 @@ class ProjParamsPage(TitledPage):
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
         self.parent = parent
         self.panel = None
         self.prjParamSizer = None
@@ -1010,7 +1010,7 @@ class DatumPage(TitledPage):
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
         self.parent = parent
         self.datum = ''
         self.datumdesc = ''
@@ -1080,7 +1080,8 @@ class DatumPage(TitledPage):
                 event.Veto()
             else:
                 # check for datum tranforms
-                #                proj4string = self.parent.CreateProj4String() + ' +datum=%s' % self.datum
+                #                proj4string = self.parent.CreateProj4String()
+                #                + ' +datum=%s' % self.datum
                 ret = RunCommand('g.proj',
                                  read=True,
                                  proj4='%s' % proj,
@@ -1171,7 +1172,6 @@ class DatumPage(TitledPage):
     def OnDatumSelected(self, event):
         """Datum selected"""
         index = event.GetIndex()
-        item = event.GetItem()
 
         self.datum = self.datumlist.GetItem(index, 0).GetText()
         self.tdatum.SetValue(self.datum)
@@ -1184,11 +1184,11 @@ class EllipsePage(TitledPage):
 
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Specify ellipsoid"))
-        
+
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
         self.parent = parent
 
         self.ellipse = ''
@@ -1334,7 +1334,6 @@ class EllipsePage(TitledPage):
     def OnItemSelected(self, event):
         """Ellipsoid selected"""
         index = event.GetIndex()
-        item = event.GetItem()
 
         self.ellipse = self.ellipselist.GetItem(index, 0).GetText()
         self.tellipse.SetValue(self.ellipse)
@@ -1363,11 +1362,12 @@ class GeoreferencedFilePage(TitledPage):
 
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Read CRS from a georeferenced data file"))
-        
+
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
+        # create variables
         self.georeffile = ''
 
         # create controls
@@ -1441,11 +1441,11 @@ class WKTPage(TitledPage):
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _(
             "Specify CRS using WKT string"))
-        
+
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
         self.wktstring = ''
         self.parent = parent
 
@@ -1501,12 +1501,13 @@ class EPSGPage(TitledPage):
 
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Select CRS from a list"))
-        
+
         self.sizer = wx.BoxSizer(wx.VERTICAL)  
         searchBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
         epsglistBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
         informationBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
-        
+
+        # definition of variables
         self.parent = parent
         self.epsgCodeDict = {}
         self.epsgcode = None
@@ -1523,7 +1524,7 @@ class EPSGPage(TitledPage):
 
         # search box
         self.searchb = SearchCtrl(self, size=(-1, 30),
-                                  style=wx.TE_PROCESS_ENTER)        
+                                  style=wx.TE_PROCESS_ENTER)
         self.epsglist = ItemList(
             self,
             data=None,
@@ -1534,7 +1535,7 @@ class EPSGPage(TitledPage):
 
         # epsg.io hyperlink
         self.tlink = HyperlinkCtrl(
-            self, id=wx.ID_ANY, 
+            self, id=wx.ID_ANY,
             label="epsg.io",
             url="https://epsg.io/")
         self.tlink.SetNormalColour(
@@ -1543,30 +1544,28 @@ class EPSGPage(TitledPage):
         self.tlink.SetVisitedColour(
             wx.SystemSettings.GetColour(
                 wx.SYS_COLOUR_GRAYTEXT))
-        
-        # layout       
+
+        # layout
         searchBoxSizer.Add(self.lcode, proportion=0,
-                       flag=wx.ALIGN_CENTER_VERTICAL |
-                       wx.ALL, border=5)
+                           flag=wx.ALIGN_CENTER_VERTICAL |
+                           wx.ALL, border=5)
         searchBoxSizer.Add(self.searchb, proportion=1,
-                       flag=wx.ALL |
-                       wx.EXPAND, border=5)
+                           flag=wx.ALL |
+                           wx.EXPAND, border=5)
         epsglistBoxSizer.Add(self.epsglist, proportion=1,
-                       flag=wx.ALL |
-                       wx.EXPAND, border=5)
-        informationBoxSizer.AddStretchSpacer(1) 
-        informationBoxSizer.Add(self.llink,  proportion=0,
-                       flag=wx.ALIGN_CENTER_VERTICAL |
-                       wx.RIGHT, border=5)
+                             flag=wx.ALL |
+                             wx.EXPAND, border=5)
+        informationBoxSizer.AddStretchSpacer(1)
+        informationBoxSizer.Add(self.llink, proportion=0,
+                                flag=wx.ALIGN_CENTER_VERTICAL |
+                                wx.RIGHT, border=5)
         informationBoxSizer.Add(self.tlink, proportion=0,
-                       flag=wx.ALIGN_CENTER_VERTICAL)
-
-        
+                                flag=wx.ALIGN_CENTER_VERTICAL)
         self.sizer.Add(searchBoxSizer, proportion=0, flag=wx.EXPAND)
         self.sizer.Add(epsglistBoxSizer, proportion=1, flag=wx.EXPAND)
         self.sizer.Add(informationBoxSizer, proportion=0,
                        flag=wx.EXPAND | wx.TOP, border=5)
-        
+
         # events
         self.searchb.Bind(wx.EVT_TEXT, self.OnTextChange)
         self.epsglist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected)
@@ -1694,11 +1693,13 @@ class IAUPage(TitledPage):
 
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Choose IAU Code"))
-        
+
+        # grid definition
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
+        # definition of variables
         self.parent = parent
         self.epsgCodeDict = {}
         self.epsgcode = None
@@ -1712,6 +1713,7 @@ class IAUPage(TitledPage):
         self.lcode = self.MakeLabel(
             _("IAU code:"),
             style=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
+
         # text input
         epsgdir = utils.PathJoin(
             globalvar.ETCDIR,
@@ -1909,7 +1911,6 @@ class IAUPage(TitledPage):
     def OnItemSelected(self, event):
         """IAU code selected from the list"""
         index = event.GetIndex()
-        item = event.GetItem()
 
         self.epsgcode = int(self.epsglist.GetItem(index, 0).GetText())
         # This is here that the index 2 (aka WKT) should be loaded in a
@@ -1948,11 +1949,13 @@ class CustomPage(TitledPage):
             self, wizard,
             _("Specify CRS using PROJ.4 string"))
         global coordsys
-        
+
+        # grid definition
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
+        # definition of variables
         self.customstring = ''
         self.parent = parent
 
@@ -2062,12 +2065,15 @@ class SummaryPage(TitledPage):
     def __init__(self, wizard, parent):
         TitledPage.__init__(self, wizard, _("Summary"))
 
+        # grid definition
         self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
         self.sizer.SetCols(5)
         self.sizer.SetRows(8)
-        
+
+        # definition of variables
         self.parent = parent
-        
+
+        # panels
         self.panelTitle = scrolled.ScrolledPanel(parent=self, id=wx.ID_ANY)
         self.panelProj4string = scrolled.ScrolledPanel(
             parent=self, id=wx.ID_ANY)
@@ -2167,7 +2173,6 @@ class SummaryPage(TitledPage):
             extra_opts['read'] = True
 
             if coordsys == 'proj':
-                addl_opts = {}
                 if len(datum) > 0:
                     extra_opts['datum'] = '%s' % datum
                     extra_opts['datum_trans'] = dtrans
@@ -2177,7 +2182,6 @@ class SummaryPage(TitledPage):
                                                  proj4=proj4string,
                                                  **extra_opts)
             elif coordsys == 'iau':
-                addl_opts = {}
                 if len(datum) > 0:
                     extra_opts['datum'] = '%s' % datum
                     extra_opts['datum_trans'] = dtrans
@@ -2198,7 +2202,7 @@ class SummaryPage(TitledPage):
                     georef=self.parent.filepage.georeffile, **extra_opts)
             elif coordsys == 'wkt':
                 ret, projlabel, err = RunCommand(
-                    'g.proj', flags='jft', wkt="-", 
+                    'g.proj', flags='jft', wkt="-",
                     stdin=self.parent.wktpage.wktstring, **extra_opts)
 
             finishButton = wx.FindWindowById(wx.ID_FORWARD)
@@ -2379,7 +2383,6 @@ class LocationWizard(wx.Object):
 
         # new location created?
         self.location = None
-        success = False
 
         # location created in different GIS database?
         self.altdb = False
@@ -2429,7 +2432,6 @@ class LocationWizard(wx.Object):
         east = None
         west = None
         resolution = None
-        transformlist = list()
 
     def __readData(self):
         """Get georeferencing information from tables in $GISBASE/etc/proj"""
@@ -2555,9 +2557,10 @@ class LocationWizard(wx.Object):
                 try:
                     os.mkdir(database)
                 except OSError as error:
-                    GError(parent=self.wizard, message="%s <%s>" %
+                    GError(parent=self.wizard,
+                           message="%s <%s>" %
                            (_("Unable to create new GRASS Database"),
-                           database))
+                            database))
                     return None
 
             # change to new GISDbase directory
@@ -2647,19 +2650,11 @@ class LocationWizard(wx.Object):
 
     def CreateProj4String(self):
         """Constract PROJ.4 string"""
-        location = self.startpage.location
         proj = self.projpage.p4proj
-        projdesc = self.projpage.projdesc
         proj4params = self.paramspage.p4projparams
 
-#        datum = self.datumpage.datum
-        if self.datumpage.datumdesc:
-            datumdesc = self.datumpage.datumdesc + ' - ' + self.datumpage.ellipse
-        else:
-            datumdesc = ''
         datumparams = self.datumpage.datumparams
         ellipse = self.ellipsepage.ellipse
-        ellipsedesc = self.ellipsepage.ellipsedesc
         ellipseparams = self.ellipsepage.ellipseparams
 
         #