[GRASS-SVN] r65400 - grass/trunk/scripts/db.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 7 05:21:43 PDT 2015


Author: martinl
Date: 2015-06-07 05:21:43 -0700 (Sun, 07 Jun 2015)
New Revision: 65400

Modified:
   grass/trunk/scripts/db.in.ogr/db.in.ogr.py
Log:
db.in.ogr: fix overwrite logic

Modified: grass/trunk/scripts/db.in.ogr/db.in.ogr.py
===================================================================
--- grass/trunk/scripts/db.in.ogr/db.in.ogr.py	2015-06-07 11:35:14 UTC (rev 65399)
+++ grass/trunk/scripts/db.in.ogr/db.in.ogr.py	2015-06-07 12:21:43 UTC (rev 65400)
@@ -70,14 +70,17 @@
 	tmpname = input.replace('.', '_')
 	output = grass.basename(tmpname)
 
-    if not grass.overwrite():
-	s = grass.read_command('db.tables', flags = 'p', quiet=True)
-	for l in s.splitlines():
-	    if l == output:
-		grass.fatal(_("Table <%s> already exists") % output)
-    else:
-	grass.write_command('db.execute', input = '-', stdin = "DROP TABLE %s" % output)
-
+    # check if table exists
+    s = grass.read_command('db.tables', flags = 'p', quiet=True)
+    for l in s.splitlines():
+        if l == output:
+            if grass.overwrite():
+                grass.warning(_("Table <%s> already exists and will be and will be overwritten") % output)
+                grass.write_command('db.execute', input = '-', stdin = "DROP TABLE %s" % output)
+                break
+            else:
+                grass.fatal(_("Table <%s> already exists") % output)
+                
     # treat DB as real vector map...
     if db_table:
 	layer = db_table



More information about the grass-commit mailing list