Permalink
Browse files

Merge pull request #1762 from alasdairnicol/ticket_21270

Fixed #21270 -- Fixed E701 pep8 warnings
  • Loading branch information...
alex committed Oct 17, 2013
2 parents 650b6fd + eb21445 commit cce42d4cf2d6820ce04e71b7c1a785ec0d19538f
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
@@ -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):
@@ -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], []
@@ -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'
@@ -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
@@ -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):
@@ -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" '
@@ -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)
@@ -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
@@ -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
@@ -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']:
@@ -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))
@@ -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
@@ -58,15 +58,17 @@ 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.
gtype = str(geom.geom_type).lower()
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'):
@@ -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
@@ -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')
@@ -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
@@ -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
@@ -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):
"""
@@ -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 = {
Oops, something went wrong.

0 comments on commit cce42d4

Please sign in to comment.