[GRASS-SVN] r64664 - in grass/trunk/gui/wxpython: animation core dbmgr gcp gmodeler iclass mapswipe psmap rlisetup timeline vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 17 12:44:20 PST 2015


Author: wenzeslaus
Date: 2015-02-17 12:44:20 -0800 (Tue, 17 Feb 2015)
New Revision: 64664

Modified:
   grass/trunk/gui/wxpython/animation/g.gui.animation.py
   grass/trunk/gui/wxpython/core/utils.py
   grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py
   grass/trunk/gui/wxpython/gcp/g.gui.gcp.py
   grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py
   grass/trunk/gui/wxpython/iclass/g.gui.iclass.py
   grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py
   grass/trunk/gui/wxpython/psmap/g.gui.psmap.py
   grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py
   grass/trunk/gui/wxpython/timeline/g.gui.timeline.py
   grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py
Log:
wxGUI: import only after grass.script.parser() call g.gui.* and PEP8 clean up

 * function GuiModuleMain() completely removed (just simple call since r62649) because it was creating unnecessary import dependency which would prevent posibility of post-parser import
 * changes according to PEP8 and removing unused imports (using pep8 and pylint tools in Spyder)
 * use grass.script as gscript rather than grass which is ambiguous
 * call parser in main function to avoid global variables options and flags (there is no need for them)
 * see also #1819 (comment:6:ticket:1819) and grass-dev Add link to manual page on the addon wiki (http://lists.osgeo.org/pipermail/grass-dev/2015-February/073734.html)


Modified: grass/trunk/gui/wxpython/animation/g.gui.animation.py
===================================================================
--- grass/trunk/gui/wxpython/animation/g.gui.animation.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/animation/g.gui.animation.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -51,22 +51,23 @@
 #% guisection: Input
 #%end
 
-import os
+import grass.script as gscript
 
-import wx
 
-import grass.script as grass
-import grass.temporal as tgis
+def main():
+    options, flags = gscript.parser()
 
-from core.globalvar import CheckWxVersion
-from core.utils import _, GuiModuleMain
-from core.giface import StandaloneGrassInterface
-from core.layerlist import LayerList
-from animation.frame import AnimationFrame, MAX_COUNT
-from animation.data import AnimLayer
+    # import wx only after running parser
+    # to avoid issues when only interface is needed
+    import grass.temporal as tgis
+    import wx
+    from core.globalvar import CheckWxVersion
+    from core.utils import _
+    from core.giface import StandaloneGrassInterface
+    from core.layerlist import LayerList
+    from animation.frame import AnimationFrame, MAX_COUNT
+    from animation.data import AnimLayer
 
-
-def main():
     rast = options['raster']
     vect = options['vector']
     strds = options['strds']
@@ -82,12 +83,11 @@
         numInputs += 1
     if stvds:
         numInputs += 1
-        
 
     if numInputs > 1:
-        grass.fatal(_("%s=, %s=, %s= and %s= are mutually exclusive.") %
-                ("raster", "vector", "strds", "stvds"))
-        
+        gscript.fatal(_("%s=, %s=, %s= and %s= are mutually exclusive.") %
+                       ("raster", "vector", "strds", "stvds"))
+
     if numInputs > 0:
         # We need to initialize the temporal framework in case
         # a space time dataset was set on the command line so that
@@ -132,6 +132,4 @@
     app.MainLoop()
 
 if __name__ == '__main__':
-    options, flags = grass.parser()
-
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/core/utils.py
===================================================================
--- grass/trunk/gui/wxpython/core/utils.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/core/utils.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -1012,14 +1012,7 @@
 
     return kwargs, missing_args
 
-def GuiModuleMain(mainfn):
-    """Main function for g.gui.* modules
 
-    os.fork removed in r62649 as fragile
-    """
-    mainfn()
-
-
 def PilImageToWxImage(pilImage, copyAlpha = True):
     """Convert PIL image to wx.Image
     

Modified: grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/dbmgr/g.gui.dbmgr.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -28,32 +28,30 @@
 #%option G_OPT_V_MAP
 #%end
 
-import os
+import grass.script as gscript
 
-import  wx
 
-import grass.script as grass
+def main():
+    options, flags = gscript.parser()
 
-from core.utils import _, GuiModuleMain
-from dbmgr.manager import AttributeManager
+    import wx
+    from core.utils import _
+    from dbmgr.manager import AttributeManager
 
-def main():
-    mapName = grass.find_file(options['map'], element = 'vector')['fullname']
+    mapName = gscript.find_file(options['map'], element='vector')['fullname']
     if not mapName:
-        grass.set_raise_on_error(False)
-        grass.fatal(_("Vector map <%s> not found") % options['map'])
-    
+        gscript.set_raise_on_error(False)
+        gscript.fatal(_("Vector map <%s> not found") % options['map'])
+
     app = wx.App()
-    grass.message(_("Loading attribute data for vector map <%s>...") % mapName)
-    f = AttributeManager(parent = None, id = wx.ID_ANY,
-                         title = "%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
-                                                mapName),
-                         size = (900, 600), vectorName = mapName)
+    gscript.message(_("Loading attribute data for vector map <%s>...") % mapName)
+    f = AttributeManager(parent=None, id=wx.ID_ANY,
+                         title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
+                                              mapName),
+                         size=(900, 600), vectorName=mapName)
     f.Show()
-    
+
     app.MainLoop()
-    
+
 if __name__ == "__main__":
-    options, flags = grass.parser()
-    
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/gcp/g.gui.gcp.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/g.gui.gcp.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/gcp/g.gui.gcp.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -34,15 +34,9 @@
 """
 
 import os
-import  wx
 
-import grass.script as grass
+import grass.script as gscript
 
-from core.settings import UserSettings
-from core.globalvar import CheckWxVersion
-from core.giface import StandaloneGrassInterface
-from core.utils import GuiModuleMain
-from gcp.manager import GCPWizard
 
 def main():
     """Sets the GRASS display driver
@@ -50,12 +44,20 @@
     .. todo::
         use command line options as an alternative to wizard
     """
+    options, flags = gscript.parser()
+
+    import wx
+    from core.settings import UserSettings
+    from core.globalvar import CheckWxVersion
+    from core.giface import StandaloneGrassInterface
+    from gcp.manager import GCPWizard
+
     driver = UserSettings.Get(group='display', key='driver', subkey='type')
     if driver == 'png':
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
     else:
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
-    
+
     app = wx.App()
     if not CheckWxVersion([2, 9]):
         wx.InitAllImageHandlers()
@@ -65,6 +67,4 @@
     app.MainLoop()
 
 if __name__ == '__main__':
-    options, flags = grass.parser()
-    
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/gmodeler/g.gui.gmodeler.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -34,29 +34,26 @@
 #% guisection: Model
 #%end
 
-import os
+import grass.script as gscript
 
-import  wx
 
-import grass.script as grass
+def main():
+    options, flags = gscript.parser()
 
-from core.giface import StandaloneGrassInterface
-from core.globalvar import CheckWxVersion
-from core.utils import _, GuiModuleMain
-from gmodeler.frame import ModelFrame
+    import wx
+    from core.giface import StandaloneGrassInterface
+    from core.globalvar import CheckWxVersion
+    from gmodeler.frame import ModelFrame
 
-def main():
     app = wx.App()
     if not CheckWxVersion([2, 9]):
         wx.InitAllImageHandlers()
-    frame = ModelFrame(parent = None, giface = StandaloneGrassInterface())
+    frame = ModelFrame(parent=None, giface=StandaloneGrassInterface())
     if options['file']:
         frame.LoadModelFile(options['file'])
     frame.Show()
-    
+
     app.MainLoop()
-    
+
 if __name__ == "__main__":
-    options, flags = grass.parser()
-    
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/iclass/g.gui.iclass.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/g.gui.iclass.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/iclass/g.gui.iclass.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -4,7 +4,7 @@
 # MODULE:    g.gui.iclass
 # AUTHOR(S): Anna Kratochvilova, Vaclav Petras
 # PURPOSE:   The Map Swipe is a wxGUI component which allows the user to
-#            interactively compare two maps  
+#            interactively compare two maps
 # COPYRIGHT: (C) 2012-2013 by Anna Kratochvilova, and the GRASS Development Team
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -50,59 +50,67 @@
 #%end
 
 import os
+import grass.script as gscript
 
-import  wx
 
-import grass.script as grass
+def main():
+    gscript.set_raise_on_error(False)
+    options, flags = gscript.parser()
 
-from core.settings import UserSettings
-from core.globalvar import CheckWxVersion
-from core.giface import StandaloneGrassInterface
-from core.utils import _, GuiModuleMain
-from iclass.frame import IClassMapFrame
+    import wx
+    from core.settings import UserSettings
+    from core.globalvar import CheckWxVersion
+    from core.giface import StandaloneGrassInterface
+    from core.utils import _
+    from iclass.frame import IClassMapFrame
 
-def main():
     group_name = subgroup_name = map_name = trainingmap_name = None
 
     if options['group']:
         if not options['subgroup']:
-            grass.fatal(_("Name of subgroup required"))
-        group_name = grass.find_file(name = options['group'], element = 'group')['name']
+            gscript.fatal(_("Name of subgroup required"))
+        group_name = gscript.find_file(name=options['group'],
+                                       element='group')['name']
         if not group_name:
-            grass.fatal(_("Group <%s> not found") % options['group'])
-        if options['subgroup'] not in grass.read_command('i.group', group = group_name, flags = 'sg').splitlines():
-            grass.fatal(_("Subgroup <%s> not found") % options['subgroup'])
+            gscript.fatal(_("Group <%s> not found") % options['group'])
+        subgroups = gscript.read_command('i.group',
+                                         group=group_name,
+                                         flags='sg').splitlines()
+        if options['subgroup'] not in subgroups:
+            gscript.fatal(_("Subgroup <%s> not found") % options['subgroup'])
         subgroup_name = options['subgroup']
-    
+
     if options['map']:
-        map_name = grass.find_file(name = options['map'], element = 'cell')['fullname']
+        map_name = gscript.find_file(name=options['map'],
+                                     element='cell')['fullname']
         if not map_name:
-            grass.fatal(_("Raster map <%s> not found") % options['map'])
-    
+            gscript.fatal(_("Raster map <%s> not found") % options['map'])
+
     if options['trainingmap']:
-        trainingmap_name = grass.find_file(name = options['trainingmap'], element = 'vector')['fullname']
+        trainingmap_name = gscript.find_file(name=options['trainingmap'],
+                                             element='vector')['fullname']
         if not trainingmap_name:
-            grass.fatal(_("Vector map <%s> not found") % options['trainingmap'])
-    
+            gscript.fatal(_("Vector map <%s> not found") % options['trainingmap'])
+
     # define display driver
-    driver = UserSettings.Get(group = 'display', key = 'driver', subkey = 'type')
+    driver = UserSettings.Get(group='display', key='driver', subkey='type')
     if driver == 'png':
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
     else:
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
-    
+
     # launch application
     app = wx.App()
     if not CheckWxVersion([2, 9]):
         wx.InitAllImageHandlers()
-    
+
     # show main frame
     giface = StandaloneGrassInterface()
-    frame = IClassMapFrame(parent = None, giface = giface)
+    frame = IClassMapFrame(parent=None, giface=giface)
     if not flags['m']:
         frame.CenterOnScreen()
     if group_name:
-        frame.SetGroup(group_name, subgroup_name) 
+        frame.SetGroup(group_name, subgroup_name)
     if map_name:
         giface.WriteLog(_("Loading raster map <%s>...") % map_name)
         frame.trainingMapManager.AddLayer(map_name)
@@ -110,14 +118,10 @@
         giface.WriteLog(_("Loading training map <%s>...") % trainingmap_name)
         frame.ImportAreas(trainingmap_name)
 
-    frame.Show()    
+    frame.Show()
     if flags['m']:
         frame.Maximize()
-    
     app.MainLoop()
-    
+
 if __name__ == '__main__':
-    grass.set_raise_on_error(False)
-    options, flags = grass.parser()
-    
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -4,7 +4,7 @@
 # MODULE:    Map Swipe
 # AUTHOR(S): Anna Kratochvilova
 # PURPOSE:   The Map Swipe is a wxGUI component which allows the user to
-#            interactively compare two maps  
+#            interactively compare two maps
 # COPYRIGHT: (C) 2012 by Anna Kratochvilova, and the GRASS Development Team
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -44,43 +44,42 @@
 #% required: no
 #%end
 
-
 import os
+import grass.script as gscript
 
-import  wx
 
-import grass.script as grass
+def main():
+    options, flags = gscript.parser()
 
-from core.settings import UserSettings
-from core.globalvar import CheckWxVersion
-from core.giface import StandaloneGrassInterface
-from core.utils import _, GuiModuleMain
-from mapswipe.frame import SwipeMapFrame
+    import wx
+    from core.settings import UserSettings
+    from core.globalvar import CheckWxVersion
+    from core.giface import StandaloneGrassInterface
+    from core.utils import _
+    from mapswipe.frame import SwipeMapFrame
 
-
-def main():
-    driver = UserSettings.Get(group = 'display', key = 'driver', subkey = 'type')
+    driver = UserSettings.Get(group='display', key='driver', subkey='type')
     if driver == 'png':
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
     else:
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
-    
+
     first = options['first']
     second = options['second']
     mode = options['mode']
 
-    for mapName in [first, second]:    
+    for mapName in [first, second]:
         if mapName:
-            gfile = grass.find_file(name = mapName)
+            gfile = gscript.find_file(name=mapName)
             if not gfile['name']:
-                grass.fatal(_("Raster map <%s> not found") % mapName)
+                gscript.fatal(_("Raster map <%s> not found") % mapName)
 
     app = wx.App()
     if not CheckWxVersion([2, 9]):
         wx.InitAllImageHandlers()
 
-    frame = SwipeMapFrame(parent = None, giface = StandaloneGrassInterface())
-    
+    frame = SwipeMapFrame(parent=None, giface=StandaloneGrassInterface())
+
     if first:
         frame.SetFirstRaster(first)
     if second:
@@ -93,7 +92,6 @@
 
     app.MainLoop()
 
+
 if __name__ == '__main__':
-    options, flags = grass.parser()
-    
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/psmap/g.gui.psmap.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/g.gui.psmap.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/psmap/g.gui.psmap.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -32,22 +32,20 @@
 #% required: no
 #%end
 
-import os
+import grass.script as gscript
 
-import  wx
 
-import grass.script as grass
+def main():
+    options, flags = gscript.parser()
 
-from core.globalvar import CheckWxVersion
-from core.utils import _, GuiModuleMain
-from psmap.frame import PsMapFrame
-from psmap.instructions import Instruction
+    import wx
+    from core.globalvar import CheckWxVersion
+    from psmap.frame import PsMapFrame
 
-def main():
     app = wx.App()
     if not CheckWxVersion([2, 9]):
         wx.InitAllImageHandlers()
-    frame = PsMapFrame(parent = None)
+    frame = PsMapFrame(parent=None)
     frame.Show()
 
     if options['file']:
@@ -56,6 +54,4 @@
     app.MainLoop()
 
 if __name__ == "__main__":
-    options, flags = grass.parser()
-    
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py
===================================================================
--- grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/rlisetup/g.gui.rlisetup.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -26,18 +26,17 @@
 #% keyword: landscape structure analysis
 #%end
 
-import os
+import grass.script as gscript
 
-import wx
-import grass.script as grass
 
-from core.giface import StandaloneGrassInterface
-from core.globalvar import CheckWxVersion
-from core.utils import _, GuiModuleMain
-from rlisetup.frame import RLiSetupFrame
+def main():
+    gscript.parser()
 
+    import wx
+    from core.giface import StandaloneGrassInterface
+    from core.globalvar import CheckWxVersion
+    from rlisetup.frame import RLiSetupFrame
 
-def main():
     app = wx.App()
     if not CheckWxVersion([2, 9]):
         wx.InitAllImageHandlers()
@@ -48,6 +47,4 @@
     app.MainLoop()
 
 if __name__ == "__main__":
-    options, flags = grass.parser()
-
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/timeline/g.gui.timeline.py
===================================================================
--- grass/trunk/gui/wxpython/timeline/g.gui.timeline.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/timeline/g.gui.timeline.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -33,20 +33,20 @@
 #% description: Show also 3D plot of spatio-temporal extents
 #%end
 
+import grass.script as gscript
 
-import os
 
-import  wx
-
-import grass.script as grass
-from core.utils import _, GuiModuleMain
-
-
 def main():
+    options, flags = gscript.parser()
+
+    import wx
     try:
         from timeline.frame import TimelineFrame
     except ImportError as e:
-        grass.fatal(e.message)
+        # TODO: why do we need this special check here, the reason of error
+        # is wrong intallation or something, no need to report this to the
+        # user in a nice way
+        gscript.fatal(e.message)
 
     datasets = options['inputs'].strip().split(',')
     datasets = [data for data in datasets if data]
@@ -61,6 +61,4 @@
 
 
 if __name__ == '__main__':
-    options, flags = grass.parser()
-
-    GuiModuleMain(main)
+    main()

Modified: grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py	2015-02-17 20:42:59 UTC (rev 64663)
+++ grass/trunk/gui/wxpython/vdigit/g.gui.vdigit.py	2015-02-17 20:44:20 UTC (rev 64664)
@@ -35,46 +35,68 @@
 #%end
 
 import os
-
 import grass.script as grass
 
-import wx
 
-from core.globalvar import CheckWxVersion
-from core.utils import _, GuiModuleMain
-from mapdisp.frame import MapFrame
-from mapdisp.main import DMonGrassInterface
-from core.settings import UserSettings
-from vdigit.main import haveVDigit, errorMsg
-from grass.exceptions import CalledModuleError
+def main():
+    grass.set_raise_on_error(False)
 
+    options, flags = grass.parser()
 
-class VDigitMapFrame(MapFrame):
-    def __init__(self, vectorMap):
-        MapFrame.__init__(self, parent = None, giface = DMonGrassInterface(None),
-                          title = _("GRASS GIS Vector Digitizer"), size = (850, 600))
-        # this giface issue not solved yet, we must set mapframe aferwards
-        self._giface._mapframe = self
-        # load vector map
-        mapLayer = self.GetMap().AddLayer(ltype = 'vector',
-                                          command = ['d.vect', 'map=%s' % vectorMap],
-                                          active = True, name = vectorMap, hidden = False, opacity = 1.0,
-                                          render = True)
-        
-        # switch toolbar
-        self.AddToolbar('vdigit', fixed = True)
-        
-        # start editing
-        self.toolbars['vdigit'].StartEditing(mapLayer)
+    # import wx only after running parser
+    # to avoid issues with complex imports when only interface is needed
+    import wx
+    from core.globalvar import CheckWxVersion
+    from core.utils import _
+    from mapdisp.frame import MapFrame
+    from mapdisp.main import DMonGrassInterface
+    from core.settings import UserSettings
+    from vdigit.main import haveVDigit, errorMsg
+    from grass.exceptions import CalledModuleError
 
-def main():
+    # define classes which needs imports as local
+    # for longer definitions, a separate file would be a better option
+    class VDigitMapFrame(MapFrame):
+        def __init__(self, vectorMap):
+            MapFrame.__init__(
+                self, parent=None, giface=DMonGrassInterface(None),
+                title=_("GRASS GIS Vector Digitizer"), size=(850, 600))
+            # this giface issue not solved yet, we must set mapframe aferwards
+            self._giface._mapframe = self
+            # load vector map
+            mapLayer = self.GetMap().AddLayer(
+                ltype='vector', name=vectorMap,
+                command=['d.vect', 'map=%s' % vectorMap],
+                active=True, hidden=False, opacity=1.0, render=True)
+
+            # switch toolbar
+            self.AddToolbar('vdigit', fixed=True)
+
+            # start editing
+            self.toolbars['vdigit'].StartEditing(mapLayer)
+
+    if not haveVDigit:
+        grass.fatal(_("Vector digitizer not available. %s") % errorMsg)
+
+    if not grass.find_file(name=options['map'], element='vector',
+                           mapset=grass.gisenv()['MAPSET'])['fullname']:
+        if not flags['c']:
+            grass.fatal(_("Vector map <%s> not found in current mapset. "
+                          "New vector map can be created by providing '-c' flag.") % options['map'])
+        else:
+            grass.message(_("New vector map <%s> created") % options['map'])
+            try:
+                grass.run_command('v.edit', map=options['map'], tool='create')
+            except CalledModuleError:
+                grass.fatal(_("Unable to create new vector map <%s>") % options['map'])
+
     # allow immediate rendering
-    driver = UserSettings.Get(group = 'display', key = 'driver', subkey = 'type')
+    driver = UserSettings.Get(group='display', key='driver', subkey='type')
     if driver == 'png':
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
     else:
         os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
-    
+
     app = wx.App()
     if not CheckWxVersion([2, 9]):
         wx.InitAllImageHandlers()
@@ -82,25 +104,6 @@
     frame.Show()
 
     app.MainLoop()
-    
+
 if __name__ == "__main__":
-    grass.set_raise_on_error(False)
-    
-    options, flags = grass.parser()
-    
-    if not haveVDigit:
-        grass.fatal(_("Vector digitizer not available. %s") % errorMsg)
-    
-    if not grass.find_file(name = options['map'], element = 'vector',
-                           mapset = grass.gisenv()['MAPSET'])['fullname']:
-        if not flags['c']:
-            grass.fatal(_("Vector map <%s> not found in current mapset. "
-                          "New vector map can be created by providing '-c' flag.") % options['map'])
-        else:
-            grass.message(_("New vector map <%s> created") % options['map'])
-            try:
-                grass.run_command('v.edit', map = options['map'], tool = 'create')
-            except CalledModuleError:
-                grass.fatal(_("Unable to create new vector map <%s>") % options['map'])
-    
-    GuiModuleMain(main)
+    main()



More information about the grass-commit mailing list