[GRASS-SVN] r65401 - grass/branches/releasebranch_7_0/scripts/db.in.ogr

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


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

Modified:
   grass/branches/releasebranch_7_0/scripts/db.in.ogr/db.in.ogr.py
Log:
db.in.ogr: fix overwrite logic
           (merge r65400 from trunk)


Modified: grass/branches/releasebranch_7_0/scripts/db.in.ogr/db.in.ogr.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/db.in.ogr/db.in.ogr.py	2015-06-07 12:21:43 UTC (rev 65400)
+++ grass/branches/releasebranch_7_0/scripts/db.in.ogr/db.in.ogr.py	2015-06-07 12:22:21 UTC (rev 65401)
@@ -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