浏览代码

remove active usages of python xrange which was removed in Python 3

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74100 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 6 年之前
父节点
当前提交
cd09ca6593
共有 3 个文件被更改,包括 12 次插入12 次删除
  1. 1 1
      gui/wxpython/nviz/wxnviz.py
  2. 7 7
      temporal/t.rast.accdetect/t.rast.accdetect.py
  3. 4 4
      tools/ppmrotate.py

+ 1 - 1
gui/wxpython/nviz/wxnviz.py

@@ -836,7 +836,7 @@ class Nviz(object):
         else:
         else:
             nsurfs = c_int()
             nsurfs = c_int()
             surf_list = GS_get_surf_list(byref(nsurfs))
             surf_list = GS_get_surf_list(byref(nsurfs))
-            for i in xrange(nsurfs.value):
+            for i in range(nsurfs.value):
                 id = surf_list[i]
                 id = surf_list[i]
                 GS_set_wire_color(id, color)
                 GS_set_wire_color(id, color)
 
 

+ 7 - 7
temporal/t.rast.accdetect/t.rast.accdetect.py

@@ -156,7 +156,7 @@ def main():
     minimum = options["minimum"]
     minimum = options["minimum"]
     maximum = options["maximum"]
     maximum = options["maximum"]
     occurrence = options["occurrence"]
     occurrence = options["occurrence"]
-    range = options["range"]
+    range_ = options["range"]
     indicator = options["indicator"]
     indicator = options["indicator"]
     staend = options["staend"]
     staend = options["staend"]
     register_null = flags["n"]
     register_null = flags["n"]
@@ -191,7 +191,7 @@ def main():
     # The occurrence space time raster dataset
     # The occurrence space time raster dataset
     if occurrence:
     if occurrence:
         if not minimum or not maximum:
         if not minimum or not maximum:
-            if not range:
+            if not range_:
                 dbif.close()
                 dbif.close()
                 grass.fatal(_("You need to set the range to compute the occurrence"
                 grass.fatal(_("You need to set the range to compute the occurrence"
                               " space time raster dataset"))
                               " space time raster dataset"))
@@ -320,14 +320,14 @@ def main():
 
 
         count = compute_occurrence(occurrence_maps, input_strds, input_maps,
         count = compute_occurrence(occurrence_maps, input_strds, input_maps,
                                    start, base, count, time_suffix, mapset,
                                    start, base, count, time_suffix, mapset,
-                                   where, reverse, range, minimum_strds,
+                                   where, reverse, range_, minimum_strds,
                                    maximum_strds, dbif)
                                    maximum_strds, dbif)
 
 
         # Indicator computation is based on the occurrence so we need to start it after
         # Indicator computation is based on the occurrence so we need to start it after
         # the occurrence cycle
         # the occurrence cycle
         if indicator:
         if indicator:
             num_maps = len(input_maps)
             num_maps = len(input_maps)
-            for i in xrange(num_maps):
+            for i in range(num_maps):
                 if reverse:
                 if reverse:
                     map = input_maps[num_maps - i - 1]
                     map = input_maps[num_maps - i - 1]
                 else:
                 else:
@@ -492,7 +492,7 @@ def create_strds_register_maps(in_strds, out_strds, out_maps, register_null,
 ############################################################################
 ############################################################################
 
 
 def compute_occurrence(occurrence_maps, input_strds, input_maps, start, base,
 def compute_occurrence(occurrence_maps, input_strds, input_maps, start, base,
-                       count, tsuffix, mapset, where, reverse, range,
+                       count, tsuffix, mapset, where, reverse, range_,
                        minimum_strds, maximum_strds, dbif):
                        minimum_strds, maximum_strds, dbif):
 
 
     if minimum_strds:
     if minimum_strds:
@@ -511,7 +511,7 @@ def compute_occurrence(occurrence_maps, input_strds, input_maps, start, base,
 
 
     # Aggregate
     # Aggregate
     num_maps = len(input_maps)
     num_maps = len(input_maps)
-    for i in xrange(num_maps):
+    for i in range(num_maps):
         if reverse:
         if reverse:
             map = input_maps[num_maps - i - 1]
             map = input_maps[num_maps - i - 1]
         else:
         else:
@@ -550,7 +550,7 @@ def compute_occurrence(occurrence_maps, input_strds, input_maps, start, base,
                              " database, use overwrite flag to overwrite.") %
                              " database, use overwrite flag to overwrite.") %
                             (occurrence_map.get_map_id()))
                             (occurrence_map.get_map_id()))
 
 
-        range_vals = range.split(",")
+        range_vals = range_.split(",")
         min = range_vals[0]
         min = range_vals[0]
         max = range_vals[1]
         max = range_vals[1]
 
 

+ 4 - 4
tools/ppmrotate.py

@@ -68,9 +68,9 @@ def write_ppm(dst, data):
 
 
 def rotate_ppm(srcd):
 def rotate_ppm(srcd):
     dstd = array.array('B', len(srcd) * '\0')
     dstd = array.array('B', len(srcd) * '\0')
-    for y in xrange(height):
-        for x in xrange(width):
-            for c in xrange(3):
+    for y in range(height):
+        for x in range(width):
+            for c in range(3):
                 old_pos = (y * width + x) * 3 + c
                 old_pos = (y * width + x) * 3 + c
                 new_pos = (x * height + (height - 1 - y)) * 3 + c
                 new_pos = (x * height + (height - 1 - y)) * 3 + c
                 dstd[new_pos] = srcd[old_pos]
                 dstd[new_pos] = srcd[old_pos]
@@ -80,7 +80,7 @@ def rotate_ppm(srcd):
 def flip_ppm(srcd):
 def flip_ppm(srcd):
     dstd = array.array('B', len(srcd) * '\0')
     dstd = array.array('B', len(srcd) * '\0')
     stride = width * 3
     stride = width * 3
-    for y in xrange(height):
+    for y in range(height):
         dy = (height - 1 - y)
         dy = (height - 1 - y)
         dstd[dy * stride:(dy + 1) * stride] = srcd[y * stride:(y + 1) * stride]
         dstd[dy * stride:(dy + 1) * stride] = srcd[y * stride:(y + 1) * stride]
     return dstd
     return dstd