浏览代码

v.db.dropcolumn: message cosmetics

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43081 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 年之前
父节点
当前提交
b750e25dce
共有 1 个文件被更改,包括 20 次插入17 次删除
  1. 20 17
      scripts/v.db.dropcolumn/v.db.dropcolumn.py

+ 20 - 17
scripts/v.db.dropcolumn/v.db.dropcolumn.py

@@ -55,34 +55,37 @@ import string
 import grass.script as grass
 import grass.script as grass
 
 
 def main():
 def main():
-    map = options['map']
-    layer = options['layer']
+    map    = options['map']
+    layer  = options['layer']
     column = options['column']
     column = options['column']
-
+    
     mapset = grass.gisenv()['MAPSET']
     mapset = grass.gisenv()['MAPSET']
-
+    
     # does map exist in CURRENT mapset?
     # does map exist in CURRENT mapset?
     if not grass.find_file(map, element = 'vector', mapset = mapset):
     if not grass.find_file(map, element = 'vector', mapset = mapset):
 	grass.fatal(_("Vector map <%s> not found in current mapset") % map)
 	grass.fatal(_("Vector map <%s> not found in current mapset") % map)
-
+    
     f = grass.vector_layer_db(map, layer)
     f = grass.vector_layer_db(map, layer)
-
+    
     table = f['table']
     table = f['table']
     keycol = f['key']
     keycol = f['key']
     database = f['database']
     database = f['database']
     driver = f['driver']
     driver = f['driver']
-
+    
     if not table:
     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:
     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):
     if not grass.vector_columns(map, layer).has_key(column):
 	grass.fatal(_("Column <%s> not found in table <%s>") % (column, table))
 	grass.fatal(_("Column <%s> not found in table <%s>") % (column, table))
-
+    
     if driver == "sqlite":
     if driver == "sqlite":
-	#echo "Using special trick for SQLite"
+	# echo "Using special trick for SQLite"
 	# http://www.sqlite.org/faq.html#q13
 	# http://www.sqlite.org/faq.html#q13
 	colnames = []
 	colnames = []
 	coltypes = []
 	coltypes = []
@@ -109,14 +112,14 @@ def main():
 	sql = tmpl.substitute(table = table, coldef = coltypes, colnames = colnames)
 	sql = tmpl.substitute(table = table, coldef = coltypes, colnames = colnames)
     else:
     else:
 	sql = "ALTER TABLE %s DROP COLUMN %s" % (table, column)
 	sql = "ALTER TABLE %s DROP COLUMN %s" % (table, column)
-
+    
     if grass.write_command('db.execute', input = '-', database = database, driver = driver,
     if grass.write_command('db.execute', input = '-', database = database, driver = driver,
 			   stdin = sql) != 0:
 			   stdin = sql) != 0:
-	grass.fatal(_("Cannot continue (problem deleting column)."))
-
+	grass.fatal(_("Deleting column failed"))
+    
     # write cmd history:
     # write cmd history:
     grass.vector_history(map)
     grass.vector_history(map)
-
+    
 if __name__ == "__main__":
 if __name__ == "__main__":
     options, flags = grass.parser()
     options, flags = grass.parser()
     main()
     main()