[GRASS-SVN] r43081 - grass/trunk/scripts/v.db.dropcolumn
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 13 02:13:43 EDT 2010
Author: martinl
Date: 2010-08-13 06:13:43 +0000 (Fri, 13 Aug 2010)
New Revision: 43081
Modified:
grass/trunk/scripts/v.db.dropcolumn/v.db.dropcolumn.py
Log:
v.db.dropcolumn: message cosmetics
Modified: grass/trunk/scripts/v.db.dropcolumn/v.db.dropcolumn.py
===================================================================
--- grass/trunk/scripts/v.db.dropcolumn/v.db.dropcolumn.py 2010-08-12 18:12:28 UTC (rev 43080)
+++ grass/trunk/scripts/v.db.dropcolumn/v.db.dropcolumn.py 2010-08-13 06:13:43 UTC (rev 43081)
@@ -55,34 +55,37 @@
import grass.script as grass
def main():
- map = options['map']
- layer = options['layer']
+ map = options['map']
+ layer = options['layer']
column = options['column']
-
+
mapset = grass.gisenv()['MAPSET']
-
+
# does map exist in CURRENT mapset?
if not grass.find_file(map, element = 'vector', mapset = mapset):
grass.fatal(_("Vector map <%s> not found in current mapset") % map)
-
+
f = grass.vector_layer_db(map, layer)
-
+
table = f['table']
keycol = f['key']
database = f['database']
driver = f['driver']
-
+
if not table:
- grass.fatal(_("There is no table connected to the input vector map Cannot delete any column"))
-
+ grass.fatal(_("There is no table connected to the input vector map. "
+ "Unable to delete any column. Exiting."))
+
if column == keycol:
- grass.fatal(_("Cannot delete <$col> column as it is needed to keep table <%s> connected to the input vector map <%s>") % (table, map))
-
+ grass.fatal(_("Unable to delete <%s> column as it is needed to keep table <%s> "
+ "connected to the input vector map <%s>") % \
+ (column, table, map))
+
if not grass.vector_columns(map, layer).has_key(column):
grass.fatal(_("Column <%s> not found in table <%s>") % (column, table))
-
+
if driver == "sqlite":
- #echo "Using special trick for SQLite"
+ # echo "Using special trick for SQLite"
# http://www.sqlite.org/faq.html#q13
colnames = []
coltypes = []
@@ -109,14 +112,14 @@
sql = tmpl.substitute(table = table, coldef = coltypes, colnames = colnames)
else:
sql = "ALTER TABLE %s DROP COLUMN %s" % (table, column)
-
+
if grass.write_command('db.execute', input = '-', database = database, driver = driver,
stdin = sql) != 0:
- grass.fatal(_("Cannot continue (problem deleting column)."))
-
+ grass.fatal(_("Deleting column failed"))
+
# write cmd history:
grass.vector_history(map)
-
+
if __name__ == "__main__":
options, flags = grass.parser()
main()
More information about the grass-commit
mailing list