Forráskód Böngészése

wxGUI/startup: read_gisrc as a GUI function (fixes https://trac.osgeo.org/grass/changeset/73175)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73177 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 6 éve
szülő
commit
a4a5a8b67a

+ 2 - 1
gui/wxpython/gis_set.py

@@ -40,6 +40,7 @@ from startup.utils import (
     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 @@ class GRASSStartup(wx.Frame):
         # GRASS variables
         #
         self.gisbase = os.getenv("GISBASE")
-        self.grassrc = sutils.read_gisrc()
+        self.grassrc = sgui.read_gisrc()
         self.gisdbase = self.GetRCValue("GISDBASE")
 
         #

+ 29 - 1
gui/wxpython/startup/guiutils.py

@@ -14,11 +14,13 @@ This is for code which depend on something from GUI (wx or wxGUI).
 """
 
 
+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 @@ class NewMapsetDialog(TextEntryDialog):
         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

+ 0 - 26
gui/wxpython/startup/utils.py

@@ -96,29 +96,3 @@ def delete_mapset(database, location, mapset):
 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