Commit 895dc880 authored by Michael Hall's avatar Michael Hall Committed by Tim Graham
Browse files

Fixed #23812 -- Changed django.utils.six.moves.xrange imports to range

parent a5499b09
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ from django.contrib.gis.gdal.prototypes import ds as capi

from django.utils.encoding import force_bytes, force_text
from django.utils import six
from django.utils.six.moves import xrange
from django.utils.six.moves import range


# For more information, see the OGR C API source code:
@@ -98,7 +98,7 @@ class DataSource(GDALBase):

    def __iter__(self):
        "Allows for iteration over the layers in a data source."
        for i in xrange(self.layer_count):
        for i in range(self.layer_count):
            yield self[i]

    def __getitem__(self, index):
+3 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api

from django.utils.encoding import force_bytes, force_text
from django.utils import six
from django.utils.six.moves import xrange
from django.utils.six.moves import range


# For more information, see the OGR C API source code:
@@ -54,7 +54,7 @@ class Feature(GDALBase):

    def __iter__(self):
        "Iterates over each field in the Feature."
        for i in xrange(self.num_fields):
        for i in range(self.num_fields):
            yield self[i]

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

    @property
    def geom(self):
+10 −10
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api
from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex

from django.utils import six
from django.utils.six.moves import xrange
from django.utils.six.moves import range

# For more information, see the OGR C API source code:
#  http://www.gdal.org/ogr/ogr__api_8h.html
@@ -546,7 +546,7 @@ class LineString(OGRGeometry):

    def __iter__(self):
        "Iterates over each point in the LineString."
        for i in xrange(self.point_count):
        for i in range(self.point_count):
            yield self[i]

    def __len__(self):
@@ -556,7 +556,7 @@ class LineString(OGRGeometry):
    @property
    def tuple(self):
        "Returns the tuple representation of this LineString."
        return tuple(self[i] for i in xrange(len(self)))
        return tuple(self[i] for i in range(len(self)))
    coords = tuple

    def _listarr(self, func):
@@ -564,7 +564,7 @@ class LineString(OGRGeometry):
        Internal routine that returns a sequence (list) corresponding with
        the given function.
        """
        return [func(self.ptr, i) for i in xrange(len(self))]
        return [func(self.ptr, i) for i in range(len(self))]

    @property
    def x(self):
@@ -596,7 +596,7 @@ class Polygon(OGRGeometry):

    def __iter__(self):
        "Iterates through each ring in the Polygon."
        for i in xrange(self.geom_count):
        for i in range(self.geom_count):
            yield self[i]

    def __getitem__(self, index):
@@ -616,14 +616,14 @@ class Polygon(OGRGeometry):
    @property
    def tuple(self):
        "Returns a tuple of LinearRing coordinate tuples."
        return tuple(self[i].tuple for i in xrange(self.geom_count))
        return tuple(self[i].tuple for i in range(self.geom_count))
    coords = tuple

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

    @property
    def centroid(self):
@@ -647,7 +647,7 @@ class GeometryCollection(OGRGeometry):

    def __iter__(self):
        "Iterates over each Geometry."
        for i in xrange(self.geom_count):
        for i in range(self.geom_count):
            yield self[i]

    def __len__(self):
@@ -672,12 +672,12 @@ class GeometryCollection(OGRGeometry):
    def point_count(self):
        "The number of Points in this Geometry Collection."
        # Summing up the number of points in each geometry in this collection
        return sum(self[i].point_count for i in xrange(self.geom_count))
        return sum(self[i].point_count for i in range(self.geom_count))

    @property
    def tuple(self):
        "Returns a tuple representation of this Geometry Collection."
        return tuple(self[i].tuple for i in xrange(self.geom_count))
        return tuple(self[i].tuple for i in range(self.geom_count))
    coords = tuple


+7 −7
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api, srs

from django.utils.encoding import force_bytes, force_text
from django.utils import six
from django.utils.six.moves import xrange
from django.utils.six.moves import range


# For more information, see the OGR C API source code:
@@ -54,7 +54,7 @@ class Layer(GDALBase):
        elif isinstance(index, slice):
            # A slice was given
            start, stop, stride = index.indices(self.num_feat)
            return [self._make_feature(fid) for fid in xrange(start, stop, stride)]
            return [self._make_feature(fid) for fid in range(start, stop, stride)]
        else:
            raise TypeError('Integers and slices may only be used when indexing OGR Layers.')

@@ -62,7 +62,7 @@ class Layer(GDALBase):
        "Iterates over each Feature in the Layer."
        # ResetReading() must be called before iteration is to begin.
        capi.reset_reading(self._ptr)
        for i in xrange(self.num_feat):
        for i in range(self.num_feat):
            yield Feature(capi.get_next_feature(self._ptr), self)

    def __len__(self):
@@ -141,7 +141,7 @@ class Layer(GDALBase):
        """
        return [force_text(capi.get_field_name(capi.get_field_defn(self._ldefn, i)),
                           self._ds.encoding, strings_only=True)
                for i in xrange(self.num_fields)]
                for i in range(self.num_fields)]

    @property
    def field_types(self):
@@ -152,19 +152,19 @@ class Layer(GDALBase):
        fields.
        """
        return [OGRFieldTypes[capi.get_field_type(capi.get_field_defn(self._ldefn, i))]
                for i in xrange(self.num_fields)]
                for i in range(self.num_fields)]

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

    @property
    def field_precisions(self):
        "Returns the field precisions for the features."
        return [capi.get_field_precision(capi.get_field_defn(self._ldefn, i))
                for i in xrange(self.num_fields)]
                for i in range(self.num_fields)]

    def _get_spatial_filter(self):
        try:
+5 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ from unittest import skipUnless

from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geometry.test_data import TestDataMixin
from django.utils.six.moves import xrange
from django.utils.six.moves import range

if HAS_GDAL:
    from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType,
@@ -355,7 +355,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):

    def test10_difference(self):
        "Testing difference()."
        for i in xrange(len(self.geometries.topology_geoms)):
        for i in range(len(self.geometries.topology_geoms)):
            a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
            b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
            d1 = OGRGeometry(self.geometries.diff_geoms[i].wkt)
@@ -367,7 +367,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):

    def test11_intersection(self):
        "Testing intersects() and intersection()."
        for i in xrange(len(self.geometries.topology_geoms)):
        for i in range(len(self.geometries.topology_geoms)):
            a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
            b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
            i1 = OGRGeometry(self.geometries.intersect_geoms[i].wkt)
@@ -380,7 +380,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):

    def test12_symdifference(self):
        "Testing sym_difference()."
        for i in xrange(len(self.geometries.topology_geoms)):
        for i in range(len(self.geometries.topology_geoms)):
            a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
            b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
            d1 = OGRGeometry(self.geometries.sdiff_geoms[i].wkt)
@@ -392,7 +392,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):

    def test13_union(self):
        "Testing union()."
        for i in xrange(len(self.geometries.topology_geoms)):
        for i in range(len(self.geometries.topology_geoms)):
            a = OGRGeometry(self.geometries.topology_geoms[i].wkt_a)
            b = OGRGeometry(self.geometries.topology_geoms[i].wkt_b)
            u1 = OGRGeometry(self.geometries.union_geoms[i].wkt)
Loading