Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #21270 -- Fixed E701 pep8 warnings

  • Loading branch information...
commit eb214452c3b1dc399b629aabea926e27b5538c52 1 parent 650b6fd
@alasdairnicol alasdairnicol authored
Showing with 626 additions and 286 deletions.
  1. +4 −2 django/contrib/admin/views/main.py
  2. +8 −4 django/contrib/admindocs/utils.py
  3. +4 −2 django/contrib/gis/admin/options.py
  4. +2 −1  django/contrib/gis/admin/widgets.py
  5. +4 −2 django/contrib/gis/db/backends/base.py
  6. +2 −1  django/contrib/gis/db/backends/postgis/introspection.py
  7. +4 −2 django/contrib/gis/db/backends/postgis/operations.py
  8. +6 −3 django/contrib/gis/db/backends/spatialite/operations.py
  9. +2 −1  django/contrib/gis/db/models/proxy.py
  10. +20 −10 django/contrib/gis/db/models/query.py
  11. +4 −2 django/contrib/gis/db/models/sql/compiler.py
  12. +2 −1  django/contrib/gis/db/models/sql/query.py
  13. +4 −2 django/contrib/gis/feeds.py
  14. +4 −2 django/contrib/gis/gdal/base.py
  15. +4 −2 django/contrib/gis/gdal/datasource.py
  16. +2 −1  django/contrib/gis/gdal/driver.py
  17. +9 −3 django/contrib/gis/gdal/error.py
  18. +2 −1  django/contrib/gis/gdal/feature.py
  19. +19 −7 django/contrib/gis/gdal/field.py
  20. +20 −9 django/contrib/gis/gdal/geometries.py
  21. +2 −1  django/contrib/gis/gdal/geomtype.py
  22. +4 −2 django/contrib/gis/gdal/layer.py
  23. +4 −2 django/contrib/gis/gdal/libgdal.py
  24. +10 −5 django/contrib/gis/gdal/prototypes/errcheck.py
  25. +6 −3 django/contrib/gis/gdal/prototypes/generation.py
  26. +12 −6 django/contrib/gis/gdal/srs.py
  27. +2 −1  django/contrib/gis/gdal/tests/test_ds.py
  28. +2 −1  django/contrib/gis/gdal/tests/test_geom.py
  29. +10 −5 django/contrib/gis/geoip/base.py
  30. +5 −3 django/contrib/gis/geoip/libgeoip.py
  31. +2 −1  django/contrib/gis/geoip/prototypes.py
  32. +4 −2 django/contrib/gis/geos/base.py
  33. +2 −1  django/contrib/gis/geos/collections.py
  34. +10 −5 django/contrib/gis/geos/coordseq.py
  35. +16 −8 django/contrib/gis/geos/geometry.py
  36. +13 −5 django/contrib/gis/geos/libgeos.py
  37. +28 −14 django/contrib/gis/geos/linestring.py
  38. +4 −2 django/contrib/gis/geos/mutable_list.py
  39. +8 −4 django/contrib/gis/geos/point.py
  40. +4 −2 django/contrib/gis/geos/polygon.py
  41. +4 −2 django/contrib/gis/geos/prepared.py
  42. +8 −4 django/contrib/gis/geos/prototypes/errcheck.py
  43. +2 −1  django/contrib/gis/geos/prototypes/geom.py
  44. +21 −9 django/contrib/gis/geos/prototypes/io.py
  45. +2 −1  django/contrib/gis/geos/prototypes/predicates.py
  46. +2 −1  django/contrib/gis/geos/prototypes/threadsafe.py
  47. +2 −1  django/contrib/gis/geos/prototypes/topology.py
  48. +20 −10 django/contrib/gis/geos/tests/test_geos.py
  49. +51 −19 django/contrib/gis/geos/tests/test_geos_mutation.py
  50. +24 −12 django/contrib/gis/geos/tests/test_mutable_list.py
  51. +6 −3 django/contrib/gis/maps/google/gmap.py
  52. +18 −9 django/contrib/gis/maps/google/overlays.py
  53. +2 −1  django/contrib/gis/measure.py
  54. +4 −2 django/contrib/gis/sitemaps/georss.py
  55. +2 −1  django/contrib/gis/sitemaps/kml.py
  56. +21 −7 django/contrib/gis/tests/distapp/models.py
  57. +12 −6 django/contrib/gis/tests/distapp/tests.py
  58. +3 −1 django/contrib/gis/tests/geoadmin/models.py
  59. +15 −5 django/contrib/gis/tests/geoapp/models.py
  60. +16 −8 django/contrib/gis/tests/geoapp/tests.py
  61. +9 −3 django/contrib/gis/tests/geogapp/models.py
  62. +2 −1  django/contrib/gis/tests/layermap/tests.py
  63. +9 −3 django/contrib/gis/tests/relatedapp/models.py
  64. +2 −1  django/contrib/gis/tests/relatedapp/tests.py
  65. +11 −4 django/contrib/gis/tests/utils.py
  66. +30 −13 django/contrib/gis/utils/layermapping.py
  67. +16 −8 django/contrib/gis/utils/ogrinspect.py
  68. +2 −1  django/core/management/color.py
  69. +6 −3 django/forms/utils.py
  70. +10 −5 django/forms/widgets.py
  71. +4 −2 django/utils/text.py
  72. +2 −1  django/utils/translation/trans_null.py
  73. +2 −1  django/utils/xmlutils.py
  74. +1 −1  setup.cfg
  75. +5 −2 tests/decorators/tests.py
  76. +2 −1  tests/forms_tests/tests/test_error_messages.py
  77. +2 −1  tests/forms_tests/tests/test_extra.py
  78. +2 −1  tests/forms_tests/tests/test_util.py
View
6 django/contrib/admin/views/main.py
@@ -198,8 +198,10 @@ def get_filters(self, request):
six.reraise(IncorrectLookupParameters, IncorrectLookupParameters(e), sys.exc_info()[2])
def get_query_string(self, new_params=None, remove=None):
- if new_params is None: new_params = {}
- if remove is None: remove = []
+ if new_params is None:
+ new_params = {}
+ if remove is None:
+ remove = []
p = self.params.copy()
for r in remove:
for k in list(p):
View
12 django/contrib/admindocs/utils.py
@@ -94,15 +94,19 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):
def create_reference_role(rolename, urlbase):
def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
- if options is None: options = {}
- if content is None: content = []
+ if options is None:
+ options = {}
+ if content is None:
+ content = []
node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % (inliner.document.settings.link_base, text.lower())), **options)
return [node], []
docutils.parsers.rst.roles.register_canonical_role(rolename, _role)
def default_reference_role(name, rawtext, text, lineno, inliner, options=None, content=None):
- if options is None: options = {}
- if content is None: content = []
+ if options is None:
+ options = {}
+ if content is None:
+ content = []
context = inliner.document.settings.default_reference_context
node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text.lower())), **options)
return [node], []
View
6 django/contrib/gis/admin/options.py
@@ -70,8 +70,10 @@ def get_map_widget(self, db_field):
"""
is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
if is_collection:
- if db_field.geom_type == 'GEOMETRYCOLLECTION': collection_type = 'Any'
- else: collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
+ if db_field.geom_type == 'GEOMETRYCOLLECTION':
+ collection_type = 'Any'
+ else:
+ collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
else:
collection_type = 'None'
View
3  django/contrib/gis/admin/widgets.py
@@ -20,7 +20,8 @@ class OpenLayersWidget(Textarea):
"""
def render(self, name, value, attrs=None):
# Update the template parameters with any attributes passed in.
- if attrs: self.params.update(attrs)
+ if attrs:
+ self.params.update(attrs)
# Defaulting the WKT value to a blank string -- this
# will be tested in the JavaScript and the appropriate
View
6 django/contrib/gis/db/backends/base.py
@@ -201,8 +201,10 @@ def ellipsoid(self):
return self.srs.ellipsoid
else:
m = self.spheroid_regex.match(self.wkt)
- if m: return (float(m.group('major')), float(m.group('flattening')))
- else: return None
+ if m:
+ return (float(m.group('major')), float(m.group('flattening')))
+ else:
+ return None
@property
def name(self):
View
3  django/contrib/gis/db/backends/postgis/introspection.py
@@ -72,7 +72,8 @@ def get_geometry_type(self, table_name, geo_col):
'WHERE "f_table_name"=%s AND "f_geometry_column"=%s',
(table_name, geo_col))
row = cursor.fetchone()
- if not row: raise GeoIntrospectionError
+ if not row:
+ raise GeoIntrospectionError
except GeoIntrospectionError:
if self.connection.ops.geography:
cursor.execute('SELECT "coord_dimension", "srid", "type" '
View
6 django/contrib/gis/db/backends/postgis/operations.py
@@ -453,8 +453,10 @@ def num_params(self, lookup_type, num_param):
Helper routine that returns a boolean indicating whether the number of
parameters is correct for the lookup type.
"""
- def exactly_two(np): return np == 2
- def two_to_three(np): return np >= 2 and np <=3
+ def exactly_two(np):
+ return np == 2
+ def two_to_three(np):
+ return np >= 2 and np <=3
if (lookup_type in self.distance_functions and
lookup_type != 'dwithin'):
return two_to_three(num_param)
View
9 django/contrib/gis/db/backends/spatialite/operations.py
@@ -275,12 +275,14 @@ def spatialite_version_tuple(self):
version = None
try:
tmp = self._get_spatialite_func("X(GeomFromText('POINT(1 1)'))")
- if tmp == 1.0: version = '2.3.0'
+ if tmp == 1.0:
+ version = '2.3.0'
except DatabaseError:
pass
# If no version string defined, then just re-raise the original
# exception.
- if version is None: raise
+ if version is None:
+ raise
m = self.version_regex.match(version)
if m:
@@ -301,7 +303,8 @@ def spatial_aggregate_sql(self, agg):
if not self.check_aggregate_support(agg):
raise NotImplementedError('%s spatial aggregate is not implmented for this backend.' % agg_name)
agg_name = agg_name.lower()
- if agg_name == 'union': agg_name += 'agg'
+ if agg_name == 'union':
+ agg_name += 'agg'
sql_template = self.select % '%(function)s(%(field)s)'
sql_function = getattr(self, agg_name)
return sql_template, sql_function
View
3  django/contrib/gis/db/models/proxy.py
@@ -54,7 +54,8 @@ def __set__(self, obj, value):
# general GeometryField is used.
if isinstance(value, self._klass) and (str(value.geom_type).upper() == gtype or gtype == 'GEOMETRY'):
# Assigning the SRID to the geometry.
- if value.srid is None: value.srid = self._field.srid
+ if value.srid is None:
+ value.srid = self._field.srid
elif value is None or isinstance(value, six.string_types + (memoryview,)):
# Set with None, WKT, HEX, or WKB
pass
View
30 django/contrib/gis/db/models/query.py
@@ -156,14 +156,20 @@ def geojson(self, precision=8, crs=False, bbox=False, **kwargs):
# PostGIS we're using. SpatiaLite only uses the first group of options.
if backend.spatial_version >= (1, 4, 0):
options = 0
- if crs and bbox: options = 3
- elif bbox: options = 1
- elif crs: options = 2
+ if crs and bbox:
+ options = 3
+ elif bbox:
+ options = 1
+ elif crs:
+ options = 2
else:
options = 0
- if crs and bbox: options = 3
- elif crs: options = 1
- elif bbox: options = 2
+ if crs and bbox:
+ options = 3
+ elif crs:
+ options = 1
+ elif bbox:
+ options = 2
s = {'desc' : 'GeoJSON',
'procedure_args' : {'precision' : precision, 'options' : options},
'procedure_fmt' : '%(geo_col)s,%(precision)s,%(options)s',
@@ -441,7 +447,8 @@ def _spatial_setup(self, att, desc=None, field_name=None, geo_field_type=None):
# Does the spatial backend support this?
connection = connections[self.db]
func = getattr(connection.ops, att, False)
- if desc is None: desc = att
+ if desc is None:
+ desc = att
if not func:
raise NotImplementedError('%s stored procedure not available on '
'the %s backend.' %
@@ -489,7 +496,8 @@ def _spatial_aggregate(self, aggregate, field_name=None,
# Adding any keyword parameters for the Aggregate object. Oracle backends
# in particular need an additional `tolerance` parameter.
agg_kwargs = {}
- if connections[self.db].ops.oracle: agg_kwargs['tolerance'] = tolerance
+ if connections[self.db].ops.oracle:
+ agg_kwargs['tolerance'] = tolerance
# Calling the QuerySet.aggregate, and returning only the value of the aggregate.
return self.aggregate(geoagg=aggregate(agg_col, **agg_kwargs))['geoagg']
@@ -533,12 +541,14 @@ def _spatial_attribute(self, att, settings, field_name=None, model_att=None):
if settings.get('setup', True):
default_args, geo_field = self._spatial_setup(att, desc=settings['desc'], field_name=field_name,
geo_field_type=settings.get('geo_field_type', None))
- for k, v in six.iteritems(default_args): settings['procedure_args'].setdefault(k, v)
+ for k, v in six.iteritems(default_args):
+ settings['procedure_args'].setdefault(k, v)
else:
geo_field = settings['geo_field']
# The attribute to attach to the model.
- if not isinstance(model_att, six.string_types): model_att = att
+ if not isinstance(model_att, six.string_types):
+ model_att = att
# Special handling for any argument that is a geometry.
for name in settings['geom_args']:
View
6 django/contrib/gis/db/models/sql/compiler.py
@@ -166,7 +166,8 @@ def resolve_columns(self, row, fields=()):
# doing pagination with Oracle.
rn_offset = 0
if self.connection.ops.oracle:
- if self.query.high_mark is not None or self.query.low_mark: rn_offset = 1
+ if self.query.high_mark is not None or self.query.low_mark:
+ rn_offset = 1
index_start = rn_offset + len(aliases)
# Converting any extra selection values (e.g., geometries and
@@ -243,7 +244,8 @@ def _field_column(self, field, table_alias=None, column=None):
used. If `column` is specified, it will be used instead of the value
in `field.column`.
"""
- if table_alias is None: table_alias = self.query.get_meta().db_table
+ if table_alias is None:
+ table_alias = self.query.get_meta().db_table
return "%s.%s" % (self.quote_name_unless_alias(table_alias),
self.connection.ops.quote_name(column or field.column))
View
3  django/contrib/gis/db/models/sql/query.py
@@ -113,7 +113,8 @@ def _geo_field(self, field_name=None):
if field_name is None:
# Incrementing until the first geographic field is found.
for fld in self.model._meta.fields:
- if isinstance(fld, GeometryField): return fld
+ if isinstance(fld, GeometryField):
+ return fld
return False
else:
# Otherwise, check by the given field name -- which may be
View
6 django/contrib/gis/feeds.py
@@ -58,7 +58,8 @@ def add_georss_element(self, handler, item, w3c_geo=False):
raise ValueError('Only should be 2 or 4 numeric elements.')
# If a GeoRSS box was given via tuple.
if not box_coords is None:
- if w3c_geo: raise ValueError('Cannot use simple GeoRSS box in W3C Geo feeds.')
+ if w3c_geo:
+ raise ValueError('Cannot use simple GeoRSS box in W3C Geo feeds.')
handler.addQuickElement('georss:box', self.georss_coords(box_coords))
else:
# Getting the lower-case geometry type.
@@ -66,7 +67,8 @@ def add_georss_element(self, handler, item, w3c_geo=False):
if gtype == 'point':
self.add_georss_point(handler, geom.coords, w3c_geo=w3c_geo)
else:
- if w3c_geo: raise ValueError('W3C Geo only supports Point geometries.')
+ if w3c_geo:
+ raise ValueError('W3C Geo only supports Point geometries.')
# For formatting consistent w/the GeoRSS simple standard:
# http://georss.org/1.0#simple
if gtype in ('linestring', 'linearring'):
View
6 django/contrib/gis/gdal/base.py
@@ -19,8 +19,10 @@ def _get_ptr(self):
# Raise an exception if the pointer isn't valid don't
# want to be passing NULL pointers to routines --
# that's very bad.
- if self._ptr: return self._ptr
- else: raise GDALException('GDAL %s pointer no longer valid.' % self.__class__.__name__)
+ if self._ptr:
+ return self._ptr
+ else:
+ raise GDALException('GDAL %s pointer no longer valid.' % self.__class__.__name__)
def _set_ptr(self, ptr):
# Only allow the pointer to be set with pointers of the
View
6 django/contrib/gis/gdal/datasource.py
@@ -95,7 +95,8 @@ def __init__(self, ds_input, ds_driver=False, write=False, encoding='utf-8'):
def __del__(self):
"Destroys this DataStructure object."
- if self._ptr: capi.destroy_ds(self._ptr)
+ if self._ptr:
+ capi.destroy_ds(self._ptr)
def __iter__(self):
"Allows for iteration over the layers in a data source."
@@ -106,7 +107,8 @@ def __getitem__(self, index):
"Allows use of the index [] operator to get a layer at the index."
if isinstance(index, six.string_types):
l = capi.get_layer_by_name(self.ptr, force_bytes(index))
- if not l: raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
+ if not l:
+ raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
elif isinstance(index, int):
if index < 0 or index >= self.layer_count:
raise OGRIndexError('index out of range')
View
3  django/contrib/gis/gdal/driver.py
@@ -59,7 +59,8 @@ def _register(self):
"Attempts to register all the data source drivers."
# Only register all if the driver count is 0 (or else all drivers
# will be registered over and over again)
- if not self.driver_count: capi.register_all()
+ if not self.driver_count:
+ capi.register_all()
# Driver properties
@property
View
12 django/contrib/gis/gdal/error.py
@@ -4,9 +4,15 @@
OGR methods.
"""
#### OGR & SRS Exceptions ####
-class GDALException(Exception): pass
-class OGRException(Exception): pass
-class SRSException(Exception): pass
+class GDALException(Exception):
+ pass
+
+class OGRException(Exception):
+ pass
+
+class SRSException(Exception):
+ pass
+
class OGRIndexError(OGRException, KeyError):
"""
This exception is raised when an invalid index is encountered, and has
View
3  django/contrib/gis/gdal/feature.py
@@ -33,7 +33,8 @@ def __init__(self, feat, layer):
def __del__(self):
"Releases a reference to this object."
- if self._ptr: capi.destroy_feature(self._ptr)
+ if self._ptr:
+ capi.destroy_feature(self._ptr)
def __getitem__(self, index):
"""
View
26 django/contrib/gis/gdal/field.py
@@ -132,9 +132,14 @@ def value(self):
return self.as_double()
# String & Binary fields, just subclasses
-class OFTString(Field): pass
-class OFTWideString(Field): pass
-class OFTBinary(Field): pass
+class OFTString(Field):
+ pass
+
+class OFTWideString(Field):
+ pass
+
+class OFTBinary(Field):
+ pass
# OFTDate, OFTTime, OFTDateTime fields.
class OFTDate(Field):
@@ -172,10 +177,17 @@ def value(self):
return None
# List fields are also just subclasses
-class OFTIntegerList(Field): pass
-class OFTRealList(Field): pass
-class OFTStringList(Field): pass
-class OFTWideStringList(Field): pass
+class OFTIntegerList(Field):
+ pass
+
+class OFTRealList(Field):
+ pass
+
+class OFTStringList(Field):
+ pass
+
+class OFTWideStringList(Field):
+ pass
# Class mapping dictionary for OFT Types and reverse mapping.
OGRFieldTypes = {
View
29 django/contrib/gis/gdal/geometries.py
@@ -122,14 +122,16 @@ def __init__(self, geom_input, srs=None):
self.ptr = g
# Assigning the SpatialReference object to the geometry, if valid.
- if bool(srs): self.srs = srs
+ if bool(srs):
+ self.srs = srs
# Setting the class depending upon the OGR Geometry Type
self.__class__ = GEO_CLASSES[self.geom_type.num]
def __del__(self):
"Deletes this Geometry."
- if self._ptr: capi.destroy_geom(self._ptr)
+ if self._ptr:
+ capi.destroy_geom(self._ptr)
# Pickle routines
def __getstate__(self):
@@ -143,7 +145,8 @@ def __getstate__(self):
def __setstate__(self, state):
wkb, srs = state
ptr = capi.from_wkb(wkb, None, byref(c_void_p()), len(wkb))
- if not ptr: raise OGRException('Invalid OGRGeometry loaded from pickled state.')
+ if not ptr:
+ raise OGRException('Invalid OGRGeometry loaded from pickled state.')
self.ptr = ptr
self.srs = srs
@@ -285,7 +288,8 @@ def _set_srs(self, srs):
# The SRID property
def _get_srid(self):
srs = self.srs
- if srs: return srs.srid
+ if srs:
+ return srs.srid
return None
def _set_srid(self, srid):
@@ -602,7 +606,8 @@ def z(self):
return self._listarr(capi.getz)
# LinearRings are used in Polygons.
-class LinearRing(LineString): pass
+class LinearRing(LineString):
+ pass
class Polygon(OGRGeometry):
@@ -673,7 +678,8 @@ def add(self, geom):
"Add the geometry to this Geometry Collection."
if isinstance(geom, OGRGeometry):
if isinstance(geom, self.__class__):
- for g in geom: capi.add_geom(self.ptr, g.ptr)
+ for g in geom:
+ capi.add_geom(self.ptr, g.ptr)
else:
capi.add_geom(self.ptr, geom.ptr)
elif isinstance(geom, six.string_types):
@@ -695,9 +701,14 @@ def tuple(self):
coords = tuple
# Multiple Geometry types.
-class MultiPoint(GeometryCollection): pass
-class MultiLineString(GeometryCollection): pass
-class MultiPolygon(GeometryCollection): pass
+class MultiPoint(GeometryCollection):
+ pass
+
+class MultiLineString(GeometryCollection):
+ pass
+
+class MultiPolygon(GeometryCollection):
+ pass
# Class mapping dictionary (using the OGRwkbGeometryType as the key)
GEO_CLASSES = {1 : Point,
View
3  django/contrib/gis/gdal/geomtype.py
@@ -36,7 +36,8 @@ def __init__(self, type_input):
num = type_input.num
elif isinstance(type_input, six.string_types):
type_input = type_input.lower()
- if type_input == 'geometry': type_input='unknown'
+ if type_input == 'geometry':
+ type_input='unknown'
num = self._str_types.get(type_input, None)
if num is None:
raise OGRException('Invalid OGR String Type "%s"' % type_input)
View
6 django/contrib/gis/gdal/layer.py
@@ -47,7 +47,8 @@ def __getitem__(self, index):
# An integer index was given -- we cannot do a check based on the
# number of features because the beginning and ending feature IDs
# are not guaranteed to be 0 and len(layer)-1, respectively.
- if index < 0: raise OGRIndexError('Negative indices are not allowed on OGR Layers.')
+ if index < 0:
+ raise OGRIndexError('Negative indices are not allowed on OGR Layers.')
return self._make_feature(index)
elif isinstance(index, slice):
# A slice was given
@@ -88,7 +89,8 @@ def _make_feature(self, feat_id):
# Random access isn't supported, have to increment through
# each feature until the given feature ID is encountered.
for feat in self:
- if feat.fid == feat_id: return feat
+ if feat.fid == feat_id:
+ return feat
# Should have returned a Feature, raise an OGRIndexError.
raise OGRIndexError('Invalid feature id: %s.' % feat_id)
View
6 django/contrib/gis/gdal/libgdal.py
@@ -36,7 +36,8 @@
if lib_names:
for lib_name in lib_names:
lib_path = find_library(lib_name)
- if not lib_path is None: break
+ if not lib_path is None:
+ break
if lib_path is None:
raise OGRException('Could not find the GDAL library (tried "%s"). '
@@ -83,7 +84,8 @@ def gdal_full_version():
def gdal_version_info():
ver = gdal_version().decode()
m = version_regex.match(ver)
- if not m: raise OGRException('Could not parse GDAL version string "%s"' % ver)
+ if not m:
+ raise OGRException('Could not parse GDAL version string "%s"' % ver)
return dict((key, m.group(key)) for key in ('major', 'minor', 'subminor'))
_verinfo = gdal_version_info()
View
15 django/contrib/gis/gdal/prototypes/errcheck.py
@@ -19,8 +19,10 @@ def ptr_byref(args, offset=-1):
def check_bool(result, func, cargs):
"Returns the boolean evaluation of the value."
- if bool(result): return True
- else: return False
+ if bool(result):
+ return True
+ else:
+ return False
### String checking Routines ###
def check_const_string(result, func, cargs, offset=None):
@@ -46,8 +48,10 @@ def check_string(result, func, cargs, offset=-1, str_result=False):
if str_result:
# For routines that return a string.
ptr = result
- if not ptr: s = None
- else: s = string_at(result)
+ if not ptr:
+ s = None
+ else:
+ s = string_at(result)
else:
# Error-code return specified.
check_err(result)
@@ -56,7 +60,8 @@ def check_string(result, func, cargs, offset=-1, str_result=False):
s = ptr.value
# Correctly freeing the allocated memory beind GDAL pointer
# w/the VSIFree routine.
- if ptr: lgdal.VSIFree(ptr)
+ if ptr:
+ lgdal.VSIFree(ptr)
return s
### DataSource, Layer error-checking ###
View
9 django/contrib/gis/gdal/prototypes/generation.py
@@ -15,8 +15,10 @@ def double_output(func, argtypes, errcheck=False, strarg=False):
"Generates a ctypes function that returns a double value."
func.argtypes = argtypes
func.restype = c_double
- if errcheck: func.errcheck = check_arg_errcode
- if strarg: func.errcheck = check_str_arg
+ if errcheck:
+ func.errcheck = check_arg_errcode
+ if strarg:
+ func.errcheck = check_str_arg
return func
def geom_output(func, argtypes, offset=None):
@@ -106,7 +108,8 @@ def void_output(func, argtypes, errcheck=True):
For functions that don't only return an error code that needs to
be examined.
"""
- if argtypes: func.argtypes = argtypes
+ if argtypes:
+ func.argtypes = argtypes
if errcheck:
# `errcheck` keyword may be set to False for routines that
# return void, rather than a status code.
View
18 django/contrib/gis/gdal/srs.py
@@ -97,7 +97,8 @@ def __init__(self, srs_input=''):
def __del__(self):
"Destroys this spatial reference."
- if self._ptr: capi.release_srs(self._ptr)
+ if self._ptr:
+ capi.release_srs(self._ptr)
def __getitem__(self, target):
"""
@@ -176,10 +177,14 @@ def validate(self):
@property
def name(self):
"Returns the name of this Spatial Reference."
- if self.projected: return self.attr_value('PROJCS')
- elif self.geographic: return self.attr_value('GEOGCS')
- elif self.local: return self.attr_value('LOCAL_CS')
- else: return None
+ if self.projected:
+ return self.attr_value('PROJCS')
+ elif self.geographic:
+ return self.attr_value('GEOGCS')
+ elif self.local:
+ return self.attr_value('LOCAL_CS')
+ else:
+ return None
@property
def srid(self):
@@ -336,7 +341,8 @@ def __init__(self, source, target):
def __del__(self):
"Deletes this Coordinate Transformation object."
- if self._ptr: capi.destroy_ct(self._ptr)
+ if self._ptr:
+ capi.destroy_ct(self._ptr)
def __str__(self):
return 'Transform from "%s" to "%s"' % (self._srs1_name, self._srs2_name)
View
3  django/contrib/gis/gdal/tests/test_ds.py
@@ -93,7 +93,8 @@ def test03a_layers(self):
# Now checking the field names.
flds = layer.fields
- for f in flds: self.assertEqual(True, f in source.fields)
+ for f in flds:
+ self.assertEqual(True, f in source.fields)
# Negative FIDs are not allowed.
self.assertRaises(OGRIndexError, layer.__getitem__, -1)
View
3  django/contrib/gis/gdal/tests/test_geom.py
@@ -418,7 +418,8 @@ def test14_add(self):
mp1.add(poly) # Adding a geometry at a time
mp2.add(poly.wkt) # Adding WKT
mp3.add(mpoly) # Adding a MultiPolygon's entire contents at once.
- for tmp in (mp1, mp2, mp3): self.assertEqual(mpoly, tmp)
+ for tmp in (mp1, mp2, mp3):
+ self.assertEqual(mpoly, tmp)
def test15_extent(self):
"Testing `extent` property."
View
15 django/contrib/gis/geoip/base.py
@@ -89,7 +89,8 @@ def __init__(self, path=None, cache=0, country=None, city=None):
# Getting the GeoIP data path.
if not path:
path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
- if not path: raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
+ if not path:
+ raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
if not isinstance(path, six.string_types):
raise TypeError('Invalid path type: %s' % type(path).__name__)
@@ -129,8 +130,10 @@ def __del__(self):
# Cleaning any GeoIP file handles lying around.
if GeoIP_delete is None:
return
- if self._country: GeoIP_delete(self._country)
- if self._city: GeoIP_delete(self._city)
+ if self._country:
+ GeoIP_delete(self._country)
+ if self._city:
+ GeoIP_delete(self._city)
def _check_query(self, query, country=False, city=False, city_or_country=False):
"Helper routine for checking the query and database availability."
@@ -199,8 +202,10 @@ def country(self, query):
#### Coordinate retrieval routines ####
def coords(self, query, ordering=('longitude', 'latitude')):
cdict = self.city(query)
- if cdict is None: return None
- else: return tuple(cdict[o] for o in ordering)
+ if cdict is None:
+ return None
+ else:
+ return tuple(cdict[o] for o in ordering)
def lon_lat(self, query):
"Returns a tuple of the (longitude, latitude) for the given query."
View
8 django/contrib/gis/geoip/libgeoip.py
@@ -18,9 +18,11 @@
lib_name = 'GeoIP'
# Getting the path to the GeoIP library.
-if lib_name: lib_path = find_library(lib_name)
-if lib_path is None: raise RuntimeError('Could not find the GeoIP library (tried "%s"). '
- 'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
+if lib_name:
+ lib_path = find_library(lib_name)
+if lib_path is None:
+ raise RuntimeError('Could not find the GeoIP library (tried "%s"). '
+ 'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
lgeoip = CDLL(lib_path)
# Getting the C `free` for the platform.
View
3  django/contrib/gis/geoip/prototypes.py
@@ -27,7 +27,8 @@ class GeoIPRecord(Structure):
1: 'utf8',
}
-class GeoIPTag(Structure): pass
+class GeoIPTag(Structure):
+ pass
RECTYPE = POINTER(GeoIPRecord)
DBTYPE = POINTER(GeoIPTag)
View
6 django/contrib/gis/geos/base.py
@@ -34,8 +34,10 @@ def _get_ptr(self):
# Raise an exception if the pointer isn't valid don't
# want to be passing NULL pointers to routines --
# that's very bad.
- if self._ptr: return self._ptr
- else: raise GEOSException('NULL GEOS %s pointer encountered.' % self.__class__.__name__)
+ if self._ptr:
+ return self._ptr
+ else:
+ raise GEOSException('NULL GEOS %s pointer encountered.' % self.__class__.__name__)
def _set_ptr(self, ptr):
# Only allow the pointer to be set with pointers of the
View
3  django/contrib/gis/geos/collections.py
@@ -73,7 +73,8 @@ def _set_list(self, length, items):
prev_ptr = self.ptr
srid = self.srid
self.ptr = self._create_collection(length, items)
- if srid: self.srid = srid
+ if srid:
+ self.srid = srid
capi.destroy_geom(prev_ptr)
_set_single = GEOSGeometry._set_single_rebuild
View
15 django/contrib/gis/geos/coordseq.py
@@ -64,7 +64,8 @@ def __setitem__(self, index, value):
# Setting the X, Y, Z
self.setX(index, value[0])
self.setY(index, value[1])
- if set_3d: self.setZ(index, value[2])
+ if set_3d:
+ self.setZ(index, value[2])
#### Internal Routines ####
def _checkindex(self, index):
@@ -144,8 +145,10 @@ def kml(self):
"Returns the KML representation for the coordinates."
# Getting the substitution string depending on whether the coordinates have
# a Z dimension.
- if self.hasz: substr = '%s,%s,%s '
- else: substr = '%s,%s,0 '
+ if self.hasz:
+ substr = '%s,%s,%s '
+ else:
+ substr = '%s,%s,0 '
return '<coordinates>%s</coordinates>' % \
''.join(substr % self[i] for i in xrange(len(self))).strip()
@@ -153,5 +156,7 @@ def kml(self):
def tuple(self):
"Returns a tuple version of this coordinate sequence."
n = self.size
- if n == 1: return self[0]
- else: return tuple(self[i] for i in xrange(n))
+ if n == 1:
+ return self[0]
+ else:
+ return tuple(self[i] for i in xrange(n))
View
24 django/contrib/gis/geos/geometry.py
@@ -66,7 +66,8 @@ def __init__(self, geo_input, srid=None):
wkt_m = wkt_regex.match(geo_input)
if wkt_m:
# Handling WKT input.
- if wkt_m.group('srid'): srid = int(wkt_m.group('srid'))
+ if wkt_m.group('srid'):
+ srid = int(wkt_m.group('srid'))
g = wkt_r().read(force_bytes(wkt_m.group('wkt')))
elif hex_regex.match(geo_input):
# Handling HEXEWKB input.
@@ -100,7 +101,8 @@ def __init__(self, geo_input, srid=None):
def _post_init(self, srid):
"Helper routine for performing post-initialization setup."
# Setting the SRID, if given.
- if srid and isinstance(srid, int): self.srid = srid
+ if srid and isinstance(srid, int):
+ self.srid = srid
# Setting the class type (e.g., Point, Polygon, etc.)
self.__class__ = GEOS_CLASSES[self.geom_typeid]
@@ -114,7 +116,8 @@ def __del__(self):
Destroys this Geometry; in other words, frees the memory used by the
GEOS C++ object.
"""
- if self._ptr: capi.destroy_geom(self._ptr)
+ if self._ptr:
+ capi.destroy_geom(self._ptr)
def __copy__(self):
"""
@@ -149,7 +152,8 @@ def __setstate__(self, state):
# Instantiating from the tuple state that was pickled.
wkb, srid = state
ptr = wkb_r().read(memoryview(wkb))
- if not ptr: raise GEOSException('Invalid Geometry loaded from pickled state.')
+ if not ptr:
+ raise GEOSException('Invalid Geometry loaded from pickled state.')
self.ptr = ptr
self._post_init(srid)
@@ -361,8 +365,10 @@ def within(self, other):
def get_srid(self):
"Gets the SRID for the geometry, returns None if no SRID is set."
s = capi.geos_get_srid(self.ptr)
- if s == 0: return None
- else: return s
+ if s == 0:
+ return None
+ else:
+ return s
def set_srid(self, srid):
"Sets the SRID for the geometry."
@@ -377,8 +383,10 @@ def ewkt(self):
are *not* included in this representation because GEOS does not yet
support serializing them.
"""
- if self.get_srid(): return 'SRID=%s;%s' % (self.srid, self.wkt)
- else: return self.wkt
+ if self.get_srid():
+ return 'SRID=%s;%s' % (self.srid, self.wkt)
+ else:
+ return self.wkt
@property
def wkt(self):
View
18 django/contrib/gis/geos/libgeos.py
@@ -43,7 +43,8 @@
if lib_names:
for lib_name in lib_names:
lib_path = find_library(lib_name)
- if not lib_path is None: break
+ if not lib_path is None:
+ break
# No GEOS library could be found.
if lib_path is None:
@@ -83,10 +84,17 @@ def error_h(fmt, lst):
#### GEOS Geometry C data structures, and utility functions. ####
# Opaque GEOS geometry structures, used for GEOM_PTR and CS_PTR
-class GEOSGeom_t(Structure): pass
-class GEOSPrepGeom_t(Structure): pass
-class GEOSCoordSeq_t(Structure): pass
-class GEOSContextHandle_t(Structure): pass
+class GEOSGeom_t(Structure):
+ pass
+
+class GEOSPrepGeom_t(Structure):
+ pass
+
+class GEOSCoordSeq_t(Structure):
+ pass
+
+class GEOSContextHandle_t(Structure):
+ pass
# Pointers to opaque GEOS geometry structures.
GEOM_PTR = POINTER(GEOSGeom_t)
View
42 django/contrib/gis/geos/linestring.py
@@ -24,25 +24,31 @@ def __init__(self, *args, **kwargs):
ls = LineString(Point(1, 1), Point(2, 2))
"""
# If only one argument provided, set the coords array appropriately
- if len(args) == 1: coords = args[0]
- else: coords = args
+ if len(args) == 1:
+ coords = args[0]
+ else:
+ coords = args
if isinstance(coords, (tuple, list)):
# Getting the number of coords and the number of dimensions -- which
# must stay the same, e.g., no LineString((1, 2), (1, 2, 3)).
ncoords = len(coords)
- if coords: ndim = len(coords[0])
- else: raise TypeError('Cannot initialize on empty sequence.')
+ if coords:
+ ndim = len(coords[0])
+ else:
+ raise TypeError('Cannot initialize on empty sequence.')
self._checkdim(ndim)
# Incrementing through each of the coordinates and verifying
for i in xrange(1, ncoords):
if not isinstance(coords[i], (tuple, list, Point)):
raise TypeError('each coordinate should be a sequence (list or tuple)')
- if len(coords[i]) != ndim: raise TypeError('Dimension mismatch.')
+ if len(coords[i]) != ndim:
+ raise TypeError('Dimension mismatch.')
numpy_coords = False
elif numpy and isinstance(coords, numpy.ndarray):
shape = coords.shape # Using numpy's shape.
- if len(shape) != 2: raise TypeError('Too many dimensions.')
+ if len(shape) != 2:
+ raise TypeError('Too many dimensions.')
self._checkdim(shape[1])
ncoords = shape[0]
ndim = shape[1]
@@ -55,9 +61,12 @@ def __init__(self, *args, **kwargs):
cs = GEOSCoordSeq(capi.create_cs(ncoords, ndim), z=bool(ndim==3))
for i in xrange(ncoords):
- if numpy_coords: cs[i] = coords[i,:]
- elif isinstance(coords[i], Point): cs[i] = coords[i].tuple
- else: cs[i] = coords[i]
+ if numpy_coords:
+ cs[i] = coords[i,:]
+ elif isinstance(coords[i], Point):
+ cs[i] = coords[i].tuple
+ else:
+ cs[i] = coords[i]
# If SRID was passed in with the keyword arguments
srid = kwargs.get('srid', None)
@@ -103,7 +112,8 @@ def _set_single(self, index, value):
self._cs[index] = value
def _checkdim(self, dim):
- if dim not in (2, 3): raise TypeError('Dimension mismatch.')
+ if dim not in (2, 3):
+ raise TypeError('Dimension mismatch.')
#### Sequence Properties ####
@property
@@ -118,8 +128,10 @@ def _listarr(self, func):
the given function. Will return a numpy array if possible.
"""
lst = [func(i) for i in xrange(len(self))]
- if numpy: return numpy.array(lst) # ARRRR!
- else: return lst
+ if numpy:
+ return numpy.array(lst) # ARRRR!
+ else:
+ return lst
@property
def array(self):
@@ -144,8 +156,10 @@ def y(self):
@property
def z(self):
"Returns a list or numpy array of the Z variable."
- if not self.hasz: return None
- else: return self._listarr(self._cs.getZ)
+ if not self.hasz:
+ return None
+ else:
+ return self._listarr(self._cs.getZ)
# LinearRings are LineStrings used within Polygons.
class LinearRing(LineString):
View
6 django/contrib/gis/geos/mutable_list.py
@@ -180,13 +180,15 @@ def count(self, val):
"Standard list count method"
count = 0
for i in self:
- if val == i: count += 1
+ if val == i:
+ count += 1
return count
def index(self, val):
"Standard list index method"
for i in xrange(0, len(self)):
- if self[i] == val: return i
+ if self[i] == val:
+ return i
raise ValueError('%s not found in object' % str(val))
## Mutating ##
View
12 django/contrib/gis/geos/point.py
@@ -50,7 +50,8 @@ def _create_point(self, ndim, coords):
i = iter(coords)
capi.cs_setx(cs, 0, next(i))
capi.cs_sety(cs, 0, next(i))
- if ndim == 3: capi.cs_setz(cs, 0, next(i))
+ if ndim == 3:
+ capi.cs_setz(cs, 0, next(i))
return capi.create_point(cs)
@@ -74,9 +75,12 @@ def __iter__(self):
def __len__(self):
"Returns the number of dimensions for this Point (either 0, 2 or 3)."
- if self.empty: return 0
- if self.hasz: return 3
- else: return 2
+ if self.empty:
+ return 0
+ if self.hasz:
+ return 3
+ else:
+ return 2
def _get_single_external(self, index):
if index == 0:
View
6 django/contrib/gis/geos/polygon.py
@@ -99,7 +99,8 @@ def _clone(self, g):
def _construct_ring(self, param, msg='Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings'):
"Helper routine for trying to construct a ring from the given parameter."
- if isinstance(param, LinearRing): return param
+ if isinstance(param, LinearRing):
+ return param
try:
ring = LinearRing(param)
return ring
@@ -112,7 +113,8 @@ def _set_list(self, length, items):
prev_ptr = self.ptr
srid = self.srid
self.ptr = self._create_polygon(length, items)
- if srid: self.srid = srid
+ if srid:
+ self.srid = srid
capi.destroy_geom(prev_ptr)
def _get_single_internal(self, index):
View
6 django/contrib/gis/geos/prepared.py
@@ -11,11 +11,13 @@ class PreparedGeometry(GEOSBase):
ptr_type = capi.PREPGEOM_PTR
def __init__(self, geom):
- if not isinstance(geom, GEOSGeometry): raise TypeError
+ if not isinstance(geom, GEOSGeometry):
+ raise TypeError
self.ptr = capi.geos_prepare(geom.ptr)
def __del__(self):
- if self._ptr: capi.prepared_destroy(self._ptr)
+ if self._ptr:
+ capi.prepared_destroy(self._ptr)
def contains(self, other):
return capi.prepared_contains(self.ptr, other.ptr)
View
12 django/contrib/gis/geos/prototypes/errcheck.py
@@ -33,7 +33,8 @@ def last_arg_byref(args):
def check_dbl(result, func, cargs):
"Checks the status code and returns the double value passed in by reference."
# Checking the status code
- if result != 1: return None
+ if result != 1:
+ return None
# Double passed in by reference, return its value.
return last_arg_byref(cargs)
@@ -53,8 +54,10 @@ def check_minus_one(result, func, cargs):
def check_predicate(result, func, cargs):
"Error checking for unary/binary predicate functions."
val = ord(result) # getting the ordinal from the character
- if val == 1: return True
- elif val == 0: return False
+ if val == 1:
+ return True
+ elif val == 0:
+ return False
else:
raise GEOSException('Error encountered on GEOS C predicate function "%s".' % func.__name__)
@@ -80,7 +83,8 @@ def check_string(result, func, cargs):
This frees the memory allocated by GEOS at the result pointer.
"""
- if not result: raise GEOSException('Error encountered checking string return value in GEOS C function "%s".' % func.__name__)
+ if not result:
+ raise GEOSException('Error encountered checking string return value in GEOS C function "%s".' % func.__name__)
# Getting the string value at the pointer address.
s = string_at(result)
# Freeing the memory allocated within GEOS
View
3  django/contrib/gis/geos/prototypes/geom.py
@@ -35,7 +35,8 @@ def bin_output(func):
def geom_output(func, argtypes):
"For GEOS routines that return a geometry."
- if argtypes: func.argtypes = argtypes
+ if argtypes:
+ func.argtypes = argtypes
func.restype = GEOM_PTR
func.errcheck = check_geom
return func
View
30 django/contrib/gis/geos/prototypes/io.py
@@ -11,10 +11,17 @@
from django.utils.encoding import force_bytes
### The WKB/WKT Reader/Writer structures and pointers ###
-class WKTReader_st(Structure): pass
-class WKTWriter_st(Structure): pass
-class WKBReader_st(Structure): pass
-class WKBWriter_st(Structure): pass
+class WKTReader_st(Structure):
+ pass
+
+class WKTWriter_st(Structure):
+ pass
+
+class WKBReader_st(Structure):
+ pass
+
+class WKBWriter_st(Structure):
+ pass
WKT_READ_PTR = POINTER(WKTReader_st)
WKT_WRITE_PTR = POINTER(WKTWriter_st)
@@ -121,7 +128,8 @@ def __init__(self):
def __del__(self):
# Cleaning up with the appropriate destructor.
- if self._ptr: self._destructor(self._ptr)
+ if self._ptr:
+ self._destructor(self._ptr)
### Base WKB/WKT Reading and Writing objects ###
@@ -194,7 +202,8 @@ def _get_byteorder(self):
return wkb_writer_get_byteorder(self.ptr)
def _set_byteorder(self, order):
- if not order in (0, 1): raise ValueError('Byte order parameter must be 0 (Big Endian) or 1 (Little Endian).')
+ if not order in (0, 1):
+ raise ValueError('Byte order parameter must be 0 (Big Endian) or 1 (Little Endian).')
wkb_writer_set_byteorder(self.ptr, order)
byteorder = property(_get_byteorder, _set_byteorder)
@@ -204,7 +213,8 @@ def _get_outdim(self):
return wkb_writer_get_outdim(self.ptr)
def _set_outdim(self, new_dim):
- if not new_dim in (2, 3): raise ValueError('WKB output dimension must be 2 or 3')
+ if not new_dim in (2, 3):
+ raise ValueError('WKB output dimension must be 2 or 3')
wkb_writer_set_outdim(self.ptr, new_dim)
outdim = property(_get_outdim, _set_outdim)
@@ -214,8 +224,10 @@ def _get_include_srid(self):
return bool(ord(wkb_writer_get_include_srid(self.ptr)))
def _set_include_srid(self, include):
- if bool(include): flag = b'\x01'
- else: flag = b'\x00'
+ if bool(include):
+ flag = b'\x01'
+ else:
+ flag = b'\x00'
wkb_writer_set_include_srid(self.ptr, flag)
srid = property(_get_include_srid, _set_include_srid)
View
3  django/contrib/gis/geos/prototypes/predicates.py
@@ -11,7 +11,8 @@
def binary_predicate(func, *args):
"For GEOS binary predicate functions."
argtypes = [GEOM_PTR, GEOM_PTR]
- if args: argtypes += args
+ if args:
+ argtypes += args
func.argtypes = argtypes
func.restype = c_char
func.errcheck = check_predicate
View
3  django/contrib/gis/geos/prototypes/threadsafe.py
@@ -11,7 +11,8 @@ def __init__(self):
self.ptr = lgeos.initGEOS_r(notice_h, error_h)
def __del__(self):
- if self.ptr: lgeos.finishGEOS_r(self.ptr)
+ if self.ptr:
+ lgeos.finishGEOS_r(self.ptr)
# Defining a thread-local object and creating an instance
# to hold a reference to GEOSContextHandle for this thread.
View
3  django/contrib/gis/geos/prototypes/topology.py
@@ -16,7 +16,8 @@
def topology(func, *args, **kwargs):
"For GEOS unary topology functions."
argtypes = [GEOM_PTR]
- if args: argtypes += args
+ if args:
+ argtypes += args
func.argtypes = argtypes
func.restype = kwargs.get('restype', GEOM_PTR)
func.errcheck = kwargs.get('errcheck', check_geom)
View
30 django/contrib/gis/geos/tests/test_geos.py
@@ -143,7 +143,8 @@ def test_kml(self):
for tg in self.geometries.wkt_out:
geom = fromstr(tg.wkt)
kml = getattr(tg, 'kml', False)
- if kml: self.assertEqual(kml, geom.kml)
+ if kml:
+ self.assertEqual(kml, geom.kml)
def test_errors(self):
"Testing the Error handlers."
@@ -338,7 +339,8 @@ def test_linestring(self):
self.assertEqual(ls, LineString(*ls.tuple)) # as individual arguments
self.assertEqual(ls, LineString([list(tup) for tup in ls.tuple])) # as list
self.assertEqual(ls.wkt, LineString(*tuple(Point(tup) for tup in ls.tuple)).wkt) # Point individual arguments
- if numpy: self.assertEqual(ls, LineString(numpy.array(ls.tuple))) # as numpy array
+ if numpy:
+ self.assertEqual(ls, LineString(numpy.array(ls.tuple))) # as numpy array
def test_multilinestring(self):
"Testing MultiLineString objects."
@@ -378,7 +380,8 @@ def test_linearring(self):
self.assertEqual(lr, LinearRing(lr.tuple))
self.assertEqual(lr, LinearRing(*lr.tuple))
self.assertEqual(lr, LinearRing([list(tup) for tup in lr.tuple]))
- if numpy: self.assertEqual(lr, LinearRing(numpy.array(lr.tuple)))
+ if numpy:
+ self.assertEqual(lr, LinearRing(numpy.array(lr.tuple)))
def test_polygons_from_bbox(self):
"Testing `from_bbox` class method."
@@ -528,8 +531,10 @@ def test_coord_seq(self):
self.assertEqual(c1, c2)
# Constructing the test value to set the coordinate sequence with
- if len(c1) == 2: tset = (5, 23)
- else: tset = (5, 23, 8)
+ if len(c1) == 2:
+ tset = (5, 23)
+ else:
+ tset = (5, 23, 8)
cs[i] = tset
# Making sure every set point matches what we expect
@@ -636,14 +641,16 @@ def test_srid(self):
# Testing SRID keyword on fromstr(), and on Polygon rings.
poly = fromstr(self.geometries.polygons[1].wkt, srid=4269)
self.assertEqual(4269, poly.srid)
- for ring in poly: self.assertEqual(4269, ring.srid)
+ for ring in poly:
+ self.assertEqual(4269, ring.srid)
poly.srid = 4326
self.assertEqual(4326, poly.shell.srid)
# Testing SRID keyword on GeometryCollection
gc = GeometryCollection(Point(5, 23), LineString((0, 0), (1.5, 1.5), (3, 3)), srid=32021)
self.assertEqual(32021, gc.srid)
- for i in range(len(gc)): self.assertEqual(32021, gc[i].srid)
+ for i in range(len(gc)):
+ self.assertEqual(32021, gc[i].srid)
# GEOS may get the SRID from HEXEWKB
# 'POINT(5 23)' at SRID=4326 in hex form -- obtained from PostGIS
@@ -691,7 +698,8 @@ def test_mutable_geometries(self):
# Constructing the new shell by adding 500 to every point in the old shell.
shell_tup = poly.shell.tuple
new_coords = []
- for point in shell_tup: new_coords.append((point[0] + 500., point[1] + 500.))
+ for point in shell_tup:
+ new_coords.append((point[0] + 500., point[1] + 500.))
new_shell = LinearRing(*tuple(new_coords))
# Assigning polygon's exterior ring w/the new shell
@@ -724,7 +732,8 @@ def test_mutable_geometries(self):
# Offsetting the each ring in the polygon by 500.
for j in xrange(len(poly)):
r = poly[j]
- for k in xrange(len(r)): r[k] = (r[k][0] + 500., r[k][1] + 500.)
+ for k in xrange(len(r)):
+ r[k] = (r[k][0] + 500., r[k][1] + 500.)
poly[j] = r
self.assertNotEqual(mpoly[i], poly)
@@ -1017,7 +1026,8 @@ def get_geoms(lst, srid=None):
g1, g2 = cPickle.loads(s1), pickle.loads(s2)
for tmpg in (g1, g2):
self.assertEqual(geom, tmpg)
- if not no_srid: self.assertEqual(geom.srid, tmpg.srid)
+ if not no_srid:
+ self.assertEqual(geom.srid, tmpg.srid)
@skipUnless(HAS_GEOS and GEOS_PREPARE, "geos >= 3.1.0 is required")
def test_prepared(self):
View
70 django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -12,26 +12,57 @@
from ..error import GEOSIndexError
-def getItem(o,i): return o[i]
-def delItem(o,i): del o[i]
-def setItem(o,i,v): o[i] = v
+def getItem(o,i):
+ return o[i]
+
+def delItem(o,i):
+ del o[i]
+
+def setItem(o,i,v):
+ o[i] = v
if HAS_GEOS:
- def api_get_distance(x): return x.distance(Point(-200,-200))
-
-def api_get_buffer(x): return x.buffer(10)
-def api_get_geom_typeid(x): return x.geom_typeid
-def api_get_num_coords(x): return x.num_coords
-def api_get_centroid(x): return x.centroid
-def api_get_empty(x): return x.empty
-def api_get_valid(x): return x.valid
-def api_get_simple(x): return x.simple
-def api_get_ring(x): return x.ring
-def api_get_boundary(x): return x.boundary
-def api_get_convex_hull(x): return x.convex_hull
-def api_get_extent(x): return x.extent
-def api_get_area(x): return x.area
-def api_get_length(x): return x.length
+ def api_get_distance(x):
+ return x.distance(Point(-200,-200))
+
+def api_get_buffer(x):
+ return x.buffer(10)
+
+def api_get_geom_typeid(x):
+ return x.geom_typeid
+
+def api_get_num_coords(x):
+ return x.num_coords
+
+def api_get_centroid(x):
+ return x.centroid
+
+def api_get_empty(x):
+ return x.empty
+
+def api_get_valid(x):
+ return x.valid
+
+def api_get_simple(x):
+ return x.simple
+
+def api_get_ring(x):
+ return x.ring
+
+def api_get_boundary(x):
+ return x.boundary
+
+def api_get_convex_hull(x):
+ return x.convex_hull
+
+def api_get_extent(x):
+ return x.extent
+
+def api_get_area(x):
+ return x.area
+
+def api_get_length(x):
+ return x.length
geos_function_tests = [val for name, val in vars().items()
if hasattr(val, '__call__')
@@ -48,7 +79,8 @@ class GEOSMutationTest(unittest.TestCase):
def test00_GEOSIndexException(self):
'Testing Geometry GEOSIndexError'
p = Point(1,2)
- for i in range(-2,2): p._checkindex(i)
+ for i in range(-2,2):
+ p._checkindex(i)
self.assertRaises(GEOSIndexError, p._checkindex, 2)
self.assertRaises(GEOSIndexError, p._checkindex, -3)
View
36 django/contrib/gis/geos/tests/test_mutable_list.py
@@ -59,7 +59,8 @@ class ListMixinTest(unittest.TestCase):
listType = UserListA
def lists_of_len(self, length=None):
- if length is None: length = self.limit
+ if length is None:
+ length = self.limit
pl = list(range(length))
return pl, self.listType(pl)
@@ -90,7 +91,8 @@ def test01_getslice(self):
def test02_setslice(self):
'Slice assignment'
- def setfcn(x,i,j,k,L): x[i:j:k] = range(L)
+ def setfcn(x,i,j,k,L):
+ x[i:j:k] = range(L)
pl, ul = self.lists_of_len()
for slen in range(self.limit + 1):
ssl = nextRange(slen)
@@ -208,9 +210,12 @@ def test04_get_set_del_single(self):
def test05_out_of_range_exceptions(self):
'Out of range exceptions'
- def setfcn(x, i): x[i] = 20
- def getfcn(x, i): return x[i]
- def delfcn(x, i): del x[i]
+ def setfcn(x, i):
+ x[i] = 20
+ def getfcn(x, i):
+ return x[i]
+ def delfcn(x, i):
+ del x[i]
pl, ul = self.lists_of_len()
for i in (-1 - self.limit, self.limit):
self.assertRaises(IndexError, setfcn, ul, i) # 'set index %d' % i)
@@ -248,7 +253,8 @@ def test06_list_methods(self):
self.assertEqual(pl[:], ul[:], 'after pop')
pl, ul = self.lists_of_len()
- def popfcn(x, i): x.pop(i)
+ def popfcn(x, i):
+ x.pop(i)
self.assertRaises(IndexError, popfcn, ul, self.limit)
self.assertRaises(IndexError, popfcn, ul, -1 - self.limit)
@@ -265,8 +271,10 @@ def popfcn(x, i): x.pop(i)
ul.remove(val)
self.assertEqual(pl[:], ul[:], 'after remove val %d' % val)
- def indexfcn(x, v): return x.index(v)
- def removefcn(x, v): return x.remove(v)
+ def indexfcn(x, v):
+ return x.index(v)
+ def removefcn(x, v):
+ return x.remove(v)
self.assertRaises(ValueError, indexfcn, ul, 40)
self.assertRaises(ValueError, removefcn, ul, 40)
@@ -276,7 +284,8 @@ def test07_allowed_types(self):
ul._allowed = six.integer_types
ul[1] = 50
ul[:2] = [60, 70, 80]
- def setfcn(x, i, v): x[i] = v
+ def setfcn(x, i, v):
+ x[i] = v
self.assertRaises(TypeError, setfcn, ul, 2, 'hello')
self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), ('hello','goodbye'))
@@ -284,8 +293,10 @@ def test08_min_length(self):
'Length limits'
pl, ul = self.lists_of_len()
ul._minlength = 1
- def delfcn(x,i): del x[:i]
- def setfcn(x,i): x[:i] = []
+ def delfcn(x,i):
+ del x[:i]
+ def setfcn(x,i):
+ x[:i] = []
for i in range(self.limit - ul._minlength + 1, self.limit + 1):
self.assertRaises(ValueError, delfcn, ul, i)
self.assertRaises(ValueError, setfcn, ul, i)
@@ -299,7 +310,8 @@ def setfcn(x,i): x[:i] = []
def test09_iterable_check(self):
'Error on assigning non-iterable to slice'
pl, ul = self.lists_of_len(self.limit + 1)
- def setfcn(x, i, v): x[i] = v
+ def setfcn(x, i, v):
+ x[i] = v
self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), 2)
def test10_checkindex(self):
View
9 django/contrib/gis/maps/google/gmap.py
@@ -87,9 +87,11 @@ def __init__(self, key=None, api_url=None, version=None,
# Defaults for the zoom level and center coordinates if the zoom
# is not automatically calculated.
- if zoom is None: zoom = 4
+ if zoom is None:
+ zoom = 4
self.zoom = zoom
- if center is None: center = (0, 0)
+ if center is None:
+ center = (0, 0)
self.center = center
def render(self):
@@ -229,5 +231,6 @@ def onload(self):
def icons(self):
"Returns a sequence of all icons in each map of the set."
icons = set()
- for map in self.maps: icons |= map.icons
+ for map in self.maps:
+ icons |= map.icons
return icons
View
27 django/contrib/gis/maps/google/overlays.py
@@ -102,8 +102,10 @@ def __init__(self, poly,
fill_opacity:
The opacity of the polygon fill. Defaults to 0.4.
"""
- if isinstance(poly, six.string_types): poly = fromstr(poly)
- if isinstance(poly, (tuple, list)): poly = Polygon(poly)
+ if isinstance(poly, six.string_types):
+ poly = fromstr(poly)
+ if isinstance(poly, (tuple, list)):
+ poly = Polygon(poly)
if not isinstance(poly, Polygon):
raise TypeError('GPolygon may only initialize on GEOS Polygons.')
@@ -152,8 +154,10 @@ def __init__(self, geom, color='#0000ff', weight=2, opacity=1):
The opacity of the polyline, between 0 and 1. Defaults to 1.
"""
# If a GEOS geometry isn't passed in, try to contsruct one.
- if isinstance(geom, six.string_types): geom = fromstr(geom)
- if isinstance(geom, (tuple, list)): geom = Polygon(geom)
+ if isinstance(geom, six.string_types):
+ geom = fromstr(geom)
+ if isinstance(geom, (tuple, list)):
+ geom = Polygon(geom)
# Generating the lat/lng coordinate pairs.
if isinstance(geom, (LineString, LinearRing)):
self.latlngs = self.latlng_from_coords(geom.coords)
@@ -282,8 +286,10 @@ def __init__(self, geom, title=None, draggable=False, icon=None):
Draggable option for GMarker, disabled by default.
"""
# If a GEOS geometry isn't passed in, try to construct one.
- if isinstance(geom, six.string_types): geom = fromstr(geom)
- if isinstance(geom, (tuple, list)): geom = Point(geom)
+ if isinstance(geom, six.string_types):
+ geom = fromstr(geom)
+ if isinstance(geom, (tuple, list)):
+ geom = Point(geom)
if isinstance(geom, Point):
self.latlng = self.latlng_from_coords(geom.coords)
else:
@@ -301,9 +307,12 @@ def latlng_from_coords(self, coords):
def options(self):
result = []
- if self.title: result.append('title: "%s"' % self.title)
- if self.icon: result.append('icon: %s' % self.icon.varname)
- if self.draggable: result.append('draggable: true')
+ if self.title:
+ result.append('title: "%s"' % self.title)
+ if self.icon:
+ result.append('icon: %s' % self.icon.varname)
+ if self.draggable:
+ result.append('draggable: true')
return '{%s}' % ','.join(result)
@property
View
3  django/contrib/gis/measure.py
@@ -179,7 +179,8 @@ def default_units(self, kwargs):
val = 0.0
default_unit = self.STANDARD_UNIT
for unit, value in six.iteritems(kwargs):
- if not isinstance(value, float): value = float(value)
+ if not isinstance(value, float):
+ value = float(value)
if unit in self.UNITS:
val += self.UNITS[unit] * value
default_unit = unit
View
6 django/contrib/gis/sitemaps/georss.py
@@ -27,7 +27,8 @@ def __init__(self, feed_dict, slug_dict=None):
# Setting up.
self.feed_dict = feed_dict
self.locations = []
- if slug_dict is None: slug_dict = {}
+ if slug_dict is None:
+ slug_dict = {}
# Getting the feed locations.
for section in feed_dict.keys():
if slug_dict.get(section, False):
@@ -42,7 +43,8 @@ def get_urls(self, page=1, site=None):
is placed on each URL element.
"""
urls = Sitemap.get_urls(self, page=page, site=site)
- for url in urls: url['geo_format'] = 'georss'
+ for url in urls:
+ url['geo_format'] = 'georss'
return urls
def items(self):
View
3  django/contrib/gis/sitemaps/kml.py
@@ -46,7 +46,8 @@ def get_urls(self, page=1, site=None):
is placed on each URL element.
"""
urls = Sitemap.get_urls(self, page=page, site=site)
- for url in urls: url['geo_format'] = self.geo_format
+ for url in urls:
+ url['geo_format'] = self.geo_format
return urls
def items(self):
View
28 django/contrib/gis/tests/distapp/models.py
@@ -7,7 +7,9 @@ class SouthTexasCity(models.Model):
name = models.CharField(max_length=30)
point = models.PointField(srid=32140)
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class SouthTexasCityFt(models.Model):
@@ -15,7 +17,9 @@ class SouthTexasCityFt(models.Model):
name = models.CharField(max_length=30)
point = models.PointField(srid=2278)
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class AustraliaCity(models.Model):
@@ -23,7 +27,9 @@ class AustraliaCity(models.Model):
name = models.CharField(max_length=30)
point = models.PointField()
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class CensusZipcode(models.Model):
@@ -31,7 +37,9 @@ class CensusZipcode(models.Model):
name = models.CharField(max_length=5)
poly = models.PolygonField(srid=4269)
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class SouthTexasZipcode(models.Model):
@@ -39,7 +47,9 @@ class SouthTexasZipcode(models.Model):
name = models.CharField(max_length=5)
poly = models.PolygonField(srid=32140, null=True)
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class Interstate(models.Model):
@@ -47,7 +57,9 @@ class Interstate(models.Model):
name = models.CharField(max_length=10)
path = models.LineStringField()
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class SouthTexasInterstate(models.Model):
@@ -55,4 +67,6 @@ class SouthTexasInterstate(models.Model):
name = models.CharField(max_length=10)
path = models.LineStringField(srid=32140)
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
View
18 django/contrib/gis/tests/distapp/tests.py
@@ -66,8 +66,10 @@ def test_dwithin(self):
# Performing distance queries on two projected coordinate systems one
# with units in meters and the other in units of U.S. survey feet.
for dist in tx_dists:
- if isinstance(dist, tuple): dist1, dist2 = dist
- else: dist1 = dist2 = dist
+ if isinstance(dist, tuple):
+ dist1, dist2 = dist
+ else:
+ dist1 = dist2 = dist
qs1 = SouthTexasCity.objects.filter(point__dwithin=(self.stx_pnt, dist1))
qs2 = SouthTexasCityFt.objects.filter(point__dwithin=(self.stx_pnt, dist2))
for qs in qs1, qs2:
@@ -75,12 +77,16 @@ def test_dwithin(self):
# Now performing the `dwithin` queries on a geodetic coordinate system.
for dist in au_dists:
- if isinstance(dist, D) and not oracle: type_error = True
- else: type_error = False
+ if isinstance(dist, D) and not oracle:
+ type_error = True
+ else:
+ type_error = False
if isinstance(dist, tuple):
- if oracle: dist = dist[1]
- else: dist = dist[0]
+ if oracle:
+ dist = dist[1]
+ else:
+ dist = dist[0]
# Creating the query set.
qs = AustraliaCity.objects.order_by('name')
View
4 django/contrib/gis/tests/geoadmin/models.py
@@ -7,6 +7,8 @@ class City(models.Model):
name = models.CharField(max_length=30)
point = models.PointField()
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
admin.site.register(City, admin.OSMGeoAdmin)
View
20 django/contrib/gis/tests/geoapp/models.py
@@ -10,14 +10,18 @@ class Country(models.Model):
name = models.CharField(max_length=30)
mpoly = models.MultiPolygonField() # SRID, by default, is 4326
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class City(models.Model):
name = models.CharField(max_length=30)
point = models.PointField()
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
# This is an inherited model from City
class PennsylvaniaCity(City):
@@ -30,14 +34,18 @@ class State(models.Model):
name = models.CharField(max_length=30)
poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
@python_2_unicode_compatible
class Track(models.Model):
name = models.CharField(max_length=30)
line = models.LineStringField()
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
class Truth(models.Model):
val = models.BooleanField(default=False)
@@ -49,7 +57,9 @@ class Feature(models.Model):
name = models.CharField(max_length=20)
geom = models.GeometryField()
objects = models.GeoManager()
- def __str__(self): return self.name
+
+ def __str__(self):
+ return self.name
class MinusOneSRID(models.Model):