Skip to content

Commit 895dc88

Browse files
mhall1timgraham
authored andcommitted
Fixed #23812 -- Changed django.utils.six.moves.xrange imports to range
1 parent a5499b0 commit 895dc88

File tree

27 files changed

+95
-94
lines changed

27 files changed

+95
-94
lines changed

django/contrib/gis/gdal/datasource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
from django.utils.encoding import force_bytes, force_text
4949
from django.utils import six
50-
from django.utils.six.moves import xrange
50+
from django.utils.six.moves import range
5151

5252

5353
# For more information, see the OGR C API source code:
@@ -98,7 +98,7 @@ def __del__(self):
9898

9999
def __iter__(self):
100100
"Allows for iteration over the layers in a data source."
101-
for i in xrange(self.layer_count):
101+
for i in range(self.layer_count):
102102
yield self[i]
103103

104104
def __getitem__(self, index):

django/contrib/gis/gdal/feature.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from django.utils.encoding import force_bytes, force_text
1111
from django.utils import six
12-
from django.utils.six.moves import xrange
12+
from django.utils.six.moves import range
1313

1414

1515
# For more information, see the OGR C API source code:
@@ -54,7 +54,7 @@ def __getitem__(self, index):
5454

5555
def __iter__(self):
5656
"Iterates over each field in the Feature."
57-
for i in xrange(self.num_fields):
57+
for i in range(self.num_fields):
5858
yield self[i]
5959

6060
def __len__(self):
@@ -94,7 +94,7 @@ def num_fields(self):
9494
def fields(self):
9595
"Returns a list of fields in the Feature."
9696
return [capi.get_field_name(capi.get_field_defn(self._layer._ldefn, i))
97-
for i in xrange(self.num_fields)]
97+
for i in range(self.num_fields)]
9898

9999
@property
100100
def geom(self):

django/contrib/gis/gdal/geometries.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex
5858

5959
from django.utils import six
60-
from django.utils.six.moves import xrange
60+
from django.utils.six.moves import range
6161

6262
# For more information, see the OGR C API source code:
6363
# http://www.gdal.org/ogr/ogr__api_8h.html
@@ -546,7 +546,7 @@ def __getitem__(self, index):
546546

547547
def __iter__(self):
548548
"Iterates over each point in the LineString."
549-
for i in xrange(self.point_count):
549+
for i in range(self.point_count):
550550
yield self[i]
551551

552552
def __len__(self):
@@ -556,15 +556,15 @@ def __len__(self):
556556
@property
557557
def tuple(self):
558558
"Returns the tuple representation of this LineString."
559-
return tuple(self[i] for i in xrange(len(self)))
559+
return tuple(self[i] for i in range(len(self)))
560560
coords = tuple
561561

562562
def _listarr(self, func):
563563
"""
564564
Internal routine that returns a sequence (list) corresponding with
565565
the given function.
566566
"""
567-
return [func(self.ptr, i) for i in xrange(len(self))]
567+
return [func(self.ptr, i) for i in range(len(self))]
568568

569569
@property
570570
def x(self):
@@ -596,7 +596,7 @@ def __len__(self):
596596

597597
def __iter__(self):
598598
"Iterates through each ring in the Polygon."
599-
for i in xrange(self.geom_count):
599+
for i in range(self.geom_count):
600600
yield self[i]
601601

602602
def __getitem__(self, index):
@@ -616,14 +616,14 @@ def shell(self):
616616
@property
617617
def tuple(self):
618618
"Returns a tuple of LinearRing coordinate tuples."
619-
return tuple(self[i].tuple for i in xrange(self.geom_count))
619+
return tuple(self[i].tuple for i in range(self.geom_count))
620620
coords = tuple
621621

622622
@property
623623
def point_count(self):
624624
"The number of Points in this Polygon."
625625
# Summing up the number of points in each ring of the Polygon.
626-
return sum(self[i].point_count for i in xrange(self.geom_count))
626+
return sum(self[i].point_count for i in range(self.geom_count))
627627

628628
@property
629629
def centroid(self):
@@ -647,7 +647,7 @@ def __getitem__(self, index):
647647

648648
def __iter__(self):
649649
"Iterates over each Geometry."
650-
for i in xrange(self.geom_count):
650+
for i in range(self.geom_count):
651651
yield self[i]
652652

653653
def __len__(self):
@@ -672,12 +672,12 @@ def add(self, geom):
672672
def point_count(self):
673673
"The number of Points in this Geometry Collection."
674674
# Summing up the number of points in each geometry in this collection
675-
return sum(self[i].point_count for i in xrange(self.geom_count))
675+
return sum(self[i].point_count for i in range(self.geom_count))
676676

677677
@property
678678
def tuple(self):
679679
"Returns a tuple representation of this Geometry Collection."
680-
return tuple(self[i].tuple for i in xrange(self.geom_count))
680+
return tuple(self[i].tuple for i in range(self.geom_count))
681681
coords = tuple
682682

683683

django/contrib/gis/gdal/layer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from django.utils.encoding import force_bytes, force_text
1818
from django.utils import six
19-
from django.utils.six.moves import xrange
19+
from django.utils.six.moves import range
2020

2121

2222
# For more information, see the OGR C API source code:
@@ -54,15 +54,15 @@ def __getitem__(self, index):
5454
elif isinstance(index, slice):
5555
# A slice was given
5656
start, stop, stride = index.indices(self.num_feat)
57-
return [self._make_feature(fid) for fid in xrange(start, stop, stride)]
57+
return [self._make_feature(fid) for fid in range(start, stop, stride)]
5858
else:
5959
raise TypeError('Integers and slices may only be used when indexing OGR Layers.')
6060

6161
def __iter__(self):
6262
"Iterates over each Feature in the Layer."
6363
# ResetReading() must be called before iteration is to begin.
6464
capi.reset_reading(self._ptr)
65-
for i in xrange(self.num_feat):
65+
for i in range(self.num_feat):
6666
yield Feature(capi.get_next_feature(self._ptr), self)
6767

6868
def __len__(self):
@@ -141,7 +141,7 @@ def fields(self):
141141
"""
142142
return [force_text(capi.get_field_name(capi.get_field_defn(self._ldefn, i)),
143143
self._ds.encoding, strings_only=True)
144-
for i in xrange(self.num_fields)]
144+
for i in range(self.num_fields)]
145145

146146
@property
147147
def field_types(self):
@@ -152,19 +152,19 @@ def field_types(self):
152152
fields.
153153
"""
154154
return [OGRFieldTypes[capi.get_field_type(capi.get_field_defn(self._ldefn, i))]
155-
for i in xrange(self.num_fields)]
155+
for i in range(self.num_fields)]
156156

157157
@property
158158
def field_widths(self):
159159
"Returns a list of the maximum field widths for the features."
160160
return [capi.get_field_width(capi.get_field_defn(self._ldefn, i))
161-
for i in xrange(self.num_fields)]
161+
for i in range(self.num_fields)]
162162

163163
@property
164164
def field_precisions(self):
165165
"Returns the field precisions for the features."
166166
return [capi.get_field_precision(capi.get_field_defn(self._ldefn, i))
167-
for i in xrange(self.num_fields)]
167+
for i in range(self.num_fields)]
168168

169169
def _get_spatial_filter(self):
170170
try:

django/contrib/gis/gdal/tests/test_geom.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from django.contrib.gis.gdal import HAS_GDAL
1111
from django.contrib.gis.geometry.test_data import TestDataMixin
12-
from django.utils.six.moves import xrange
12+
from django.utils.six.moves import range
1313

1414
if HAS_GDAL:
1515
from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType,
@@ -355,7 +355,7 @@ def test09c_transform_dim(self):
355355

356356
def test10_difference(self):
357357
"Testing difference()."
358-
for i in xrange(len(self.geometries.topology_geoms)):
358+
for i in range(len(self.geometries.topology_geoms)):
359359
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
360360
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
361361
d1 = OGRGeometry(self.geometries.diff_geoms[i].wkt)
@@ -367,7 +367,7 @@ def test10_difference(self):
367367

368368
def test11_intersection(self):
369369
"Testing intersects() and intersection()."
370-
for i in xrange(len(self.geometries.topology_geoms)):
370+
for i in range(len(self.geometries.topology_geoms)):
371371
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
372372
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
373373
i1 = OGRGeometry(self.geometries.intersect_geoms[i].wkt)
@@ -380,7 +380,7 @@ def test11_intersection(self):
380380

381381
def test12_symdifference(self):
382382
"Testing sym_difference()."
383-
for i in xrange(len(self.geometries.topology_geoms)):
383+
for i in range(len(self.geometries.topology_geoms)):
384384
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
385385
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
386386
d1 = OGRGeometry(self.geometries.sdiff_geoms[i].wkt)
@@ -392,7 +392,7 @@ def test12_symdifference(self):
392392

393393
def test13_union(self):
394394
"Testing union()."
395-
for i in xrange(len(self.geometries.topology_geoms)):
395+
for i in range(len(self.geometries.topology_geoms)):
396396
a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
397397
b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
398398
u1 = OGRGeometry(self.geometries.union_geoms[i].wkt)

django/contrib/gis/geos/collections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from django.contrib.gis.geos.point import Point
1010
from django.contrib.gis.geos.polygon import Polygon
1111
from django.contrib.gis.geos import prototypes as capi
12-
from django.utils.six.moves import xrange
12+
from django.utils.six.moves import range
1313

1414

1515
class GeometryCollection(GEOSGeometry):
@@ -42,7 +42,7 @@ def __init__(self, *args, **kwargs):
4242

4343
def __iter__(self):
4444
"Iterates over each Geometry in the Collection."
45-
for i in xrange(len(self)):
45+
for i in range(len(self)):
4646
yield self[i]
4747

4848
def __len__(self):

django/contrib/gis/geos/coordseq.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
99
from django.contrib.gis.geos.libgeos import CS_PTR
1010
from django.contrib.gis.geos import prototypes as capi
11-
from django.utils.six.moves import xrange
11+
from django.utils.six.moves import range
1212

1313

1414
class GEOSCoordSeq(GEOSBase):
@@ -26,7 +26,7 @@ def __init__(self, ptr, z=False):
2626

2727
def __iter__(self):
2828
"Iterates over each point in the coordinate sequence."
29-
for i in xrange(self.size):
29+
for i in range(self.size):
3030
yield self[i]
3131

3232
def __len__(self):
@@ -151,7 +151,7 @@ def kml(self):
151151
else:
152152
substr = '%s,%s,0 '
153153
return '<coordinates>%s</coordinates>' % \
154-
''.join(substr % self[i] for i in xrange(len(self))).strip()
154+
''.join(substr % self[i] for i in range(len(self))).strip()
155155

156156
@property
157157
def tuple(self):
@@ -160,4 +160,4 @@ def tuple(self):
160160
if n == 1:
161161
return self[0]
162162
else:
163-
return tuple(self[i] for i in xrange(n))
163+
return tuple(self[i] for i in range(n))

django/contrib/gis/geos/linestring.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.contrib.gis.geos.geometry import GEOSGeometry
55
from django.contrib.gis.geos.point import Point
66
from django.contrib.gis.geos import prototypes as capi
7-
from django.utils.six.moves import xrange
7+
from django.utils.six.moves import range
88

99

1010
class LineString(GEOSGeometry):
@@ -40,7 +40,7 @@ def __init__(self, *args, **kwargs):
4040
raise TypeError('Cannot initialize on empty sequence.')
4141
self._checkdim(ndim)
4242
# Incrementing through each of the coordinates and verifying
43-
for i in xrange(1, ncoords):
43+
for i in range(1, ncoords):
4444
if not isinstance(coords[i], (tuple, list, Point)):
4545
raise TypeError('each coordinate should be a sequence (list or tuple)')
4646
if len(coords[i]) != ndim:
@@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):
6161
# set the points using GEOSCoordSeq.__setitem__().
6262
cs = GEOSCoordSeq(capi.create_cs(ncoords, ndim), z=bool(ndim == 3))
6363

64-
for i in xrange(ncoords):
64+
for i in range(ncoords):
6565
if numpy_coords:
6666
cs[i] = coords[i, :]
6767
elif isinstance(coords[i], Point):
@@ -78,7 +78,7 @@ def __init__(self, *args, **kwargs):
7878

7979
def __iter__(self):
8080
"Allows iteration over this LineString."
81-
for i in xrange(len(self)):
81+
for i in range(len(self)):
8282
yield self[i]
8383

8484
def __len__(self):
@@ -128,7 +128,7 @@ def _listarr(self, func):
128128
Internal routine that returns a sequence (list) corresponding with
129129
the given function. Will return a numpy array if possible.
130130
"""
131-
lst = [func(i) for i in xrange(len(self))]
131+
lst = [func(i) for i in range(len(self))]
132132
if numpy:
133133
return numpy.array(lst) # ARRRR!
134134
else:

django/contrib/gis/geos/mutable_list.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"""
1111
from django.utils.functional import total_ordering
1212
from django.utils import six
13-
from django.utils.six.moves import xrange
13+
from django.utils.six.moves import range
1414

1515

1616
@total_ordering
@@ -78,7 +78,7 @@ def __init__(self, *args, **kwargs):
7878
def __getitem__(self, index):
7979
"Get the item(s) at the specified index/slice."
8080
if isinstance(index, slice):
81-
return [self._get_single_external(i) for i in xrange(*index.indices(len(self)))]
81+
return [self._get_single_external(i) for i in range(*index.indices(len(self)))]
8282
else:
8383
index = self._checkindex(index)
8484
return self._get_single_external(index)
@@ -98,7 +98,7 @@ def __delitem__(self, index):
9898

9999
newLen = origLen - len(indexRange)
100100
newItems = (self._get_single_internal(i)
101-
for i in xrange(origLen)
101+
for i in range(origLen)
102102
if i not in indexRange)
103103

104104
self._rebuild(newLen, newItems)
@@ -114,7 +114,7 @@ def __setitem__(self, index, val):
114114

115115
def __iter__(self):
116116
"Iterate over the items in the list"
117-
for i in xrange(len(self)):
117+
for i in range(len(self)):
118118
yield self[i]
119119

120120
### Special methods for arithmetic operations ###
@@ -187,7 +187,7 @@ def count(self, val):
187187

188188
def index(self, val):
189189
"Standard list index method"
190-
for i in xrange(0, len(self)):
190+
for i in range(0, len(self)):
191191
if self[i] == val:
192192
return i
193193
raise ValueError('%s not found in object' % str(val))
@@ -294,7 +294,7 @@ def _assign_extended_slice_rebuild(self, start, stop, step, valueList):
294294
newVals = dict(zip(indexList, valueList))
295295

296296
def newItems():
297-
for i in xrange(newLen):
297+
for i in range(newLen):
298298
if i in newVals:
299299
yield newVals[i]
300300
else:
@@ -321,7 +321,7 @@ def _assign_simple_slice(self, start, stop, valueList):
321321
newLen = origLen - stop + start + len(valueList)
322322

323323
def newItems():
324-
for i in xrange(origLen + 1):
324+
for i in range(origLen + 1):
325325
if i == start:
326326
for val in valueList:
327327
yield val

0 commit comments

Comments
 (0)