|
@@ -14,11 +14,13 @@ This is for code which depend on something from GUI (wx or wxGUI).
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
+import os
|
|
|
|
+
|
|
import wx
|
|
import wx
|
|
|
|
|
|
import grass.script as gs
|
|
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.dialogs import TextEntryDialog
|
|
from gui_core.widgets import GenericValidator
|
|
from gui_core.widgets import GenericValidator
|
|
|
|
|
|
@@ -54,3 +56,29 @@ class NewMapsetDialog(TextEntryDialog):
|
|
if help_hanlder:
|
|
if help_hanlder:
|
|
help_button = self.FindWindowById(wx.ID_HELP)
|
|
help_button = self.FindWindowById(wx.ID_HELP)
|
|
help_button.Bind(wx.EVT_BUTTON, help_hanlder)
|
|
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
|