[GRASS-SVN] r33515 - grass/trunk/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 23 21:56:00 EDT 2008
Author: glynn
Date: 2008-09-23 21:56:00 -0400 (Tue, 23 Sep 2008)
New Revision: 33515
Modified:
grass/trunk/lib/python/grass.py
Log:
Make find_file handle the not-found case
Extend make_command to allow option=None to omit the option entirely
Modified: grass/trunk/lib/python/grass.py
===================================================================
--- grass/trunk/lib/python/grass.py 2008-09-23 21:13:38 UTC (rev 33514)
+++ grass/trunk/lib/python/grass.py 2008-09-24 01:56:00 UTC (rev 33515)
@@ -32,7 +32,8 @@
if flags:
args.append("-%s" % flags)
for opt, val in options.iteritems():
- args.append("%s=%s" % (opt, _make_val(val)))
+ if val != None:
+ args.append("%s=%s" % (opt, _make_val(val)))
return args
def start_command(prog, flags = "", overwrite = False, quiet = False, verbose = False, **kwargs):
@@ -155,9 +156,16 @@
# interface to g.findfile
-def find_file(name, element = 'cell'):
- lines = read_command("g.findfile", element = element, file = name).splitlines()
- return dict([_kv_regex.match(line).groups() for line in lines])
+def find_file(name, element = 'cell', mapset = None):
+ lines = read_command("g.findfile", element = element, file = name, mapset = mapset).splitlines()
+ result = []
+ for line in lines:
+ m = _kv_regex.match(line)
+ if m != None:
+ result.append(m.groups())
+ else:
+ result.append(line.split('='))
+ return dict(result)
# interface to g.list
More information about the grass-commit
mailing list