[GRASS-SVN] r34141 - grass/trunk/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 2 14:32:58 EST 2008


Author: glynn
Date: 2008-11-02 14:32:58 -0500 (Sun, 02 Nov 2008)
New Revision: 34141

Modified:
   grass/trunk/lib/python/Makefile
   grass/trunk/lib/python/grass.py
Log:
Use -n flag for g.gisenv, g.findfile
Remove unused parse_key_val2 function


Modified: grass/trunk/lib/python/Makefile
===================================================================
--- grass/trunk/lib/python/Makefile	2008-11-02 19:31:39 UTC (rev 34140)
+++ grass/trunk/lib/python/Makefile	2008-11-02 19:32:58 UTC (rev 34141)
@@ -3,10 +3,10 @@
 include $(MODULE_TOPDIR)/include/Make/Other.make
 
 default: $(ETC)/python
+	$(MAKE) $(ETC)/python/grass.py $(ETC)/python/README.txt
 
-$(ETC)/python: grass.py README.txt
-	if [ ! -d $@ ]; then $(MKDIR) $@; fi
-	for file in $^ ; do $(INSTALL_DATA) $$file $@ ; done
+$(ETC)/python:
+	-if [ ! -d $@ ]; then $(MKDIR) $@; fi
 
-.PHONY: $(ETC)/python
-
+$(ETC)/python/%: %
+	$(INSTALL_DATA) $< $@

Modified: grass/trunk/lib/python/grass.py
===================================================================
--- grass/trunk/lib/python/grass.py	2008-11-02 19:31:39 UTC (rev 34140)
+++ grass/trunk/lib/python/grass.py	2008-11-02 19:32:58 UTC (rev 34141)
@@ -230,33 +230,14 @@
 	result[k] = v
     return result
 
-_kv_regex = None
-
-def parse_key_val2(s):
-    """Parse a string into a dictionary, where entries are separated
-    by newlines and the key and value are separated by `=', and the
-    value is enclosed in single quotes.
-    Suitable for parsing the output from g.findfile and g.gisenv.
-    """
-    global _kv_regex
-    if _kv_regex == None:
-	_kv_regex = re.compile("([^=]+)='(.*)';?")
-    result = []
-    for line in s.splitlines():
-	m = _kv_regex.match(line)
-	if m != None:
-	    result.append(m.groups())
-	else:
-	    result.append(line.split('=', 1))
-    return dict(result)
-
 # interface to g.gisenv
 
 def gisenv():
     """Returns the output from running g.gisenv (with no arguments), as a
     dictionary.
     """
-    return parse_key_val2(read_command("g.gisenv"))
+    s = read_command("g.gisenv", flags='n')
+    return parse_key_val(s)
 
 # interface to g.region
 
@@ -287,8 +268,8 @@
 
 def find_file(name, element = 'cell', mapset = None):
     """Returns the output from running g.findfile as a dictionary."""
-    s = read_command("g.findfile", element = element, file = name, mapset = mapset)
-    return parse_key_val2(s)
+    s = read_command("g.findfile", flags='n', element = element, file = name, mapset = mapset)
+    return parse_key_val(s)
 
 # interface to g.list
 



More information about the grass-commit mailing list