[GRASS-SVN] r68020 - grass/trunk/scripts/v.db.join

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 8 05:03:57 PST 2016


Author: lucadelu
Date: 2016-03-08 05:03:57 -0800 (Tue, 08 Mar 2016)
New Revision: 68020

Modified:
   grass/trunk/scripts/v.db.join/v.db.join.py
Log:
v.db.join: PEP8 cleanup

Modified: grass/trunk/scripts/v.db.join/v.db.join.py
===================================================================
--- grass/trunk/scripts/v.db.join/v.db.join.py	2016-03-08 12:07:44 UTC (rev 68019)
+++ grass/trunk/scripts/v.db.join/v.db.join.py	2016-03-08 13:03:57 UTC (rev 68020)
@@ -72,7 +72,7 @@
         scolumns = options['subset_columns'].split(',')
     else:
         scolumns = None
-    
+
     f = grass.vector_layer_db(map, layer)
 
     maptable = f['table']
@@ -80,21 +80,22 @@
     driver   = f['driver']
 
     if driver == 'dbf':
-	grass.fatal(_("JOIN is not supported for tables stored in DBF format"))
+        grass.fatal(_("JOIN is not supported for tables stored in DBF format"))
 
     if not maptable:
-	grass.fatal(_("There is no table connected to this map. Unable to join any column."))
+        grass.fatal(_("There is no table connected to this map. Unable to join any column."))
 
     # check if column is in map table
     if not grass.vector_columns(map, layer).has_key(column):
-	grass.fatal(_("Column <%s> not found in table <%s>") % (column, maptable))
+        grass.fatal(_("Column <%s> not found in table <%s>") % (column,
+                                                                maptable))
 
     # describe other table
-    all_cols_ot = grass.db_describe(otable, driver = driver, database = database)['cols']
+    all_cols_ot = grass.db_describe(otable, driver=driver, database=database)['cols']
 
     # check if ocolumn is on other table
     if ocolumn not in [ocol[0] for ocol in all_cols_ot]:
-	grass.fatal(_("Column <%s> not found in table <%s>") % (ocolumn, otable))
+        grass.fatal(_("Column <%s> not found in table <%s>") % (ocolumn, otable))
 
     # determine columns subset from other table
     if not scolumns:
@@ -102,8 +103,8 @@
         cols_to_add = all_cols_ot
     else:
         cols_to_add = []
-    	# check if scolumns exists in the other table
-    	for scol in scolumns:
+        # check if scolumns exists in the other table
+        for scol in scolumns:
             found = False
             for col_ot in all_cols_ot:
                 if scol == col_ot[0]:
@@ -111,21 +112,21 @@
                     cols_to_add.append(col_ot)
                     break
             if not found:
-                grass.warning(_("Column <%s> not found in table <%s>.") % (scol, otable))
-    
+                grass.warning(_("Column <%s> not found in table <%s>") % (scol, otable))
+
     all_cols_tt = grass.vector_columns(map, int(layer)).keys()
 
     select = "SELECT $colname FROM $otable WHERE $otable.$ocolumn=$table.$column"
     template = string.Template("UPDATE $table SET $colname=(%s);" % select)
 
     for col in cols_to_add:
-	# skip the vector column which is used for join
-	colname = col[0]
-	if colname == column:
-	    continue
-        
+        # skip the vector column which is used for join
+        colname = col[0]
+        if colname == column:
+            continue
+
         use_len = False
-	if len(col) > 2:
+        if len(col) > 2:
             use_len = True
             # Sqlite 3 does not support the precision number any more
             if driver == "sqlite":
@@ -133,25 +134,25 @@
             # MySQL - expect format DOUBLE PRECISION(M,D), see #2792
             elif driver == "mysql" and col[1] == 'DOUBLE PRECISION':
                 use_len = False
-        
+
         if use_len:
-	    coltype = "%s(%s)" % (col[1], col[2])
-	else:
-	    coltype = "%s" % col[1]
+            coltype = "%s(%s)" % (col[1], col[2])
+        else:
+            coltype = "%s" % col[1]
 
-	colspec = "%s %s" % (colname, coltype)
+        colspec = "%s %s" % (colname, coltype)
 
-	# add only the new column to the table
-	if colname not in all_cols_tt:
+        # add only the new column to the table
+        if colname not in all_cols_tt:
             try:
                 grass.run_command('v.db.addcolumn', map=map,
                                   columns=colspec, layer=layer)
             except CalledModuleError:
                 grass.fatal(_("Error creating column <%s>") % colname)
 
-	stmt = template.substitute(table = maptable, column = column,
-				   otable = otable, ocolumn = ocolumn,
-				   colname = colname)
+        stmt = template.substitute(table=maptable, column=column,
+                                   otable=otable, ocolumn=ocolumn,
+                                   colname=colname)
         grass.debug(stmt, 1)
         grass.verbose(_("Updating column <%s> of vector map <%s>...") % (colname, map))
         try:



More information about the grass-commit mailing list