[GRASS-SVN] r73177 - in grass/trunk/gui/wxpython: . startup

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 24 18:35:26 PDT 2018


Author: wenzeslaus
Date: 2018-08-24 18:35:26 -0700 (Fri, 24 Aug 2018)
New Revision: 73177

Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/startup/guiutils.py
   grass/trunk/gui/wxpython/startup/utils.py
Log:
wxGUI/startup: read_gisrc as a GUI function (fixes r73175)

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2018-08-25 01:27:09 UTC (rev 73176)
+++ grass/trunk/gui/wxpython/gis_set.py	2018-08-25 01:35:26 UTC (rev 73177)
@@ -40,6 +40,7 @@
     get_lockfile_if_present, get_possible_database_path, create_mapset)
 import startup.utils as sutils
 from startup.guiutils import SetSessionMapset, NewMapsetDialog
+import startup.guiutils as sgui
 from location_wizard.dialogs import RegionDef
 from gui_core.dialogs import TextEntryDialog
 from gui_core.widgets import GenericValidator, StaticWrapText
@@ -63,7 +64,7 @@
         # GRASS variables
         #
         self.gisbase = os.getenv("GISBASE")
-        self.grassrc = sutils.read_gisrc()
+        self.grassrc = sgui.read_gisrc()
         self.gisdbase = self.GetRCValue("GISDBASE")
 
         #

Modified: grass/trunk/gui/wxpython/startup/guiutils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/guiutils.py	2018-08-25 01:27:09 UTC (rev 73176)
+++ grass/trunk/gui/wxpython/startup/guiutils.py	2018-08-25 01:35:26 UTC (rev 73177)
@@ -14,11 +14,13 @@
 """
 
 
+import os
+
 import wx
 
 import grass.script as gs
 
-from core.gcmd import RunCommand
+from core.gcmd import DecodeString, RunCommand
 from gui_core.dialogs import TextEntryDialog
 from gui_core.widgets import GenericValidator
 
@@ -54,3 +56,29 @@
         if help_hanlder:
             help_button = self.FindWindowById(wx.ID_HELP)
             help_button.Bind(wx.EVT_BUTTON, help_hanlder)
+
+
+# TODO: similar to (but not the same as) read_gisrc function in grass.py
+def read_gisrc():
+    """Read variables from a current GISRC file
+
+    Returns a dictionary representation of the file content.
+    """
+    grassrc = {}
+
+    gisrc = os.getenv("GISRC")
+
+    if gisrc and os.path.isfile(gisrc):
+        try:
+            rc = open(gisrc, "r")
+            for line in rc.readlines():
+                try:
+                    key, val = line.split(":", 1)
+                except ValueError as e:
+                    sys.stderr.write(
+                        _('Invalid line in GISRC file (%s):%s\n' % (e, line)))
+                grassrc[key.strip()] = DecodeString(val.strip())
+        finally:
+            rc.close()
+
+    return grassrc

Modified: grass/trunk/gui/wxpython/startup/utils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/utils.py	2018-08-25 01:27:09 UTC (rev 73176)
+++ grass/trunk/gui/wxpython/startup/utils.py	2018-08-25 01:35:26 UTC (rev 73177)
@@ -96,29 +96,3 @@
 def delete_location(database, location):
     """Deletes a specified location"""
     shutil.rmtree(os.path.join(database, location))
-
-
-# TODO: similar to (but not the same as) read_gisrc function in grass.py
-def read_gisrc():
-    """Read variables from a current GISRC file
-
-    Returns a dictionary representation of the file content.
-    """
-    grassrc = {}
-
-    gisrc = os.getenv("GISRC")
-
-    if gisrc and os.path.isfile(gisrc):
-        try:
-            rc = open(gisrc, "r")
-            for line in rc.readlines():
-                try:
-                    key, val = line.split(":", 1)
-                except ValueError as e:
-                    sys.stderr.write(
-                        _('Invalid line in GISRC file (%s):%s\n' % (e, line)))
-                grassrc[key.strip()] = DecodeString(val.strip())
-        finally:
-            rc.close()
-
-    return grassrc



More information about the grass-commit mailing list