[Git][debian-gis-team/grass][master] Add patch to fix SyntaxWarning & SyntaxError issues with Python 3.8.

Bas Couwenberg gitlab at salsa.debian.org
Sat Apr 25 10:08:08 BST 2020



Bas Couwenberg pushed to branch master at Debian GIS Project / grass


Commits:
9ab9396e by Bas Couwenberg at 2020-04-25T11:07:48+02:00
Add patch to fix SyntaxWarning & SyntaxError issues with Python 3.8.

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/python3.8.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -4,6 +4,7 @@ grass (7.8.2-2) UNRELEASED; urgency=medium
   * Bump Standards-Version to 4.5.0, no changes.
   * Bump debhelper compat to 10, changes:
     - Drop --parallel option, enabled by default
+  * Add patch to fix SyntaxWarning & SyntaxError issues with Python 3.8.
 
  -- Bas Couwenberg <sebastic at debian.org>  Wed, 15 Jan 2020 16:20:26 +0100
 


=====================================
debian/patches/python3.8.patch
=====================================
@@ -0,0 +1,302 @@
+Description: Fix SyntaxWarning & SyntaxError issues with Python 3.8.
+Author: Bas Couwenberg <sebastic at debian.org>
+Forwarded: https://github.com/OSGeo/grass/pull/549
+
+--- a/gui/wxpython/core/gconsole.py
++++ b/gui/wxpython/core/gconsole.py
+@@ -597,7 +597,7 @@ class GConsole(wx.EvtHandler):
+                     for line in sfile.readlines():
+                         if len(line) < 2:
+                             continue
+-                        if line[0] is '#' and line[1] is '%':
++                        if line[0] == '#' and line[1] == '%':
+                             skipInterface = False
+                             break
+                     sfile.close()
+--- a/gui/wxpython/dbmgr/vinfo.py
++++ b/gui/wxpython/dbmgr/vinfo.py
+@@ -167,7 +167,7 @@ class VectorDBInfo(VectorDBInfoBase):
+ 
+         table = self.layers[layer]["table"]  # get table desc
+         # select values (only one record)
+-        if where is None or where is '':
++        if where is None or where == '':
+             sql = "SELECT %s FROM %s" % (cols, table)
+         else:
+             sql = "SELECT %s FROM %s WHERE %s" % (cols, table, where)
+--- a/gui/wxpython/gmodeler/model.py
++++ b/gui/wxpython/gmodeler/model.py
+@@ -258,7 +258,7 @@ class Model(object):
+         for data in self.GetData():
+             if prompt == data.GetPrompt():
+                 mapName = data.GetValue()
+-                if not mapName or mapName[0] is '%':
++                if not mapName or mapName[0] == '%':
+                     continue  # skip variables
+                 maps.append(mapName)
+ 
+--- a/gui/wxpython/gui_core/gselect.py
++++ b/gui/wxpython/gui_core/gselect.py
+@@ -1865,7 +1865,7 @@ class GdalSelect(wx.Panel):
+         self.changingSizer.Show(
+             self.protocolPanel, show=(
+             sourceType == 'pro'))
+-        self.changingSizer.Show(self.dbPanel, show=(sourceType is 'db'))
++        self.changingSizer.Show(self.dbPanel, show=(sourceType == 'db'))
+ 
+         self.changingSizer.Layout()
+ 
+--- a/gui/wxpython/location_wizard/wizard.py
++++ b/gui/wxpython/location_wizard/wizard.py
+@@ -1303,7 +1303,7 @@ class EllipsePage(TitledPage):
+         try:
+             self.ellipse, self.ellipsedesc = self.ellipselist.Search(
+                 index=[0, 1], pattern=event.GetString())
+-            if self.scope is 'earth':
++            if self.scope == 'earth':
+                 self.ellipseparams = self.parent.ellipsoids[self.ellipse][1]
+             else:
+                 self.ellipseparams = self.parent.planetary_ellipsoids[
+--- a/imagery/i.atcorr/create_iwave.py
++++ b/imagery/i.atcorr/create_iwave.py
+@@ -31,21 +31,21 @@ from scipy import interpolate
+ 
+ def usage():
+     """How to use this..."""
+-    print "create_iwave.py <csv file>"
++    print("create_iwave.py <csv file>")
+     print
+-    print "Generates filter function template for iwave.cpp from csv file. Note:"
+-    print "- csv file must have wl response for each band in each column"
+-    print "- first line must be a header with wl followed by band names"
+-    print "- all following lines will be the data."
+-    print "If spectral response is null, leave field empty in csv file. Example:"
++    print("Generates filter function template for iwave.cpp from csv file. Note:")
++    print("- csv file must have wl response for each band in each column")
++    print("- first line must be a header with wl followed by band names")
++    print("- all following lines will be the data.")
++    print("If spectral response is null, leave field empty in csv file. Example:")
+     print
+-    print "WL(nm),band 1,band 2,band 3,band 4"
+-    print "455,0.93,,,"
+-    print "485,0.94,0.00,,"
+-    print "545,0.00,0.87,0.00,"
++    print("WL(nm),band 1,band 2,band 3,band 4")
++    print("455,0.93,,,")
++    print("485,0.94,0.00,,")
++    print("545,0.00,0.87,0.00,")
+     print
+-    print "This script will interpolate the filter functions to 2.5 nm steps"
+-    print "and output a cpp template file in the IWave format to be added to iwave.cpp"
++    print("This script will interpolate the filter functions to 2.5 nm steps")
++    print("and output a cpp template file in the IWave format to be added to iwave.cpp")
+ 
+ def read_input(csvfile):
+     """
+@@ -64,7 +64,7 @@ def read_input(csvfile):
+     bands = infile.readline().split(',')
+     bands.remove(bands[0])
+     bands[-1] = bands[-1].strip()
+-    print " > Number of bands found: %d" % len(bands)
++    print(" > Number of bands found: %d" % len(bands))
+     infile.close()
+ 
+     # create converter dictionary for import
+@@ -197,7 +197,7 @@ def write_cpp(bands, values, sensor, fol
+     # keep in sync with IWave::parse()
+     rthresh = 0.01
+     print 
+-    print " > Response peaks from interpolation to 2.5 nm steps:"
++    print(" > Response peaks from interpolation to 2.5 nm steps:")
+ 
+     # getting necessary data
+     # single or multiple bands?
+@@ -218,7 +218,7 @@ def write_cpp(bands, values, sensor, fol
+  	while c < len(fi) - 1 and fi[c + 1] > rthresh:
+ 	    c = c + 1
+  	max_wavelength = np.floor(li[0] * 1000 + (2.5 * c))
+- 	print "   %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength)
++ 	print("   %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength))
+ 
+     else:
+         filter_f = []
+@@ -240,7 +240,7 @@ def write_cpp(bands, values, sensor, fol
+ 	    while c < len(fi) - 1 and fi[c + 1] > rthresh:
+ 		c = c + 1
+ 	    max_wavelength = np.floor(li[0] * 1000 + (2.5 * c))
+-	    print "   %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength)
++	    print("   %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength))
+     
+     # writing...
+     outfile = open(os.path.join(folder, sensor+"_cpp_template.txt"), 'w')
+@@ -314,7 +314,7 @@ def main():
+     sensor = os.path.splitext(os.path.basename(inputfile))[0]
+     
+     print
+-    print " > Getting sensor name from csv file: %s" % (sensor)
++    print(" > Getting sensor name from csv file: %s" % (sensor))
+     
+     # getting data from file
+     bands, values = read_input(inputfile)
+@@ -324,7 +324,7 @@ def main():
+     # around the peak response, keep in sync with IWave::parse()
+     rthresh = 0.01
+     print
+-    print " > Response peaks from input file:"
++    print(" > Response peaks from input file:")
+     for b in range(1, len(bands) + 1):
+ 	lowl = 0
+ 	hiwl = 0
+@@ -346,15 +346,15 @@ def main():
+ 	    hiwl = values[i,0]
+ 	    i += 1
+ 	
+-	print "   %s (%inm - %inm)" % (bands[b - 1], lowl, hiwl)
++	print("   %s (%inm - %inm)" % (bands[b - 1], lowl, hiwl))
+ 
+     # writing file in same folder of input file
+     write_cpp(bands, values, sensor, os.path.dirname(inputfile))
+     
+     print
+-    print " > Filter functions exported to %s" % ("sensors_csv/"+sensor+"_cpp_template.txt")
+-    print " > Please check this file for possible errors before inserting the code into file iwave.cpp"
+-    print " > Don't forget to add the necessary data to the files iwave.h, geomcond.h, geomcond.cpp, and to i.atcorr.html"
++    print(" > Filter functions exported to %s" % ("sensors_csv/"+sensor+"_cpp_template.txt"))
++    print(" > Please check this file for possible errors before inserting the code into file iwave.cpp")
++    print(" > Don't forget to add the necessary data to the files iwave.h, geomcond.h, geomcond.cpp, and to i.atcorr.html")
+     print
+     
+     return
+--- a/lib/python/pygrass/gis/__init__.py
++++ b/lib/python/pygrass/gis/__init__.py
+@@ -72,7 +72,7 @@ def _check_raise(value, path, type):
+              if value is empty return environmental variable
+     :rtype: str
+     """
+-    if value is '':
++    if value == '':
+         from grass.pygrass.utils import getenv
+         return getenv(type)
+     if is_valid(value, path, type):
+--- a/lib/python/temporal/core.py
++++ b/lib/python/temporal/core.py
+@@ -62,7 +62,7 @@ def profile_function(func):
+     """Profiling function provided by the temporal framework"""
+     do_profiling = os.getenv("GRASS_TGIS_PROFILE")
+ 
+-    if do_profiling is "True" or do_profiling is "1":
++    if do_profiling == "True" or do_profiling == "1":
+         import cProfile, pstats
+         try:
+             import StringIO as io
+@@ -579,7 +579,7 @@ def init(raise_fatal_error=False):
+             enable_timestamp_write = False
+             msgr.warning("TGIS_DISABLE_TIMESTAMP_WRITE is True")
+ 
+-    if driver_string is not None and driver_string is not "":
++    if driver_string is not None and driver_string != "":
+         driver_string = decode(driver_string)
+         if driver_string == "sqlite":
+             tgis_backend = driver_string
+--- a/lib/python/temporal/temporal_algebra.py
++++ b/lib/python/temporal/temporal_algebra.py
+@@ -2292,7 +2292,7 @@ class TemporalAlgebraParser(object):
+                             # Do not register empty maps if not required
+                             # In case of a null map continue, do not register null maps
+ 
+-                            if map_i.get_type() is "raster" or map_i.get_type() is "raster3d":
++                            if map_i.get_type() == "raster" or map_i.get_type() == "raster3d":
+                                 if map_i.metadata.get_min() is None and \
+                                    map_i.metadata.get_max() is None:
+                                     if not self.register_null:
+--- a/doc/python/raster_example_ctypes.py
++++ b/doc/python/raster_example_ctypes.py
+@@ -52,7 +52,7 @@ elif data_type == DCELL_TYPE:
+     ptype = POINTER(c_double)
+     type_name = 'DCELL'
+ 
+-print "Raster map <%s> contains data type %s." % (input, type_name)
++print("Raster map <%s> contains data type %s." % (input, type_name))
+ 
+ in_fd   = Rast_open_old(input, mapset)
+ in_rast = Rast_allocate_buf(data_type)
+@@ -60,14 +60,14 @@ in_rast = cast(c_void_p(in_rast), ptype)
+ 
+ rows = Rast_window_rows()
+ cols = Rast_window_cols()
+-print "Current region is %d rows x %d columns" % (rows, cols)
++print("Current region is %d rows x %d columns" % (rows, cols))
+ 
+ # iterate through map rows
+-print "Map data:"
++print("Map data:")
+ for row_n in range(rows):
+     # read a row of raster data into memory, then print it
+     Rast_get_row(in_fd, in_rast, row_n, data_type)
+-    print row_n, in_rast[0:cols]
++    print(row_n, in_rast[0:cols])
+     # TODO check for NULL
+ 
+ # closed map and cleanup memory allocation
+--- a/doc/python/vector_example_ctypes.py
++++ b/doc/python/vector_example_ctypes.py
+@@ -36,10 +36,10 @@ Vect_set_open_level(2)
+ Vect_open_old(map_info, input, mapset)
+ 
+ # query
+-print 'Vector map        :', Vect_get_full_name(map_info)
+-print 'Vector is 3D      :', Vect_is_3d(map_info)
+-print 'Vector DB links   :', Vect_get_num_dblinks(map_info)
+-print 'Map Scale         : 1:%d' % Vect_get_scale(map_info)
++print('Vector map        :', Vect_get_full_name(map_info))
++print('Vector is 3D      :', Vect_is_3d(map_info))
++print('Vector DB links   :', Vect_get_num_dblinks(map_info))
++print('Map Scale         : 1:%d' % Vect_get_scale(map_info))
+ 
+ # vector box tests
+ box = bound_box()
+@@ -48,13 +48,13 @@ c_northing  = 4921010.0
+ c_easting2  = 4599505.0
+ 
+ Vect_get_map_box(map_info, byref(box))
+-print 'Position 1 in box ?', Vect_point_in_box(c_easting1, c_northing, 0, byref(box))
+-print 'Position 2 in box ?', Vect_point_in_box(c_easting2, c_northing, 0, byref(box))
++print('Position 1 in box ?', Vect_point_in_box(c_easting1, c_northing, 0, byref(box)))
++print('Position 2 in box ?', Vect_point_in_box(c_easting2, c_northing, 0, byref(box)))
+ 
+-print 'Number of features:', Vect_get_num_lines(map_info)
+-print 'Number of points  :', Vect_get_num_primitives(map_info, GV_POINT)
+-print 'Number of lines   :', Vect_get_num_primitives(map_info, GV_LINE)
+-print 'Number of areas   :', Vect_get_num_areas(map_info)
++print('Number of features:', Vect_get_num_lines(map_info))
++print('Number of points  :', Vect_get_num_primitives(map_info, GV_POINT))
++print('Number of lines   :', Vect_get_num_primitives(map_info, GV_LINE))
++print('Number of areas   :', Vect_get_num_areas(map_info))
+ 
+ # close map
+ Vect_close(map_info)
+--- a/doc/python/m.distance.py
++++ b/doc/python/m.distance.py
+@@ -119,11 +119,11 @@ def main():
+         segment_distance = G_distance(x[i-1], y[i-1], x[i], y[i])
+         overall_distance += segment_distance
+         
+-        print "segment %d distance is %.2f meters" % (i, segment_distance)
++        print("segment %d distance is %.2f meters" % (i, segment_distance))
+         
+         # add to the area array
+     
+-    print "\ntotal distance is %.2f meters\n" % overall_distance
++    print("\ntotal distance is %.2f meters\n" % overall_distance)
+     
+     # calc area
+     if len(coords) < 3:
+@@ -136,7 +136,7 @@ def main():
+ 
+     # do not need to close polygon (but it doesn't hurt if you do)
+     area = G_area_of_polygon(x, y, len(coords))
+-    print "area is %.2f square meters\n" % area
++    print("area is %.2f square meters\n" % area)
+     
+     # we don't need this, but just to have a look
+     if proj_type == 1:


=====================================
debian/patches/series
=====================================
@@ -2,3 +2,4 @@ pager
 instdir
 no-fail-html.patch
 jquery.patch
+python3.8.patch



View it on GitLab: https://salsa.debian.org/debian-gis-team/grass/-/commit/9ab9396ef2f210d4b2997240cf04775e2dd0cfac

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/grass/-/commit/9ab9396ef2f210d4b2997240cf04775e2dd0cfac
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200425/4792dc82/attachment-0001.html>


More information about the Pkg-grass-devel mailing list