[GRASS-SVN] r67220 - grass/branches/releasebranch_7_0/scripts/v.what.strds
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 18 03:54:10 PST 2015
Author: neteler
Date: 2015-12-18 03:54:10 -0800 (Fri, 18 Dec 2015)
New Revision: 67220
Modified:
grass/branches/releasebranch_7_0/scripts/v.what.strds/v.what.strds.py
Log:
v.what.strds: backport of flag to Update attribute table of input vector map (trunk, [66326:66332])
Modified: grass/branches/releasebranch_7_0/scripts/v.what.strds/v.what.strds.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/v.what.strds/v.what.strds.py 2015-12-18 11:04:16 UTC (rev 67219)
+++ grass/branches/releasebranch_7_0/scripts/v.what.strds/v.what.strds.py 2015-12-18 11:54:10 UTC (rev 67220)
@@ -33,6 +33,7 @@
#%end
#%option G_OPT_V_OUTPUT
+#% required: no
#%end
#%option G_OPT_DB_WHERE
@@ -42,6 +43,12 @@
#% key: t_where
#%end
+#%flag
+#% key: u
+#% label: Update attribute table of input vector map
+#% description: Instead of creating a new vector map update the attribute table with value(s)
+#%end
+
import grass.script as grass
import grass.temporal as tgis
from grass.pygrass.utils import copy as gcopy
@@ -88,6 +95,13 @@
where = options["where"]
tempwhere = options["t_where"]
+ if output and flags['u']:
+ grass.fatal(_("Cannot combine 'output' option and 'u' flag"))
+ elif not output and not flags['u']:
+ grass.fatal(_("'output' option or 'u' flag must be given"))
+ elif not output and flags['u']:
+ grass.warning(_("Attribute table of vector {name} will be updated...").format(name=input))
+
if where == "" or where == " " or where == "\n":
where = None
@@ -173,7 +187,10 @@
samples.append(s)
# Get the layer and database connections of the input vector
- gcopy(input, output, 'vect')
+ if output:
+ gcopy(input, output, 'vector')
+ else:
+ output = input
msgr = Messenger()
perc_curr = 0
More information about the grass-commit
mailing list