[GRASS-SVN] r68359 - in grass/trunk/temporal: t.info t.list t.rast.accumulate t.rast.aggregate/testsuite t.rast.neighbors t.rast.to.rast3 t.rast.what t.register t.topology t.vect.db.select t.vect.observe.strds
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 2 09:08:53 PDT 2016
Author: zarch
Date: 2016-05-02 09:08:53 -0700 (Mon, 02 May 2016)
New Revision: 68359
Modified:
grass/trunk/temporal/t.info/t.info.py
grass/trunk/temporal/t.list/t.list.py
grass/trunk/temporal/t.rast.accumulate/t.rast.accumulate.py
grass/trunk/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py
grass/trunk/temporal/t.rast.neighbors/t.rast.neighbors.py
grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
grass/trunk/temporal/t.rast.what/t.rast.what.py
grass/trunk/temporal/t.register/t.register.py
grass/trunk/temporal/t.topology/t.topology.py
grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py
grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py
Log:
temporal modules: Update syntax to be compatible with python3 and python2
Modified: grass/trunk/temporal/t.info/t.info.py
===================================================================
--- grass/trunk/temporal/t.info/t.info.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.info/t.info.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -47,8 +47,8 @@
#% description: Print information about the temporal DBMI interface and exit
#% suppress_required: yes
#%end
+from __future__ import print_function
-
import grass.script as grass
import grass.temporal as tgis
@@ -73,24 +73,24 @@
if system and not shellstyle:
# 0123456789012345678901234567890
- print " +------------------- Temporal DBMI backend information ----------------------+"
- print " | DBMI Python interface:...... " + str(dbif.get_dbmi().__name__)
- print " | Temporal database string:... " + str(
- tgis.get_tgis_database_string())
- print " | SQL template path:.......... " + str(
- tgis.get_sql_template_path())
+ print(" +------------------- Temporal DBMI backend information ----------------------+")
+ print(" | DBMI Python interface:...... " + str(dbif.get_dbmi().__name__))
+ print(" | Temporal database string:... " + str(
+ tgis.get_tgis_database_string()))
+ print(" | SQL template path:.......... " + str(
+ tgis.get_sql_template_path()))
if rows:
for row in rows:
- print " | %s .......... %s"%(row[0], row[1])
- print " +----------------------------------------------------------------------------+"
+ print(" | %s .......... %s"%(row[0], row[1]))
+ print(" +----------------------------------------------------------------------------+")
return
elif system:
- print "dbmi_python_interface=\'" + str(dbif.get_dbmi().__name__) + "\'"
- print "dbmi_string=\'" + str(tgis.get_tgis_database_string()) + "\'"
- print "sql_template_path=\'" + str(tgis.get_sql_template_path()) + "\'"
+ print("dbmi_python_interface=\'" + str(dbif.get_dbmi().__name__) + "\'")
+ print("dbmi_string=\'" + str(tgis.get_tgis_database_string()) + "\'")
+ print("sql_template_path=\'" + str(tgis.get_sql_template_path()) + "\'")
if rows:
for row in rows:
- print "%s=\'%s\'"%(row[0], row[1])
+ print("%s=\'%s\'"%(row[0], row[1]))
return
if not system and not name:
Modified: grass/trunk/temporal/t.list/t.list.py
===================================================================
--- grass/trunk/temporal/t.list/t.list.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.list/t.list.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -80,7 +80,7 @@
#% description: Print the column names as first row
#% guisection: Formatting
#%end
-
+from __future__ import print_function
import grass.script as gscript
import grass.temporal as tgis
import sys
@@ -153,7 +153,7 @@
if outpath:
outfile.write("{st}\n".format(st=output))
else:
- print output
+ print(output)
first = False
for row in rows:
@@ -168,7 +168,7 @@
if outpath:
outfile.write("{st}\n".format(st=output))
else:
- print output
+ print(output)
if outpath:
outfile.close()
dbif.close()
Modified: grass/trunk/temporal/t.rast.accumulate/t.rast.accumulate.py
===================================================================
--- grass/trunk/temporal/t.rast.accumulate/t.rast.accumulate.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.rast.accumulate/t.rast.accumulate.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -146,8 +146,8 @@
#% key: r
#% description: Reverse time direction in cyclic accumulation
#%end
+from __future__ import print_function
-
import grass.script as grass
import grass.temporal as tgis
from grass.pygrass.modules import Module
@@ -357,7 +357,7 @@
# Aggregate
num_maps = len(gran_list)
- for i in xrange(num_maps):
+ for i in range(num_maps):
if reverse:
map = gran_list[num_maps - i - 1]
else:
@@ -458,7 +458,7 @@
if method:
accmod.inputs["method"].value = method
- print accmod
+ print(accmod)
accmod.run()
if accmod.popen.returncode != 0:
Modified: grass/trunk/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py
===================================================================
--- grass/trunk/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -7,6 +7,8 @@
:authors: Soeren Gebbert
"""
+from __future__ import print_function
+
import os
import grass.pygrass.modules as pymod
import grass.temporal as tgis
@@ -86,7 +88,7 @@
end = datetime.now()
delta = end - start
- print "test_aggregation_1day_4procs:", delta.total_seconds()
+ print("test_aggregation_1day_4procs:", delta.total_seconds())
tinfo_string="""start_time=2001-01-01 00:00:00
end_time=2001-04-01 00:00:00
@@ -111,7 +113,7 @@
end = datetime.now()
delta = end - start
- print "test_aggregation_1day_3procs:", delta.total_seconds()
+ print("test_aggregation_1day_3procs:", delta.total_seconds())
tinfo_string="""start_time=2001-01-01 00:00:00
@@ -141,7 +143,7 @@
end = datetime.now()
delta = end - start
- print "test_aggregation_1day_2procs:", delta.total_seconds()
+ print("test_aggregation_1day_2procs:", delta.total_seconds())
tinfo_string="""start_time=2001-01-01 00:00:00
Modified: grass/trunk/temporal/t.rast.neighbors/t.rast.neighbors.py
===================================================================
--- grass/trunk/temporal/t.rast.neighbors/t.rast.neighbors.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.rast.neighbors/t.rast.neighbors.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -83,6 +83,7 @@
#% key: n
#% description: Register Null maps
#%end
+from __future__ import print_function
import copy
import grass.script as grass
Modified: grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py
===================================================================
--- grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.rast.to.rast3/t.rast.to.rast3.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -29,6 +29,7 @@
#%option G_OPT_R3_OUTPUT
#%end
+from __future__ import print_function
import os
import grass.script as grass
@@ -85,7 +86,7 @@
unit = granularity.split(" ")[1]
granularity = float(granularity.split(" ")[0])
- print "Gran from stds %0.15f"%(granularity)
+ print("Gran from stds %0.15f"%(granularity))
if unit == "years" or unit == "year":
bottom = float(start.year - 1900)
Modified: grass/trunk/temporal/t.rast.what/t.rast.what.py
===================================================================
--- grass/trunk/temporal/t.rast.what/t.rast.what.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.rast.what/t.rast.what.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -392,13 +392,13 @@
first = False
- for col in xrange(num_cols - 3):
+ for col in range(num_cols - 3):
start, end = output_time_list[count][col].get_temporal_extent_as_tuple()
time_string = "%(start)s%(sep)s%(end)s"\
%({"start":str(start), "end":str(end),
"sep":separator})
out_file.write(time_string)
- for row in xrange(len(matrix)):
+ for row in range(len(matrix)):
value = matrix[row][col + 3]
out_file.write("%(sep)s%(value)s"\
%({"sep":separator,
@@ -448,7 +448,7 @@
lines = in_file.readlines()
- for i in xrange(len(lines)):
+ for i in range(len(lines)):
cols = lines[i].split(separator)
if first is True:
Modified: grass/trunk/temporal/t.register/t.register.py
===================================================================
--- grass/trunk/temporal/t.register/t.register.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.register/t.register.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -132,6 +132,12 @@
options, flags = grass.parser()
try:
+ from builtins import StandardError
+ except ImportError:
+ # python 3
+ StandardError = Exception
+
+ try:
tgis.profile_function(main)
except StandardError as e:
grass.fatal(e)
Modified: grass/trunk/temporal/t.topology/t.topology.py
===================================================================
--- grass/trunk/temporal/t.topology/t.topology.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.topology/t.topology.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -41,6 +41,7 @@
#% key: s
#% description: Print spatio-temporal relationships and exit
#%end
+from __future__ import print_function
import grass.script as grass
import grass.temporal as tgis
@@ -81,73 +82,73 @@
sp.base.print_info()
# 0123456789012345678901234567890
- print " +-------------------- Temporal topology -------------------------------------+"
+ print(" +-------------------- Temporal topology -------------------------------------+")
if where:
- print " | Is subset of dataset: ...... True"
+ print(" | Is subset of dataset: ...... True")
else:
- print " | Is subset of dataset: ...... False"
+ print(" | Is subset of dataset: ...... False")
check = sp.check_temporal_topology(maps)
if check:
# 0123456789012345678901234567890
- print " | Temporal topology is: ...... valid"
+ print(" | Temporal topology is: ...... valid")
else:
# 0123456789012345678901234567890
- print " | Temporal topology is: ...... invalid"
+ print(" | Temporal topology is: ...... invalid")
dict_ = sp.count_temporal_types(maps)
for key in dict_.keys():
if key == "interval":
# 0123456789012345678901234567890
- print " | Number of intervals: ....... %s" % (dict_[key])
+ print(" | Number of intervals: ....... %s" % (dict_[key]))
if key == "point":
- print " | Number of points: .......... %s" % (dict_[key])
+ print(" | Number of points: .......... %s" % (dict_[key]))
if key == "invalid":
- print " | Invalid time stamps: ....... %s" % (dict_[key])
+ print(" | Invalid time stamps: ....... %s" % (dict_[key]))
# 0123456789012345678901234567890
- print " | Number of gaps: ............ %i" % sp.count_gaps(maps)
+ print(" | Number of gaps: ............ %i" % sp.count_gaps(maps))
if sp.is_time_absolute():
gran = tgis.compute_absolute_time_granularity(maps)
else:
gran = tgis.compute_relative_time_granularity(maps)
- print " | Granularity: ............... %s" % str(gran)
+ print(" | Granularity: ............... %s" % str(gran))
- print " +-------------------- Topological relations ---------------------------------+"
+ print(" +-------------------- Topological relations ---------------------------------+")
dict_ = sp.count_temporal_relations(maps)
if dict_:
for key in dict_.keys():
if key == "equal":
# 0123456789012345678901234567890
- print " | Equal:...................... %s" % (dict_[key])
+ print(" | Equal:...................... %s" % (dict_[key]))
if key == "during":
- print " | During: .................... %s" % (dict_[key])
+ print(" | During: .................... %s" % (dict_[key]))
if key == "contains":
- print " | Contains: .................. %s" % (dict_[key])
+ print(" | Contains: .................. %s" % (dict_[key]))
if key == "overlaps":
- print " | Overlaps: .................. %s" % (dict_[key])
+ print(" | Overlaps: .................. %s" % (dict_[key]))
if key == "overlapped":
- print " | Overlapped: ................ %s" % (dict_[key])
+ print(" | Overlapped: ................ %s" % (dict_[key]))
if key == "after":
- print " | After: ..................... %s" % (dict_[key])
+ print(" | After: ..................... %s" % (dict_[key]))
if key == "before":
- print " | Before: .................... %s" % (dict_[key])
+ print(" | Before: .................... %s" % (dict_[key]))
if key == "starts":
- print " | Starts: .................... %s" % (dict_[key])
+ print(" | Starts: .................... %s" % (dict_[key]))
if key == "finishes":
- print " | Finishes: .................. %s" % (dict_[key])
+ print(" | Finishes: .................. %s" % (dict_[key]))
if key == "started":
- print " | Started: ................... %s" % (dict_[key])
+ print(" | Started: ................... %s" % (dict_[key]))
if key == "finished":
- print " | Finished: .................. %s" % (dict_[key])
+ print(" | Finished: .................. %s" % (dict_[key]))
if key == "follows":
- print " | Follows: ................... %s" % (dict_[key])
+ print(" | Follows: ................... %s" % (dict_[key]))
if key == "precedes":
- print " | Precedes: .................. %s" % (dict_[key])
- print " +----------------------------------------------------------------------------+"
+ print(" | Precedes: .................. %s" % (dict_[key]))
+ print(" +----------------------------------------------------------------------------+")
if __name__ == "__main__":
options, flags = grass.parser()
Modified: grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py
===================================================================
--- grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.vect.db.select/t.vect.db.select.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -43,6 +43,7 @@
#%option G_OPT_T_WHERE
#% key: t_where
#%end
+from __future__ import print_function
import grass.script as grass
import grass.temporal as tgis
@@ -101,14 +102,14 @@
separator, separator, entry)
if col_names != col_names_new:
col_names = col_names_new
- print col_names
+ print(col_names)
else:
if row["end_time"]:
- print "%s%s%s%s%s" % (row["start_time"], separator,
- row["end_time"], separator, entry)
+ print("%s%s%s%s%s" % (row["start_time"], separator,
+ row["end_time"], separator, entry))
else:
- print "%s%s%s%s" % (row["start_time"],
- separator, separator, entry)
+ print("%s%s%s%s" % (row["start_time"],
+ separator, separator, entry))
count += 1
if __name__ == "__main__":
Modified: grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py
===================================================================
--- grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py 2016-05-02 16:08:34 UTC (rev 68358)
+++ grass/trunk/temporal/t.vect.observe.strds/t.vect.observe.strds.py 2016-05-02 16:08:53 UTC (rev 68359)
@@ -139,7 +139,7 @@
strds_names[0], False, None,
"equal", False, False)
- for i in xrange(len(mapmatrizes[0])):
+ for i in range(len(mapmatrizes[0])):
isvalid = True
mapname_list = []
for mapmatrix in mapmatrizes:
More information about the grass-commit
mailing list