[GRASS-SVN] r73971 - in grass-addons/grass7/vector: v.civil v.flexure v.habitat.dem v.in.gbif v.in.natura2000 v.in.redlist v.in.survey v.in.wfs2 v.krige v.lidar.mcc v.maxent.swd v.neighborhoodmatrix v.net.curvedarcs v.sort.points
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 17 14:01:13 PST 2019
Author: neteler
Date: 2019-01-17 14:01:13 -0800 (Thu, 17 Jan 2019)
New Revision: 73971
Modified:
grass-addons/grass7/vector/v.civil/road_road.py
grass-addons/grass7/vector/v.flexure/v.flexure.py
grass-addons/grass7/vector/v.habitat.dem/v.habitat.dem.py
grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py
grass-addons/grass7/vector/v.in.natura2000/v.in.natura2000.py
grass-addons/grass7/vector/v.in.redlist/v.in.redlist.py
grass-addons/grass7/vector/v.in.survey/v.in.survey.py
grass-addons/grass7/vector/v.in.wfs2/wfs_base.py
grass-addons/grass7/vector/v.in.wfs2/wfs_owslib_drv.py
grass-addons/grass7/vector/v.krige/v.krige.py
grass-addons/grass7/vector/v.krige/vkrige.py
grass-addons/grass7/vector/v.lidar.mcc/v.lidar.mcc.py
grass-addons/grass7/vector/v.maxent.swd/v.maxent.swd.py
grass-addons/grass7/vector/v.neighborhoodmatrix/v.neighborhoodmatrix.py
grass-addons/grass7/vector/v.net.curvedarcs/v.net.curvedarcs.py
grass-addons/grass7/vector/v.sort.points/v.sort.points.py
Log:
vector addons: Python3 compatibility changes, using 2to3 from python-tools
Modified: grass-addons/grass7/vector/v.civil/road_road.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_road.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.civil/road_road.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -83,7 +83,7 @@
"""
tabla = self.rtab.tables['_Plan']
tabla2 = list(tabla)
- print tabla2
+ print(tabla2)
if table_to_plant:
self.plant = Plant.Plant(self.rtab.polyline, tabla,
Modified: grass-addons/grass7/vector/v.flexure/v.flexure.py
===================================================================
--- grass-addons/grass7/vector/v.flexure/v.flexure.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.flexure/v.flexure.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -206,7 +206,7 @@
col_names = np.array(vect_db['columns'])
q_col = (col_names == options['column'])
if np.sum(q_col):
- col_values = np.array(vect_db['values'].values()).astype(float)
+ col_values = np.array(list(vect_db['values'].values())).astype(float)
flex.q = col_values[:, q_col].squeeze() # Make it 1D for consistency w/ x, y
else:
grass.fatal("provided column name, "+options['column']+" does not match\nany column in "+options['q0']+".")
@@ -240,9 +240,9 @@
flex.latlon = True
flex.PlanetaryRadius = float(grass.parse_command('g.proj', flags='j')['+a'])
if flex.Verbose:
- print "Latitude/longitude grid."
- print "Based on r_Earth = 6371 km"
- print "Computing distances between load points using great circle paths"
+ print("Latitude/longitude grid.")
+ print("Based on r_Earth = 6371 km")
+ print("Computing distances between load points using great circle paths")
##########
# SOLVE! #
@@ -263,7 +263,7 @@
col = int((np.array(wtable.columns.names()) == 'w').nonzero()[0]) # update this column
for i in range(1, len(w)+1):
# ignoring 1st column: assuming it will be category (always true here)
- wnewvalues = w[i].attrs.values()[1:col] + tuple([flex.w[i-1]]) + w[i].attrs.values()[col+1:]
+ wnewvalues = list(w[i].attrs.values())[1:col] + tuple([flex.w[i-1]]) + list(w[i].attrs.values())[col+1:]
wtable.update(key=i, values=wnewvalues)
wtable.conn.commit() # Save this
w.close(build=False) # don't build here b/c it is always verbose
@@ -280,7 +280,7 @@
grass.run_command('r.colors', map=options['raster_output'], color='differences', quiet=True)
def install_dependencies():
- print "PLACEHOLDER"
+ print("PLACEHOLDER")
if __name__ == "__main__":
import sys
Modified: grass-addons/grass7/vector/v.habitat.dem/v.habitat.dem.py
===================================================================
--- grass-addons/grass7/vector/v.habitat.dem/v.habitat.dem.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.habitat.dem/v.habitat.dem.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -116,10 +116,6 @@
from numpy import zeros
import csv
-if not os.environ.has_key("GISBASE"):
- grass.message( "You must be in GRASS GIS to run this program." )
- sys.exit(1)
-
def main():
r_elevation = options['elevation'].split('@')[0]
v_habitat = options['vector'].split('@')[0]
Modified: grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py
===================================================================
--- grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -58,13 +58,9 @@
import tempfile
import grass.script as grass
-if not os.environ.has_key("GISBASE"):
- grass.message( "You must be in GRASS GIS to run this program." )
- sys.exit(1)
def main():
-
gbifraw = options['input']
gbifimported = options['output']
directory = options['dir']
Modified: grass-addons/grass7/vector/v.in.natura2000/v.in.natura2000.py
===================================================================
--- grass-addons/grass7/vector/v.in.natura2000/v.in.natura2000.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.in.natura2000/v.in.natura2000.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -118,9 +118,6 @@
import tempfile
import grass.script as grass
-if not os.environ.has_key("GISBASE"):
- grass.message( "You must be in GRASS GIS to run this program." )
- sys.exit(1)
def main():
Modified: grass-addons/grass7/vector/v.in.redlist/v.in.redlist.py
===================================================================
--- grass-addons/grass7/vector/v.in.redlist/v.in.redlist.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.in.redlist/v.in.redlist.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -65,13 +65,9 @@
import grass.script as grass
from osgeo import ogr
-if not os.environ.has_key("GISBASE"):
- grass.message( "You must be in GRASS GIS to run this program." )
- sys.exit(1)
def main():
-
redlist_shapefile_long = options['input']
imported_species = options['species_name']
species_to_import = options['output']
Modified: grass-addons/grass7/vector/v.in.survey/v.in.survey.py
===================================================================
--- grass-addons/grass7/vector/v.in.survey/v.in.survey.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.in.survey/v.in.survey.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -713,11 +713,11 @@
for num, line in enumerate(fileinput.FileInput(self.filename, # etc
inplace=2)):
if num == 0:
- print "VERTI:"
- print layer.vector + ' ' + str(layer.n_pts)
- print line.strip('\n')
+ print("VERTI:")
+ print(layer.vector + ' ' + str(layer.n_pts))
+ print(line.strip('\n'))
else:
- print line.strip('\n')
+ print(line.strip('\n'))
# ***
return 0
Modified: grass-addons/grass7/vector/v.in.wfs2/wfs_base.py
===================================================================
--- grass-addons/grass7/vector/v.in.wfs2/wfs_base.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.in.wfs2/wfs_base.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -116,8 +116,8 @@
cap_lines = cap.readlines()
for line in cap_lines:
- print line
-
+ print(line)
+
def _computeBbox(self):
"""!Get region extent for WFS query (bbox)
"""
Modified: grass-addons/grass7/vector/v.in.wfs2/wfs_owslib_drv.py
===================================================================
--- grass-addons/grass7/vector/v.in.wfs2/wfs_owslib_drv.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.in.wfs2/wfs_owslib_drv.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -28,7 +28,7 @@
maxfeatures = self.o_maximum_features,
bbox = query_bbox)
#TODO do it better
- except ServiceException, e:
+ except ServiceException as e:
grass.fatal(_("Server returned exception"))
grass.debug(url)
Modified: grass-addons/grass7/vector/v.krige/v.krige.py
===================================================================
--- grass-addons/grass7/vector/v.krige/v.krige.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.krige/v.krige.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -96,7 +96,7 @@
#% description: If omitted, will be <input name>_kriging.var
#% required : no
#%end
-from __future__ import print_function
+
import os
import sys
@@ -392,10 +392,10 @@
#@TODO: let GRASS remount its commandstring. Until then, keep that 4 lines below.
command = ""
notnulloptions = {}
- for k, v in options.items():
+ for k, v in list(options.items()):
if v is not '':
notnulloptions[k] = v
- command = command.join("%s=%s " % (k, v) for k, v in notnulloptions.items())
+ command = command.join("%s=%s " % (k, v) for k, v in list(notnulloptions.items()))
# re-cast integers from strings, as parser() cast everything to string.
for each in ("psill", "nugget", "range", "kappa"):
Modified: grass-addons/grass7/vector/v.krige/vkrige.py
===================================================================
--- grass-addons/grass7/vector/v.krige/vkrige.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.krige/vkrige.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -21,7 +21,7 @@
import sys
# from tempfile import gettempdir
import time
-import thread
+import _thread
from core.utils import _
# dependencies to be checked once, as they are quite
@@ -721,7 +721,7 @@
self.KappaCtrl.SetValue(self.kappa)
# use R plot function, in a separate window.
- thread.start_new_thread(self.plot, ())
+ _thread.start_new_thread(self.plot, ())
def plot(self):
# robjects.r.X11()
@@ -728,7 +728,7 @@
# robjects.r.png("variogram.png")
textplot = robjects.r.plot(self.controller.Variogram['datavariogram'],
self.controller.Variogram['variogrammodel'])
- print textplot
+ print(textplot)
self.refresh()
# robjects.r['dev.off']()
Modified: grass-addons/grass7/vector/v.lidar.mcc/v.lidar.mcc.py
===================================================================
--- grass-addons/grass7/vector/v.lidar.mcc/v.lidar.mcc.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.lidar.mcc/v.lidar.mcc.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -87,10 +87,6 @@
except ImportError:
sys.exit(_("No GRASS-python library found"))
-if not os.environ.has_key("GISBASE"):
- print("You must be in GRASS GIS to run this program.")
- sys.exit(1)
-
GUIModulesPath = os.path.join(os.getenv("GISBASE"), "etc", "gui", "wxpython")
sys.path.append(GUIModulesPath)
@@ -97,9 +93,9 @@
GUIPath = os.path.join(os.getenv("GISBASE"), "etc", "gui", "wxpython", "scripts")
sys.path.append(GUIPath)
-### i18N
+# i18N
import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+gettext.install('grassmods', os.path.join(os.getenv("GISBASE"), 'locale'))
def cleanup():
nuldev = file(os.devnull, 'w')
Modified: grass-addons/grass7/vector/v.maxent.swd/v.maxent.swd.py
===================================================================
--- grass-addons/grass7/vector/v.maxent.swd/v.maxent.swd.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.maxent.swd/v.maxent.swd.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -175,10 +175,6 @@
# Standard
#----------------------------------------------------------------------------
-if not os.environ.has_key("GISBASE"):
- grass.message("You must be in GRASS GIS to run this program.")
- sys.exit(1)
-
# create set to store names of temporary maps to be deleted upon exit
clean_rast = set()
Modified: grass-addons/grass7/vector/v.neighborhoodmatrix/v.neighborhoodmatrix.py
===================================================================
--- grass-addons/grass7/vector/v.neighborhoodmatrix/v.neighborhoodmatrix.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.neighborhoodmatrix/v.neighborhoodmatrix.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -74,7 +74,7 @@
#put result into a list of integer pairs
temp_neighbors=[]
for line in vtodb_results.splitlines():
- if line.split('|')[1]<>'-1' and line.split('|')[2]<>'-1':
+ if line.split('|')[1]!='-1' and line.split('|')[2]!='-1':
temp_neighbors.append([int(line.split('|')[1]), int(line.split('|')[2])])
#temp_neighbors.sort()
@@ -116,12 +116,12 @@
if output and output != '-':
out.write(fromid + sep + toid + '\n')
else:
- print(fromid + sep + toid)
+ print((fromid + sep + toid))
else:
if output and output != '-':
out.write(str(pair[0]) + sep + str(pair[1])+'\n')
else:
- print(str(pair[0]) + sep + str(pair[1]))
+ print((str(pair[0]) + sep + str(pair[1])))
if output and output != '-':
out.close()
Modified: grass-addons/grass7/vector/v.net.curvedarcs/v.net.curvedarcs.py
===================================================================
--- grass-addons/grass7/vector/v.net.curvedarcs/v.net.curvedarcs.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.net.curvedarcs/v.net.curvedarcs.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -110,7 +110,7 @@
if offset < minoffset:
offset = minoffset
y = [math.sin(a)*offset for a in t]
- P = zip(x,y)
+ P = list(zip(x,y))
cat = linecat*10000
for px, py in P:
cat += 1
@@ -145,7 +145,7 @@
header = False
continue
data = line.rstrip().split(separator)
- print data
+ print(data)
if sameok or not (data[0] == data[1]):
fout.write("%s %s %s\n" % (cat, data[0], data[1]))
sqlout.write("UPDATE %s SET from_node = %s, to_node = %s, volume = %s WHERE cat = %d;\n" % (outputfile, data[0], data[1], data[2], cat))
Modified: grass-addons/grass7/vector/v.sort.points/v.sort.points.py
===================================================================
--- grass-addons/grass7/vector/v.sort.points/v.sort.points.py 2019-01-17 21:58:28 UTC (rev 73970)
+++ grass-addons/grass7/vector/v.sort.points/v.sort.points.py 2019-01-17 22:01:13 UTC (rev 73971)
@@ -63,7 +63,7 @@
columns = gscript.vector_columns(inputmap)
key_column = gscript.vector_layer_db(inputmap, layer)['key']
sort_index = columns[sort_column]['index']+2
- sorted_cols = sorted(columns.iteritems(), key=lambda (x, y): y['index'])
+ sorted_cols = sorted(iter(columns.items()), key=lambda x_y: x_y[1]['index'])
column_def="x DOUBLE PRECISION, y DOUBLE PRECISION, cat INTEGER"
colnames = []
for colcount in range(1,len(sorted_cols)):
More information about the grass-commit
mailing list