From b35ff0d9208c426cc0f67c65d724972974734f57 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 26 Oct 2013 18:27:42 -0700 Subject: [PATCH] Fixed all the E203 violations --- .../contrib/admin/templatetags/admin_list.py | 2 +- django/contrib/admindocs/utils.py | 18 +-- django/contrib/admindocs/views.py | 20 +-- django/contrib/gis/admin/options.py | 66 +++++----- django/contrib/gis/admin/widgets.py | 2 +- .../gis/db/backends/oracle/operations.py | 36 +++--- .../gis/db/backends/postgis/introspection.py | 4 +- .../gis/db/backends/postgis/operations.py | 64 +++++----- .../db/backends/spatialite/introspection.py | 14 +-- .../gis/db/backends/spatialite/operations.py | 36 +++--- django/contrib/gis/db/backends/utils.py | 16 +-- django/contrib/gis/db/models/fields.py | 6 +- django/contrib/gis/db/models/query.py | 104 +++++++-------- django/contrib/gis/db/models/sql/query.py | 4 +- django/contrib/gis/feeds.py | 4 +- django/contrib/gis/forms/fields.py | 8 +- django/contrib/gis/gdal/driver.py | 10 +- django/contrib/gis/gdal/geometries.py | 28 ++--- django/contrib/gis/gdal/geomtype.py | 26 ++-- django/contrib/gis/gdal/tests/test_driver.py | 8 +- django/contrib/gis/geoip/base.py | 4 +- django/contrib/gis/geoip/tests.py | 4 +- django/contrib/gis/geos/geometry.py | 16 +-- django/contrib/gis/geos/tests/test_geos.py | 2 +- .../gis/management/commands/ogrinspect.py | 6 +- django/contrib/gis/maps/google/gmap.py | 26 ++-- django/contrib/gis/measure.py | 118 +++++++++--------- django/contrib/gis/sitemaps/kml.py | 4 +- django/contrib/gis/sitemaps/views.py | 2 +- django/contrib/gis/tests/geo3d/tests.py | 12 +- django/contrib/gis/tests/geoapp/feeds.py | 14 +-- django/contrib/gis/tests/geoapp/sitemaps.py | 6 +- .../contrib/gis/tests/geoapp/test_regress.py | 8 +- django/contrib/gis/tests/geoapp/tests.py | 10 +- django/contrib/gis/tests/geoapp/urls.py | 4 +- django/contrib/gis/tests/geogapp/tests.py | 6 +- django/contrib/gis/tests/layermap/models.py | 26 ++-- django/contrib/gis/tests/layermap/tests.py | 12 +- .../contrib/gis/tests/test_spatialrefsys.py | 36 +++--- django/contrib/gis/utils/layermapping.py | 44 +++---- django/contrib/gis/utils/srs.py | 8 +- django/contrib/sites/management.py | 2 +- django/core/serializers/__init__.py | 12 +- django/core/serializers/xml_serializer.py | 14 +-- django/core/urlresolvers.py | 2 +- django/forms/formsets.py | 4 +- django/test/html.py | 2 +- django/utils/translation/trans_real.py | 2 +- django/views/debug.py | 6 +- django/views/static.py | 6 +- docs/_ext/literals_to_xrefs.py | 2 +- setup.cfg | 2 +- tests/admin_views/admin.py | 8 +- tests/aggregation_regress/tests.py | 16 +-- tests/cache/tests.py | 52 ++++---- tests/forms_tests/tests/test_forms.py | 10 +- tests/model_forms/tests.py | 6 +- tests/serializers/tests.py | 2 +- tests/template_tests/filters.py | 52 ++++---- tests/template_tests/templatetags/custom.py | 20 +-- tests/template_tests/tests.py | 12 +- tests/test_client/views.py | 4 +- tests/test_utils/tests.py | 2 +- 63 files changed, 541 insertions(+), 541 deletions(-) diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index f58c5745ea..7d5a616cef 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -398,7 +398,7 @@ def admin_list_filter(cl, spec): tpl = get_template(spec.template) return tpl.render(Context({ 'title': spec.title, - 'choices' : list(spec.choices(cl)), + 'choices': list(spec.choices(cl)), 'spec': spec, })) diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py index cdb1064412..f75bf499df 100644 --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -60,10 +60,10 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None): Convert the string from reST to an XHTML fragment. """ overrides = { - 'doctitle_xform' : True, - 'inital_header_level' : 3, - "default_reference_context" : default_reference_context, - "link_base" : reverse('django-admindocs-docroot').rstrip('/') + 'doctitle_xform': True, + 'inital_header_level': 3, + "default_reference_context": default_reference_context, + "link_base": reverse('django-admindocs-docroot').rstrip('/') } if thing_being_parsed: thing_being_parsed = force_bytes("<%s>" % thing_being_parsed) @@ -85,11 +85,11 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None): # reST roles # ROLES = { - 'model' : '%s/models/%s/', - 'view' : '%s/views/%s/', - 'template' : '%s/templates/%s/', - 'filter' : '%s/filters/#%s', - 'tag' : '%s/tags/#%s', + 'model': '%s/models/%s/', + 'view': '%s/views/%s/', + 'template': '%s/templates/%s/', + 'filter': '%s/filters/#%s', + 'tag': '%s/tags/#%s', } def create_reference_role(rolename, urlbase): diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index 3c888fdb8e..405f6b2a74 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -229,12 +229,12 @@ def model_detail(request, app_label, model_name): fields.append({ 'name': "%s.all" % field.name, "data_type": 'List', - 'verbose': utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.model_name), + 'verbose': utils.parse_rst(_("all %s") % verbose, 'model', _('model:') + opts.model_name), }) fields.append({ - 'name' : "%s.count" % field.name, - 'data_type' : 'Integer', - 'verbose' : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.model_name), + 'name': "%s.count" % field.name, + 'data_type': 'Integer', + 'verbose': utils.parse_rst(_("number of %s") % verbose, 'model', _('model:') + opts.model_name), }) # Gather model methods. @@ -260,14 +260,14 @@ def model_detail(request, app_label, model_name): verbose = _("related `%(app_label)s.%(object_name)s` objects") % {'app_label': rel.opts.app_label, 'object_name': rel.opts.object_name} accessor = rel.get_accessor_name() fields.append({ - 'name' : "%s.all" % accessor, - 'data_type' : 'List', - 'verbose' : utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.model_name), + 'name': "%s.all" % accessor, + 'data_type': 'List', + 'verbose': utils.parse_rst(_("all %s") % verbose, 'model', _('model:') + opts.model_name), }) fields.append({ - 'name' : "%s.count" % accessor, - 'data_type' : 'Integer', - 'verbose' : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.model_name), + 'name': "%s.count" % accessor, + 'data_type': 'Integer', + 'verbose': utils.parse_rst(_("number of %s") % verbose, 'model', _('model:') + opts.model_name), }) return render_to_response('admin_doc/model_detail.html', { 'root_path': urlresolvers.reverse('admin:index'), diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py index c73c4224eb..6ec6a23ffd 100644 --- a/django/contrib/gis/admin/options.py +++ b/django/contrib/gis/admin/options.py @@ -86,39 +86,39 @@ class GeoModelAdmin(ModelAdmin): wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()] wms_options = ', %s' % ', '.join(wms_options) - params = {'default_lon' : self.default_lon, - 'default_lat' : self.default_lat, - 'default_zoom' : self.default_zoom, - 'display_wkt' : self.debug or self.display_wkt, - 'geom_type' : OGRGeomType(db_field.geom_type), - 'field_name' : db_field.name, - 'is_collection' : is_collection, - 'scrollable' : self.scrollable, - 'layerswitcher' : self.layerswitcher, - 'collection_type' : collection_type, - 'is_generic' : db_field.geom_type == 'GEOMETRY', - 'is_linestring' : db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'), - 'is_polygon' : db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'), - 'is_point' : db_field.geom_type in ('POINT', 'MULTIPOINT'), - 'num_zoom' : self.num_zoom, - 'max_zoom' : self.max_zoom, - 'min_zoom' : self.min_zoom, - 'units' : self.units, # likely should get from object - 'max_resolution' : self.max_resolution, - 'max_extent' : self.max_extent, - 'modifiable' : self.modifiable, - 'mouse_position' : self.mouse_position, - 'scale_text' : self.scale_text, - 'map_width' : self.map_width, - 'map_height' : self.map_height, - 'point_zoom' : self.point_zoom, - 'srid' : self.map_srid, - 'display_srid' : self.display_srid, - 'wms_url' : self.wms_url, - 'wms_layer' : self.wms_layer, - 'wms_name' : self.wms_name, - 'wms_options' : wms_options, - 'debug' : self.debug, + params = {'default_lon': self.default_lon, + 'default_lat': self.default_lat, + 'default_zoom': self.default_zoom, + 'display_wkt': self.debug or self.display_wkt, + 'geom_type': OGRGeomType(db_field.geom_type), + 'field_name': db_field.name, + 'is_collection': is_collection, + 'scrollable': self.scrollable, + 'layerswitcher': self.layerswitcher, + 'collection_type': collection_type, + 'is_generic': db_field.geom_type == 'GEOMETRY', + 'is_linestring': db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'), + 'is_polygon': db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'), + 'is_point': db_field.geom_type in ('POINT', 'MULTIPOINT'), + 'num_zoom': self.num_zoom, + 'max_zoom': self.max_zoom, + 'min_zoom': self.min_zoom, + 'units': self.units, # likely should get from object + 'max_resolution': self.max_resolution, + 'max_extent': self.max_extent, + 'modifiable': self.modifiable, + 'mouse_position': self.mouse_position, + 'scale_text': self.scale_text, + 'map_width': self.map_width, + 'map_height': self.map_height, + 'point_zoom': self.point_zoom, + 'srid': self.map_srid, + 'display_srid': self.display_srid, + 'wms_url': self.wms_url, + 'wms_layer': self.wms_layer, + 'wms_name': self.wms_name, + 'wms_options': wms_options, + 'debug': self.debug, } return OLMap diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index 8533bdc044..b098b7e7a2 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -10,7 +10,7 @@ from django.contrib.gis.geos import GEOSGeometry, GEOSException # Creating a template context that contains Django settings # values needed by admin map templates. -geo_context = Context({'LANGUAGE_BIDI' : translation.get_language_bidi()}) +geo_context = Context({'LANGUAGE_BIDI': translation.get_language_bidi()}) logger = logging.getLogger('django.contrib.gis') diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 9eed8632e8..5fced474c8 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -109,33 +109,33 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations): select = 'SDO_UTIL.TO_WKTGEOMETRY(%s)' distance_functions = { - 'distance_gt' : (SDODistance('>'), dtypes), - 'distance_gte' : (SDODistance('>='), dtypes), - 'distance_lt' : (SDODistance('<'), dtypes), - 'distance_lte' : (SDODistance('<='), dtypes), - 'dwithin' : (SDODWithin(), dtypes), + 'distance_gt': (SDODistance('>'), dtypes), + 'distance_gte': (SDODistance('>='), dtypes), + 'distance_lt': (SDODistance('<'), dtypes), + 'distance_lte': (SDODistance('<='), dtypes), + 'dwithin': (SDODWithin(), dtypes), } geometry_functions = { - 'contains' : SDOOperation('SDO_CONTAINS'), - 'coveredby' : SDOOperation('SDO_COVEREDBY'), - 'covers' : SDOOperation('SDO_COVERS'), - 'disjoint' : SDOGeomRelate('DISJOINT'), - 'intersects' : SDOOperation('SDO_OVERLAPBDYINTERSECT'), # TODO: Is this really the same as ST_Intersects()? - 'equals' : SDOOperation('SDO_EQUAL'), - 'exact' : SDOOperation('SDO_EQUAL'), - 'overlaps' : SDOOperation('SDO_OVERLAPS'), - 'same_as' : SDOOperation('SDO_EQUAL'), - 'relate' : (SDORelate, six.string_types), # Oracle uses a different syntax, e.g., 'mask=inside+touch' - 'touches' : SDOOperation('SDO_TOUCH'), - 'within' : SDOOperation('SDO_INSIDE'), + 'contains': SDOOperation('SDO_CONTAINS'), + 'coveredby': SDOOperation('SDO_COVEREDBY'), + 'covers': SDOOperation('SDO_COVERS'), + 'disjoint': SDOGeomRelate('DISJOINT'), + 'intersects': SDOOperation('SDO_OVERLAPBDYINTERSECT'), # TODO: Is this really the same as ST_Intersects()? + 'equals': SDOOperation('SDO_EQUAL'), + 'exact': SDOOperation('SDO_EQUAL'), + 'overlaps': SDOOperation('SDO_OVERLAPS'), + 'same_as': SDOOperation('SDO_EQUAL'), + 'relate': (SDORelate, six.string_types), # Oracle uses a different syntax, e.g., 'mask=inside+touch' + 'touches': SDOOperation('SDO_TOUCH'), + 'within': SDOOperation('SDO_INSIDE'), } geometry_functions.update(distance_functions) gis_terms = set(['isnull']) gis_terms.update(geometry_functions) - truncate_params = {'relate' : None} + truncate_params = {'relate': None} def convert_extent(self, clob): if clob: diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py index 3189fa4553..d9e1dd350e 100644 --- a/django/contrib/gis/db/backends/postgis/introspection.py +++ b/django/contrib/gis/db/backends/postgis/introspection.py @@ -32,14 +32,14 @@ class PostGISIntrospection(DatabaseIntrospection): try: cursor.execute(oid_sql, ('geometry',)) GEOM_TYPE = cursor.fetchone()[0] - postgis_types = {GEOM_TYPE : 'GeometryField'} + postgis_types = {GEOM_TYPE: 'GeometryField'} if self.connection.ops.geography: cursor.execute(oid_sql, ('geography',)) GEOG_TYPE = cursor.fetchone()[0] # The value for the geography type is actually a tuple # to pass in the `geography=True` keyword to the field # definition. - postgis_types[GEOG_TYPE] = ('GeometryField', {'geography' : True}) + postgis_types[GEOG_TYPE] = ('GeometryField', {'geography': True}) finally: cursor.close() diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 867402c92d..92e5323d36 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -84,56 +84,56 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations): self.geometry_operators = { # The "&<" operator returns true if A's bounding box overlaps or # is to the left of B's bounding box. - 'overlaps_left' : PostGISOperator('&<'), + 'overlaps_left': PostGISOperator('&<'), # The "&>" operator returns true if A's bounding box overlaps or # is to the right of B's bounding box. - 'overlaps_right' : PostGISOperator('&>'), + 'overlaps_right': PostGISOperator('&>'), # The "<<" operator returns true if A's bounding box is strictly # to the left of B's bounding box. - 'left' : PostGISOperator('<<'), + 'left': PostGISOperator('<<'), # The ">>" operator returns true if A's bounding box is strictly # to the right of B's bounding box. - 'right' : PostGISOperator('>>'), + 'right': PostGISOperator('>>'), # The "&<|" operator returns true if A's bounding box overlaps or # is below B's bounding box. - 'overlaps_below' : PostGISOperator('&<|'), + 'overlaps_below': PostGISOperator('&<|'), # The "|&>" operator returns true if A's bounding box overlaps or # is above B's bounding box. - 'overlaps_above' : PostGISOperator('|&>'), + 'overlaps_above': PostGISOperator('|&>'), # The "<<|" operator returns true if A's bounding box is strictly # below B's bounding box. - 'strictly_below' : PostGISOperator('<<|'), + 'strictly_below': PostGISOperator('<<|'), # The "|>>" operator returns true if A's bounding box is strictly # above B's bounding box. - 'strictly_above' : PostGISOperator('|>>'), + 'strictly_above': PostGISOperator('|>>'), # The "~=" operator is the "same as" operator. It tests actual # geometric equality of two features. So if A and B are the same feature, # vertex-by-vertex, the operator returns true. - 'same_as' : PostGISOperator('~='), - 'exact' : PostGISOperator('~='), + 'same_as': PostGISOperator('~='), + 'exact': PostGISOperator('~='), # The "@" operator returns true if A's bounding box is completely contained # by B's bounding box. - 'contained' : PostGISOperator('@'), + 'contained': PostGISOperator('@'), # The "~" operator returns true if A's bounding box completely contains # by B's bounding box. - 'bbcontains' : PostGISOperator('~'), + 'bbcontains': PostGISOperator('~'), # The "&&" operator returns true if A's bounding box overlaps # B's bounding box. - 'bboverlaps' : PostGISOperator('&&'), + 'bboverlaps': PostGISOperator('&&'), } self.geometry_functions = { - 'equals' : PostGISFunction(prefix, 'Equals'), - 'disjoint' : PostGISFunction(prefix, 'Disjoint'), - 'touches' : PostGISFunction(prefix, 'Touches'), - 'crosses' : PostGISFunction(prefix, 'Crosses'), - 'within' : PostGISFunction(prefix, 'Within'), - 'overlaps' : PostGISFunction(prefix, 'Overlaps'), - 'contains' : PostGISFunction(prefix, 'Contains'), - 'intersects' : PostGISFunction(prefix, 'Intersects'), - 'relate' : (PostGISRelate, six.string_types), - 'coveredby' : PostGISFunction(prefix, 'CoveredBy'), - 'covers' : PostGISFunction(prefix, 'Covers'), + 'equals': PostGISFunction(prefix, 'Equals'), + 'disjoint': PostGISFunction(prefix, 'Disjoint'), + 'touches': PostGISFunction(prefix, 'Touches'), + 'crosses': PostGISFunction(prefix, 'Crosses'), + 'within': PostGISFunction(prefix, 'Within'), + 'overlaps': PostGISFunction(prefix, 'Overlaps'), + 'contains': PostGISFunction(prefix, 'Contains'), + 'intersects': PostGISFunction(prefix, 'Intersects'), + 'relate': (PostGISRelate, six.string_types), + 'coveredby': PostGISFunction(prefix, 'CoveredBy'), + 'covers': PostGISFunction(prefix, 'Covers'), } # Valid distance types and substitutions @@ -141,16 +141,16 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations): def get_dist_ops(operator): "Returns operations for both regular and spherical distances." - return {'cartesian' : PostGISDistance(prefix, operator), - 'sphere' : PostGISSphereDistance(prefix, operator), - 'spheroid' : PostGISSpheroidDistance(prefix, operator), + return {'cartesian': PostGISDistance(prefix, operator), + 'sphere': PostGISSphereDistance(prefix, operator), + 'spheroid': PostGISSpheroidDistance(prefix, operator), } self.distance_functions = { - 'distance_gt' : (get_dist_ops('>'), dtypes), - 'distance_gte' : (get_dist_ops('>='), dtypes), - 'distance_lt' : (get_dist_ops('<'), dtypes), - 'distance_lte' : (get_dist_ops('<='), dtypes), - 'dwithin' : (PostGISFunctionParam(prefix, 'DWithin'), dtypes) + 'distance_gt': (get_dist_ops('>'), dtypes), + 'distance_gte': (get_dist_ops('>='), dtypes), + 'distance_lt': (get_dist_ops('<'), dtypes), + 'distance_lte': (get_dist_ops('<='), dtypes), + 'dwithin': (PostGISFunctionParam(prefix, 'DWithin'), dtypes) } # Adding the distance functions to the geometries lookup. diff --git a/django/contrib/gis/db/backends/spatialite/introspection.py b/django/contrib/gis/db/backends/spatialite/introspection.py index 90ed83fa08..c841d1ae6a 100644 --- a/django/contrib/gis/db/backends/spatialite/introspection.py +++ b/django/contrib/gis/db/backends/spatialite/introspection.py @@ -9,13 +9,13 @@ class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict): """ base_data_types_reverse = FlexibleFieldLookupDict.base_data_types_reverse.copy() base_data_types_reverse.update( - {'point' : 'GeometryField', - 'linestring' : 'GeometryField', - 'polygon' : 'GeometryField', - 'multipoint' : 'GeometryField', - 'multilinestring' : 'GeometryField', - 'multipolygon' : 'GeometryField', - 'geometrycollection' : 'GeometryField', + {'point': 'GeometryField', + 'linestring': 'GeometryField', + 'polygon': 'GeometryField', + 'multipoint': 'GeometryField', + 'multilinestring': 'GeometryField', + 'multipolygon': 'GeometryField', + 'geometrycollection': 'GeometryField', }) class SpatiaLiteIntrospection(DatabaseIntrospection): diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 6fada2e336..4954ba5210 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -86,31 +86,31 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations): select = 'AsText(%s)' geometry_functions = { - 'equals' : SpatiaLiteFunction('Equals'), - 'disjoint' : SpatiaLiteFunction('Disjoint'), - 'touches' : SpatiaLiteFunction('Touches'), - 'crosses' : SpatiaLiteFunction('Crosses'), - 'within' : SpatiaLiteFunction('Within'), - 'overlaps' : SpatiaLiteFunction('Overlaps'), - 'contains' : SpatiaLiteFunction('Contains'), - 'intersects' : SpatiaLiteFunction('Intersects'), - 'relate' : (SpatiaLiteRelate, six.string_types), + 'equals': SpatiaLiteFunction('Equals'), + 'disjoint': SpatiaLiteFunction('Disjoint'), + 'touches': SpatiaLiteFunction('Touches'), + 'crosses': SpatiaLiteFunction('Crosses'), + 'within': SpatiaLiteFunction('Within'), + 'overlaps': SpatiaLiteFunction('Overlaps'), + 'contains': SpatiaLiteFunction('Contains'), + 'intersects': SpatiaLiteFunction('Intersects'), + 'relate': (SpatiaLiteRelate, six.string_types), # Returns true if B's bounding box completely contains A's bounding box. - 'contained' : SpatiaLiteFunction('MbrWithin'), + 'contained': SpatiaLiteFunction('MbrWithin'), # Returns true if A's bounding box completely contains B's bounding box. - 'bbcontains' : SpatiaLiteFunction('MbrContains'), + 'bbcontains': SpatiaLiteFunction('MbrContains'), # Returns true if A's bounding box overlaps B's bounding box. - 'bboverlaps' : SpatiaLiteFunction('MbrOverlaps'), + 'bboverlaps': SpatiaLiteFunction('MbrOverlaps'), # These are implemented here as synonyms for Equals - 'same_as' : SpatiaLiteFunction('Equals'), - 'exact' : SpatiaLiteFunction('Equals'), + 'same_as': SpatiaLiteFunction('Equals'), + 'exact': SpatiaLiteFunction('Equals'), } distance_functions = { - 'distance_gt' : (get_dist_ops('>'), dtypes), - 'distance_gte' : (get_dist_ops('>='), dtypes), - 'distance_lt' : (get_dist_ops('<'), dtypes), - 'distance_lte' : (get_dist_ops('<='), dtypes), + 'distance_gt': (get_dist_ops('>'), dtypes), + 'distance_gte': (get_dist_ops('>='), dtypes), + 'distance_lt': (get_dist_ops('<'), dtypes), + 'distance_lte': (get_dist_ops('<='), dtypes), } geometry_functions.update(distance_functions) diff --git a/django/contrib/gis/db/backends/utils.py b/django/contrib/gis/db/backends/utils.py index 2612810659..53f1e1b6a4 100644 --- a/django/contrib/gis/db/backends/utils.py +++ b/django/contrib/gis/db/backends/utils.py @@ -19,11 +19,11 @@ class SpatialOperation(object): return self.sql_template % self.params(geo_col, geometry), [] def params(self, geo_col, geometry): - params = {'function' : self.function, - 'geo_col' : geo_col, - 'geometry' : geometry, - 'operator' : self.operator, - 'result' : self.result, + params = {'function': self.function, + 'geo_col': geo_col, + 'geometry': geometry, + 'operator': self.operator, + 'result': self.result, } params.update(self.extra) return params @@ -36,9 +36,9 @@ class SpatialFunction(SpatialOperation): def __init__(self, func, result='', operator='', **kwargs): # Getting the function prefix. - default = {'function' : func, - 'operator' : operator, - 'result' : result + default = {'function': func, + 'operator': operator, + 'result': result } kwargs.update(default) super(SpatialFunction, self).__init__(**kwargs) diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index d29705986f..e137ddffb5 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -203,9 +203,9 @@ class GeometryField(Field): return connection.ops.geo_db_type(self) def formfield(self, **kwargs): - defaults = {'form_class' : self.form_class, - 'geom_type' : self.geom_type, - 'srid' : self.srid, + defaults = {'form_class': self.form_class, + 'geom_type': self.geom_type, + 'srid': self.srid, } defaults.update(kwargs) if (self.dim > 2 and not 'widget' in kwargs and diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py index f418fc8f00..2d13cbecc0 100644 --- a/django/contrib/gis/db/models/query.py +++ b/django/contrib/gis/db/models/query.py @@ -41,9 +41,9 @@ class GeoQuerySet(QuerySet): # Peforming setup here rather than in `_spatial_attribute` so that # we can get the units for `AreaField`. procedure_args, geo_field = self._spatial_setup('area', field_name=kwargs.get('field_name', None)) - s = {'procedure_args' : procedure_args, - 'geo_field' : geo_field, - 'setup' : False, + s = {'procedure_args': procedure_args, + 'geo_field': geo_field, + 'setup': False, } connection = connections[self.db] backend = connection.ops @@ -170,9 +170,9 @@ class GeoQuerySet(QuerySet): options = 1 elif bbox: options = 2 - s = {'desc' : 'GeoJSON', - 'procedure_args' : {'precision' : precision, 'options' : options}, - 'procedure_fmt' : '%(geo_col)s,%(precision)s,%(options)s', + s = {'desc': 'GeoJSON', + 'procedure_args': {'precision': precision, 'options': options}, + 'procedure_fmt': '%(geo_col)s,%(precision)s,%(options)s', } return self._spatial_attribute('geojson', s, **kwargs) @@ -184,7 +184,7 @@ class GeoQuerySet(QuerySet): The `precision` keyword may be used to custom the number of _characters_ used in the output GeoHash, the default is 20. """ - s = {'desc' : 'GeoHash', + s = {'desc': 'GeoHash', 'procedure_args': {'precision': precision}, 'procedure_fmt': '%(geo_col)s,%(precision)s', } @@ -196,7 +196,7 @@ class GeoQuerySet(QuerySet): on each element of the GeoQuerySet. """ backend = connections[self.db].ops - s = {'desc' : 'GML', 'procedure_args' : {'precision' : precision}} + s = {'desc': 'GML', 'procedure_args': {'precision': precision}} if backend.postgis: # PostGIS AsGML() aggregate function parameter order depends on the # version -- uggh. @@ -204,7 +204,7 @@ class GeoQuerySet(QuerySet): s['procedure_fmt'] = '%(version)s,%(geo_col)s,%(precision)s' else: s['procedure_fmt'] = '%(geo_col)s,%(precision)s,%(version)s' - s['procedure_args'] = {'precision' : precision, 'version' : version} + s['procedure_args'] = {'precision': precision, 'version': version} return self._spatial_attribute('gml', s, **kwargs) @@ -221,9 +221,9 @@ class GeoQuerySet(QuerySet): Returns KML representation of the geometry field in a `kml` attribute on each element of this GeoQuerySet. """ - s = {'desc' : 'KML', - 'procedure_fmt' : '%(geo_col)s,%(precision)s', - 'procedure_args' : {'precision' : kwargs.pop('precision', 8)}, + s = {'desc': 'KML', + 'procedure_fmt': '%(geo_col)s,%(precision)s', + 'procedure_args': {'precision': kwargs.pop('precision', 8)}, } return self._spatial_attribute('kml', s, **kwargs) @@ -300,14 +300,14 @@ class GeoQuerySet(QuerySet): if connections[self.db].ops.spatialite: if z != 0.0: raise NotImplementedError('SpatiaLite does not support 3D scaling.') - s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s', - 'procedure_args' : {'x' : x, 'y' : y}, - 'select_field' : GeomField(), + s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s', + 'procedure_args': {'x': x, 'y': y}, + 'select_field': GeomField(), } else: - s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s,%(z)s', - 'procedure_args' : {'x' : x, 'y' : y, 'z' : z}, - 'select_field' : GeomField(), + s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s,%(z)s', + 'procedure_args': {'x': x, 'y': y, 'z': z}, + 'select_field': GeomField(), } return self._spatial_attribute('scale', s, **kwargs) @@ -327,22 +327,22 @@ class GeoQuerySet(QuerySet): if nargs == 1: size = args[0] procedure_fmt = '%(geo_col)s,%(size)s' - procedure_args = {'size' : size} + procedure_args = {'size': size} elif nargs == 2: xsize, ysize = args procedure_fmt = '%(geo_col)s,%(xsize)s,%(ysize)s' - procedure_args = {'xsize' : xsize, 'ysize' : ysize} + procedure_args = {'xsize': xsize, 'ysize': ysize} elif nargs == 4: xsize, ysize, xorigin, yorigin = args procedure_fmt = '%(geo_col)s,%(xorigin)s,%(yorigin)s,%(xsize)s,%(ysize)s' - procedure_args = {'xsize' : xsize, 'ysize' : ysize, - 'xorigin' : xorigin, 'yorigin' : yorigin} + procedure_args = {'xsize': xsize, 'ysize': ysize, + 'xorigin': xorigin, 'yorigin': yorigin} else: raise ValueError('Must provide 1, 2, or 4 arguments to `snap_to_grid`.') - s = {'procedure_fmt' : procedure_fmt, - 'procedure_args' : procedure_args, - 'select_field' : GeomField(), + s = {'procedure_fmt': procedure_fmt, + 'procedure_args': procedure_args, + 'select_field': GeomField(), } return self._spatial_attribute('snap_to_grid', s, **kwargs) @@ -362,10 +362,10 @@ class GeoQuerySet(QuerySet): relative = int(bool(relative)) if not isinstance(precision, six.integer_types): raise TypeError('SVG precision keyword argument must be an integer.') - s = {'desc' : 'SVG', - 'procedure_fmt' : '%(geo_col)s,%(rel)s,%(precision)s', - 'procedure_args' : {'rel' : relative, - 'precision' : precision, + s = {'desc': 'SVG', + 'procedure_fmt': '%(geo_col)s,%(rel)s,%(precision)s', + 'procedure_args': {'rel': relative, + 'precision': precision, } } return self._spatial_attribute('svg', s, **kwargs) @@ -385,14 +385,14 @@ class GeoQuerySet(QuerySet): if connections[self.db].ops.spatialite: if z != 0.0: raise NotImplementedError('SpatiaLite does not support 3D translation.') - s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s', - 'procedure_args' : {'x' : x, 'y' : y}, - 'select_field' : GeomField(), + s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s', + 'procedure_args': {'x': x, 'y': y}, + 'select_field': GeomField(), } else: - s = {'procedure_fmt' : '%(geo_col)s,%(x)s,%(y)s,%(z)s', - 'procedure_args' : {'x' : x, 'y' : y, 'z' : z}, - 'select_field' : GeomField(), + s = {'procedure_fmt': '%(geo_col)s,%(x)s,%(y)s,%(z)s', + 'procedure_args': {'x': x, 'y': y, 'z': z}, + 'select_field': GeomField(), } return self._spatial_attribute('translate', s, **kwargs) @@ -455,7 +455,7 @@ class GeoQuerySet(QuerySet): (desc, connection.ops.name)) # Initializing the procedure arguments. - procedure_args = {'function' : func} + procedure_args = {'function': func} # Is there a geographic field in the model to perform this # operation on? @@ -580,7 +580,7 @@ class GeoQuerySet(QuerySet): # Finally, setting the extra selection attribute with # the format string expanded with the stored procedure # arguments. - return self.extra(select={model_att : fmt % settings['procedure_args']}, + return self.extra(select={model_att: fmt % settings['procedure_args']}, select_params=settings['select_params']) def _distance_attribute(self, func, geom=None, tolerance=0.05, spheroid=False, **kwargs): @@ -695,29 +695,29 @@ class GeoQuerySet(QuerySet): if spheroid: # Call to distance_spheroid() requires spheroid param as well. procedure_fmt += ",'%(spheroid)s'" - procedure_args.update({'function' : backend.distance_spheroid, 'spheroid' : params[1]}) + procedure_args.update({'function': backend.distance_spheroid, 'spheroid': params[1]}) else: - procedure_args.update({'function' : backend.distance_sphere}) + procedure_args.update({'function': backend.distance_sphere}) elif length or perimeter: procedure_fmt = '%(geo_col)s' if not geography and geodetic and length: # There's no `length_sphere`, and `length_spheroid` also # works on 3D geometries. procedure_fmt += ",'%(spheroid)s'" - procedure_args.update({'function' : backend.length_spheroid, 'spheroid' : params[1]}) + procedure_args.update({'function': backend.length_spheroid, 'spheroid': params[1]}) elif geom_3d and backend.postgis: # Use 3D variants of perimeter and length routines on PostGIS. if perimeter: - procedure_args.update({'function' : backend.perimeter3d}) + procedure_args.update({'function': backend.perimeter3d}) elif length: - procedure_args.update({'function' : backend.length3d}) + procedure_args.update({'function': backend.length3d}) # Setting up the settings for `_spatial_attribute`. - s = {'select_field' : DistanceField(dist_att), - 'setup' : False, - 'geo_field' : geo_field, - 'procedure_args' : procedure_args, - 'procedure_fmt' : procedure_fmt, + s = {'select_field': DistanceField(dist_att), + 'setup': False, + 'geo_field': geo_field, + 'procedure_args': procedure_args, + 'procedure_fmt': procedure_fmt, } if geom_args: s['geom_args'] = ('geom',) @@ -736,7 +736,7 @@ class GeoQuerySet(QuerySet): s = {'select_field': GeomField()} if connections[self.db].ops.oracle: s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s' - s['procedure_args'] = {'tolerance' : tolerance} + s['procedure_args'] = {'tolerance': tolerance} return self._spatial_attribute(func, s, **kwargs) def _geomset_attribute(self, func, geom, tolerance=0.05, **kwargs): @@ -746,10 +746,10 @@ class GeoQuerySet(QuerySet): for geometry set-like operations (e.g., intersection, difference, union, sym_difference). """ - s = {'geom_args' : ('geom',), - 'select_field' : GeomField(), - 'procedure_fmt' : '%(geo_col)s,%(geom)s', - 'procedure_args' : {'geom' : geom}, + s = {'geom_args': ('geom',), + 'select_field': GeomField(), + 'procedure_fmt': '%(geo_col)s,%(geom)s', + 'procedure_args': {'geom': geom}, } if connections[self.db].ops.oracle: s['procedure_fmt'] += ',%(tolerance)s' diff --git a/django/contrib/gis/db/models/sql/query.py b/django/contrib/gis/db/models/sql/query.py index d93bada571..b789174525 100644 --- a/django/contrib/gis/db/models/sql/query.py +++ b/django/contrib/gis/db/models/sql/query.py @@ -67,9 +67,9 @@ class GeoQuery(sql.Query): elif isinstance(field, DistanceField): # Using the field's distance attribute, can instantiate # `Distance` with the right context. - value = Distance(**{field.distance_att : value}) + value = Distance(**{field.distance_att: value}) elif isinstance(field, AreaField): - value = Area(**{field.area_att : value}) + value = Area(**{field.area_att: value}) elif isinstance(field, (GeomField, GeometryField)) and value: value = Geometry(value) elif field is not None: diff --git a/django/contrib/gis/feeds.py b/django/contrib/gis/feeds.py index 14976717ad..1482064fe2 100644 --- a/django/contrib/gis/feeds.py +++ b/django/contrib/gis/feeds.py @@ -133,7 +133,7 @@ class Feed(BaseFeed): feed_type = GeoRSSFeed def feed_extra_kwargs(self, obj): - return {'geometry' : self.__get_dynamic_attr('geometry', obj)} + return {'geometry': self.__get_dynamic_attr('geometry', obj)} def item_extra_kwargs(self, item): - return {'geometry' : self.__get_dynamic_attr('item_geometry', item)} + return {'geometry': self.__get_dynamic_attr('item_geometry', item)} diff --git a/django/contrib/gis/forms/fields.py b/django/contrib/gis/forms/fields.py index 2e75689010..2445e54715 100644 --- a/django/contrib/gis/forms/fields.py +++ b/django/contrib/gis/forms/fields.py @@ -19,10 +19,10 @@ class GeometryField(forms.Field): geom_type = 'GEOMETRY' default_error_messages = { - 'required' : _('No geometry value provided.'), - 'invalid_geom' : _('Invalid geometry value.'), - 'invalid_geom_type' : _('Invalid geometry type.'), - 'transform_error' : _('An error occurred when transforming the geometry ' + 'required': _('No geometry value provided.'), + 'invalid_geom': _('Invalid geometry value.'), + 'invalid_geom_type': _('Invalid geometry type.'), + 'transform_error': _('An error occurred when transforming the geometry ' 'to the SRID of the geometry form field.'), } diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py index cf5bb8bb58..015785b8d1 100644 --- a/django/contrib/gis/gdal/driver.py +++ b/django/contrib/gis/gdal/driver.py @@ -15,11 +15,11 @@ class Driver(GDALBase): "Wraps an OGR Data Source Driver." # Case-insensitive aliases for OGR Drivers. - _alias = {'esri' : 'ESRI Shapefile', - 'shp' : 'ESRI Shapefile', - 'shape' : 'ESRI Shapefile', - 'tiger' : 'TIGER', - 'tiger/line' : 'TIGER', + _alias = {'esri': 'ESRI Shapefile', + 'shp': 'ESRI Shapefile', + 'shape': 'ESRI Shapefile', + 'tiger': 'TIGER', + 'tiger/line': 'TIGER', } def __init__(self, dr_input): diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index a6613b0db4..74a4e94450 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -711,19 +711,19 @@ class MultiPolygon(GeometryCollection): pass # Class mapping dictionary (using the OGRwkbGeometryType as the key) -GEO_CLASSES = {1 : Point, - 2 : LineString, - 3 : Polygon, - 4 : MultiPoint, - 5 : MultiLineString, - 6 : MultiPolygon, - 7 : GeometryCollection, +GEO_CLASSES = {1: Point, + 2: LineString, + 3: Polygon, + 4: MultiPoint, + 5: MultiLineString, + 6: MultiPolygon, + 7: GeometryCollection, 101: LinearRing, - 1 + OGRGeomType.wkb25bit : Point, - 2 + OGRGeomType.wkb25bit : LineString, - 3 + OGRGeomType.wkb25bit : Polygon, - 4 + OGRGeomType.wkb25bit : MultiPoint, - 5 + OGRGeomType.wkb25bit : MultiLineString, - 6 + OGRGeomType.wkb25bit : MultiPolygon, - 7 + OGRGeomType.wkb25bit : GeometryCollection, + 1 + OGRGeomType.wkb25bit: Point, + 2 + OGRGeomType.wkb25bit: LineString, + 3 + OGRGeomType.wkb25bit: Polygon, + 4 + OGRGeomType.wkb25bit: MultiPoint, + 5 + OGRGeomType.wkb25bit: MultiLineString, + 6 + OGRGeomType.wkb25bit: MultiPolygon, + 7 + OGRGeomType.wkb25bit: GeometryCollection, } diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 1b1547c341..e943a03ee8 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -9,23 +9,23 @@ class OGRGeomType(object): wkb25bit = -2147483648 # Dictionary of acceptable OGRwkbGeometryType s and their string names. - _types = {0 : 'Unknown', - 1 : 'Point', - 2 : 'LineString', - 3 : 'Polygon', - 4 : 'MultiPoint', - 5 : 'MultiLineString', - 6 : 'MultiPolygon', - 7 : 'GeometryCollection', - 100 : 'None', - 101 : 'LinearRing', + _types = {0: 'Unknown', + 1: 'Point', + 2: 'LineString', + 3: 'Polygon', + 4: 'MultiPoint', + 5: 'MultiLineString', + 6: 'MultiPolygon', + 7: 'GeometryCollection', + 100: 'None', + 101: 'LinearRing', 1 + wkb25bit: 'Point25D', 2 + wkb25bit: 'LineString25D', 3 + wkb25bit: 'Polygon25D', 4 + wkb25bit: 'MultiPoint25D', - 5 + wkb25bit : 'MultiLineString25D', - 6 + wkb25bit : 'MultiPolygon25D', - 7 + wkb25bit : 'GeometryCollection25D', + 5 + wkb25bit: 'MultiLineString25D', + 6 + wkb25bit: 'MultiPolygon25D', + 7 + wkb25bit: 'GeometryCollection25D', } # Reverse type dictionary, keyed by lower-case of the name. _str_types = dict((v.lower(), k) for k, v in _types.items()) diff --git a/django/contrib/gis/gdal/tests/test_driver.py b/django/contrib/gis/gdal/tests/test_driver.py index af0ecf5dc8..89c65afeb9 100644 --- a/django/contrib/gis/gdal/tests/test_driver.py +++ b/django/contrib/gis/gdal/tests/test_driver.py @@ -12,10 +12,10 @@ valid_drivers = ('ESRI Shapefile', 'MapInfo File', 'TIGER', 'S57', 'DGN', invalid_drivers = ('Foo baz', 'clucka', 'ESRI Shp') -aliases = {'eSrI' : 'ESRI Shapefile', - 'TigER/linE' : 'TIGER', - 'SHAPE' : 'ESRI Shapefile', - 'sHp' : 'ESRI Shapefile', +aliases = {'eSrI': 'ESRI Shapefile', + 'TigER/linE': 'TIGER', + 'SHAPE': 'ESRI Shapefile', + 'sHp': 'ESRI Shapefile', } diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py index 0fb2614b0c..c4188d8819 100644 --- a/django/contrib/gis/geoip/base.py +++ b/django/contrib/gis/geoip/base.py @@ -195,8 +195,8 @@ class GeoIP(object): '24.124.1.80' and 'djangoproject.com' are valid parameters. """ # Returning the country code and name - return {'country_code' : self.country_code(query), - 'country_name' : self.country_name(query), + return {'country_code': self.country_code(query), + 'country_name': self.country_name(query), } #### Coordinate retrieval routines #### diff --git a/django/contrib/gis/geoip/tests.py b/django/contrib/gis/geoip/tests.py index c49ffb5bf1..4e7a990d50 100644 --- a/django/contrib/gis/geoip/tests.py +++ b/django/contrib/gis/geoip/tests.py @@ -80,7 +80,7 @@ class GeoIPTest(unittest.TestCase): self.assertEqual('US', func(query)) for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name): self.assertEqual('United States', func(query)) - self.assertEqual({'country_code' : 'US', 'country_name' : 'United States'}, + self.assertEqual({'country_code': 'US', 'country_name': 'United States'}, g.country(query)) @skipUnless(HAS_GEOS, "Geos is required") @@ -96,7 +96,7 @@ class GeoIPTest(unittest.TestCase): self.assertEqual('US', func(query)) for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name): self.assertEqual('United States', func(query)) - self.assertEqual({'country_code' : 'US', 'country_name' : 'United States'}, + self.assertEqual({'country_code': 'US', 'country_name': 'United States'}, g.country(query)) # City information dictionary. diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index 7965fffa79..073415abea 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -707,14 +707,14 @@ from django.contrib.gis.geos.linestring import LineString, LinearRing from django.contrib.gis.geos.point import Point from django.contrib.gis.geos.polygon import Polygon from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon -GEOS_CLASSES = {0 : Point, - 1 : LineString, - 2 : LinearRing, - 3 : Polygon, - 4 : MultiPoint, - 5 : MultiLineString, - 6 : MultiPolygon, - 7 : GeometryCollection, +GEOS_CLASSES = {0: Point, + 1: LineString, + 2: LinearRing, + 3: Polygon, + 4: MultiPoint, + 5: MultiLineString, + 6: MultiPolygon, + 7: GeometryCollection, } # If supported, import the PreparedGeometry class. diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index 8e1552539f..9c24f614df 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -239,7 +239,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # an invalid type. for g in (p, ls): self.assertNotEqual(g, None) - self.assertNotEqual(g, {'foo' : 'bar'}) + self.assertNotEqual(g, {'foo': 'bar'}) self.assertNotEqual(g, False) def test_points(self): diff --git a/django/contrib/gis/management/commands/ogrinspect.py b/django/contrib/gis/management/commands/ogrinspect.py index af2d585f28..1c6482e3b5 100644 --- a/django/contrib/gis/management/commands/ogrinspect.py +++ b/django/contrib/gis/management/commands/ogrinspect.py @@ -103,9 +103,9 @@ class Command(LabelCommand): if show_mapping: # Constructing the keyword arguments for `mapping`, and # calling it on the data source. - kwargs = {'geom_name' : options['geom_name'], - 'layer_key' : options['layer_key'], - 'multi_geom' : options['multi_geom'], + kwargs = {'geom_name': options['geom_name'], + 'layer_key': options['layer_key'], + 'multi_geom': options['multi_geom'], } mapping_dict = mapping(ds, **kwargs) # This extra legwork is so that the dictionary definition comes diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py index 89b625378d..590b9999af 100644 --- a/django/contrib/gis/maps/google/gmap.py +++ b/django/contrib/gis/maps/google/gmap.py @@ -98,16 +98,16 @@ class GoogleMap(object): """ Generates the JavaScript necessary for displaying this Google Map. """ - params = {'calc_zoom' : self.calc_zoom, - 'center' : self.center, - 'dom_id' : self.dom_id, - 'js_module' : self.js_module, - 'kml_urls' : self.kml_urls, - 'zoom' : self.zoom, - 'polygons' : self.polygons, - 'polylines' : self.polylines, + params = {'calc_zoom': self.calc_zoom, + 'center': self.center, + 'dom_id': self.dom_id, + 'js_module': self.js_module, + 'kml_urls': self.kml_urls, + 'zoom': self.zoom, + 'polygons': self.polygons, + 'polylines': self.polylines, 'icons': self.icons, - 'markers' : self.markers, + 'markers': self.markers, } params.update(self.extra_context) return render_to_string(self.template, params) @@ -211,10 +211,10 @@ class GoogleMapSet(GoogleMap): Generates the JavaScript for the collection of Google Maps in this set. """ - params = {'js_module' : self.js_module, - 'dom_ids' : self.dom_ids, - 'load_map_js' : self.load_map_js(), - 'icons' : self.icons, + params = {'js_module': self.js_module, + 'dom_ids': self.dom_ids, + 'load_map_js': self.load_map_js(), + 'icons': self.icons, } params.update(self.extra_context) return render_to_string(self.template, params) diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py index a63e4eef9d..82d75e0cef 100644 --- a/django/contrib/gis/measure.py +++ b/django/contrib/gis/measure.py @@ -221,77 +221,77 @@ class MeasureBase(object): class Distance(MeasureBase): STANDARD_UNIT = "m" UNITS = { - 'chain' : 20.1168, - 'chain_benoit' : 20.116782, - 'chain_sears' : 20.1167645, - 'british_chain_benoit' : 20.1167824944, - 'british_chain_sears' : 20.1167651216, - 'british_chain_sears_truncated' : 20.116756, - 'cm' : 0.01, - 'british_ft' : 0.304799471539, - 'british_yd' : 0.914398414616, - 'clarke_ft' : 0.3047972654, - 'clarke_link' : 0.201166195164, - 'fathom' : 1.8288, + 'chain': 20.1168, + 'chain_benoit': 20.116782, + 'chain_sears': 20.1167645, + 'british_chain_benoit': 20.1167824944, + 'british_chain_sears': 20.1167651216, + 'british_chain_sears_truncated': 20.116756, + 'cm': 0.01, + 'british_ft': 0.304799471539, + 'british_yd': 0.914398414616, + 'clarke_ft': 0.3047972654, + 'clarke_link': 0.201166195164, + 'fathom': 1.8288, 'ft': 0.3048, - 'german_m' : 1.0000135965, - 'gold_coast_ft' : 0.304799710181508, - 'indian_yd' : 0.914398530744, - 'inch' : 0.0254, + 'german_m': 1.0000135965, + 'gold_coast_ft': 0.304799710181508, + 'indian_yd': 0.914398530744, + 'inch': 0.0254, 'km': 1000.0, - 'link' : 0.201168, - 'link_benoit' : 0.20116782, - 'link_sears' : 0.20116765, + 'link': 0.201168, + 'link_benoit': 0.20116782, + 'link_sears': 0.20116765, 'm': 1.0, 'mi': 1609.344, - 'mm' : 0.001, + 'mm': 0.001, 'nm': 1852.0, - 'nm_uk' : 1853.184, - 'rod' : 5.0292, - 'sears_yd' : 0.91439841, - 'survey_ft' : 0.304800609601, - 'um' : 0.000001, + 'nm_uk': 1853.184, + 'rod': 5.0292, + 'sears_yd': 0.91439841, + 'survey_ft': 0.304800609601, + 'um': 0.000001, 'yd': 0.9144, } # Unit aliases for `UNIT` terms encountered in Spatial Reference WKT. ALIAS = { - 'centimeter' : 'cm', - 'foot' : 'ft', - 'inches' : 'inch', - 'kilometer' : 'km', - 'kilometre' : 'km', - 'meter' : 'm', - 'metre' : 'm', - 'micrometer' : 'um', - 'micrometre' : 'um', - 'millimeter' : 'mm', - 'millimetre' : 'mm', - 'mile' : 'mi', - 'yard' : 'yd', - 'British chain (Benoit 1895 B)' : 'british_chain_benoit', - 'British chain (Sears 1922)' : 'british_chain_sears', - 'British chain (Sears 1922 truncated)' : 'british_chain_sears_truncated', - 'British foot (Sears 1922)' : 'british_ft', - 'British foot' : 'british_ft', - 'British yard (Sears 1922)' : 'british_yd', - 'British yard' : 'british_yd', - "Clarke's Foot" : 'clarke_ft', - "Clarke's link" : 'clarke_link', - 'Chain (Benoit)' : 'chain_benoit', - 'Chain (Sears)' : 'chain_sears', - 'Foot (International)' : 'ft', - 'German legal metre' : 'german_m', - 'Gold Coast foot' : 'gold_coast_ft', - 'Indian yard' : 'indian_yd', + 'centimeter': 'cm', + 'foot': 'ft', + 'inches': 'inch', + 'kilometer': 'km', + 'kilometre': 'km', + 'meter': 'm', + 'metre': 'm', + 'micrometer': 'um', + 'micrometre': 'um', + 'millimeter': 'mm', + 'millimetre': 'mm', + 'mile': 'mi', + 'yard': 'yd', + 'British chain (Benoit 1895 B)': 'british_chain_benoit', + 'British chain (Sears 1922)': 'british_chain_sears', + 'British chain (Sears 1922 truncated)': 'british_chain_sears_truncated', + 'British foot (Sears 1922)': 'british_ft', + 'British foot': 'british_ft', + 'British yard (Sears 1922)': 'british_yd', + 'British yard': 'british_yd', + "Clarke's Foot": 'clarke_ft', + "Clarke's link": 'clarke_link', + 'Chain (Benoit)': 'chain_benoit', + 'Chain (Sears)': 'chain_sears', + 'Foot (International)': 'ft', + 'German legal metre': 'german_m', + 'Gold Coast foot': 'gold_coast_ft', + 'Indian yard': 'indian_yd', 'Link (Benoit)': 'link_benoit', 'Link (Sears)': 'link_sears', - 'Nautical Mile' : 'nm', - 'Nautical Mile (UK)' : 'nm_uk', - 'US survey foot' : 'survey_ft', - 'U.S. Foot' : 'survey_ft', - 'Yard (Indian)' : 'indian_yd', - 'Yard (Sears)' : 'sears_yd' + 'Nautical Mile': 'nm', + 'Nautical Mile (UK)': 'nm_uk', + 'US survey foot': 'survey_ft', + 'U.S. Foot': 'survey_ft', + 'Yard (Indian)': 'indian_yd', + 'Yard (Sears)': 'sears_yd' } LALIAS = dict((k.lower(), v) for k, v in ALIAS.items()) diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py index 1f3a567025..68e2ffd7d9 100644 --- a/django/contrib/gis/sitemaps/kml.py +++ b/django/contrib/gis/sitemaps/kml.py @@ -55,8 +55,8 @@ class KMLSitemap(Sitemap): def location(self, obj): return urlresolvers.reverse('django.contrib.gis.sitemaps.views.%s' % self.geo_format, - kwargs={'label' : obj[0], - 'model' : obj[1], + kwargs={'label': obj[0], + 'model': obj[1], 'field_name': obj[2], } ) diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index e184f4c6b6..dac63658e6 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -106,7 +106,7 @@ def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB render = render_to_kmz else: render = render_to_kml - return render('gis/kml/placemarks.kml', {'places' : placemarks}) + return render('gis/kml/placemarks.kml', {'places': placemarks}) def kmz(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS): """ diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py index f9a8eb5760..c294ca1790 100644 --- a/django/contrib/gis/tests/geo3d/tests.py +++ b/django/contrib/gis/tests/geo3d/tests.py @@ -46,10 +46,10 @@ city_dict = dict((name, coords) for name, coords in city_data) interstate_data = ( ('I-45', 'LINESTRING(-95.3708481 29.7765870 11.339,-95.3694580 29.7787980 4.536,-95.3690305 29.7797359 9.762,-95.3691886 29.7812450 12.448,-95.3696447 29.7850144 10.457,-95.3702511 29.7868518 9.418,-95.3706724 29.7881286 14.858,-95.3711632 29.7896157 15.386,-95.3714525 29.7936267 13.168,-95.3717848 29.7955007 15.104,-95.3717719 29.7969804 16.516,-95.3717305 29.7982117 13.923,-95.3717254 29.8000778 14.385,-95.3719875 29.8013539 15.160,-95.3720575 29.8026785 15.544,-95.3721321 29.8040912 14.975,-95.3722074 29.8050998 15.688,-95.3722779 29.8060430 16.099,-95.3733818 29.8076750 15.197,-95.3741563 29.8103686 17.268,-95.3749458 29.8129927 19.857,-95.3763564 29.8144557 15.435)', - (11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858, - 15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16 , - 15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857, - 15.435), + (11.339, 4.536, 9.762, 12.448, 10.457, 9.418, 14.858, + 15.386, 13.168, 15.104, 16.516, 13.923, 14.385, 15.16, + 15.544, 14.975, 15.688, 16.099, 15.197, 17.268, 19.857, + 15.435), ), ) @@ -131,8 +131,8 @@ class Geo3DTest(TestCase): """ Testing LayerMapping on 3D models. """ - point_mapping = {'point' : 'POINT'} - mpoint_mapping = {'mpoint' : 'MULTIPOINT'} + point_mapping = {'point': 'POINT'} + mpoint_mapping = {'mpoint': 'MULTIPOINT'} # The VRT is 3D, but should still be able to map sans the Z. lm = LayerMapping(Point2D, vrt_file, point_mapping, transform=False) diff --git a/django/contrib/gis/tests/geoapp/feeds.py b/django/contrib/gis/tests/geoapp/feeds.py index 9ec959ecce..a59593061f 100644 --- a/django/contrib/gis/tests/geoapp/feeds.py +++ b/django/contrib/gis/tests/geoapp/feeds.py @@ -56,11 +56,11 @@ class TestW3CGeo3(TestGeoRSS1): # The feed dictionary to use for URLs. feed_dict = { - 'rss1' : TestGeoRSS1, - 'rss2' : TestGeoRSS2, - 'atom1' : TestGeoAtom1, - 'atom2' : TestGeoAtom2, - 'w3cgeo1' : TestW3CGeo1, - 'w3cgeo2' : TestW3CGeo2, - 'w3cgeo3' : TestW3CGeo3, + 'rss1': TestGeoRSS1, + 'rss2': TestGeoRSS2, + 'atom1': TestGeoAtom1, + 'atom2': TestGeoAtom2, + 'w3cgeo1': TestW3CGeo1, + 'w3cgeo2': TestW3CGeo2, + 'w3cgeo3': TestW3CGeo3, } diff --git a/django/contrib/gis/tests/geoapp/sitemaps.py b/django/contrib/gis/tests/geoapp/sitemaps.py index 55bf7c764c..68490ace2f 100644 --- a/django/contrib/gis/tests/geoapp/sitemaps.py +++ b/django/contrib/gis/tests/geoapp/sitemaps.py @@ -4,7 +4,7 @@ from .feeds import feed_dict from .models import City, Country -sitemaps = {'kml' : KMLSitemap([City, Country]), - 'kmz' : KMZSitemap([City, Country]), - 'georss' : GeoRSSSitemap(feed_dict), +sitemaps = {'kml': KMLSitemap([City, Country]), + 'kmz': KMZSitemap([City, Country]), + 'georss': GeoRSSSitemap(feed_dict), } diff --git a/django/contrib/gis/tests/geoapp/test_regress.py b/django/contrib/gis/tests/geoapp/test_regress.py index 37c6a33732..3bd74b00d1 100644 --- a/django/contrib/gis/tests/geoapp/test_regress.py +++ b/django/contrib/gis/tests/geoapp/test_regress.py @@ -33,11 +33,11 @@ class GeoRegressionTests(TestCase): def test_kmz(self): "Testing `render_to_kmz` with non-ASCII data. See #11624." name = "Åland Islands" - places = [{'name' : name, - 'description' : name, - 'kml' : '5.0,23.0' + places = [{'name': name, + 'description': name, + 'kml': '5.0,23.0' }] - render_to_kmz('gis/kml/placemarks.kml', {'places' : places}) + render_to_kmz('gis/kml/placemarks.kml', {'places': places}) @no_spatialite @no_mysql diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index a3f673d5f0..4b20c4b2c8 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -534,7 +534,7 @@ class GeoQuerySetTest(TestCase): def test_gml(self): "Testing GML output from the database using GeoQuerySet.gml()." - if mysql or (spatialite and not connection.ops.gml) : + if mysql or (spatialite and not connection.ops.gml): self.assertRaises(NotImplementedError, Country.objects.all().gml, field_name='mpoly') return @@ -635,15 +635,15 @@ class GeoQuerySetTest(TestCase): # Reference values. if oracle: # SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_POINTONSURFACE(GEOAPP_COUNTRY.MPOLY, 0.05)) FROM GEOAPP_COUNTRY; - ref = {'New Zealand' : fromstr('POINT (174.616364 -36.100861)', srid=4326), - 'Texas' : fromstr('POINT (-103.002434 36.500397)', srid=4326), + ref = {'New Zealand': fromstr('POINT (174.616364 -36.100861)', srid=4326), + 'Texas': fromstr('POINT (-103.002434 36.500397)', srid=4326), } elif postgis or spatialite: # Using GEOSGeometry to compute the reference point on surface values # -- since PostGIS also uses GEOS these should be the same. - ref = {'New Zealand' : Country.objects.get(name='New Zealand').mpoly.point_on_surface, - 'Texas' : Country.objects.get(name='Texas').mpoly.point_on_surface + ref = {'New Zealand': Country.objects.get(name='New Zealand').mpoly.point_on_surface, + 'Texas': Country.objects.get(name='Texas').mpoly.point_on_surface } for c in Country.objects.point_on_surface(): diff --git a/django/contrib/gis/tests/geoapp/urls.py b/django/contrib/gis/tests/geoapp/urls.py index 70db62d71b..6aba9e525a 100644 --- a/django/contrib/gis/tests/geoapp/urls.py +++ b/django/contrib/gis/tests/geoapp/urls.py @@ -11,8 +11,8 @@ urlpatterns = patterns('', ) urlpatterns += patterns('django.contrib.gis.sitemaps.views', - (r'^sitemap.xml$', 'index', {'sitemaps' : sitemaps}), - (r'^sitemaps/(?P
\w+)\.xml$', 'sitemap', {'sitemaps' : sitemaps}), + (r'^sitemap.xml$', 'index', {'sitemaps': sitemaps}), + (r'^sitemaps/(?P
\w+)\.xml$', 'sitemap', {'sitemaps': sitemaps}), (r'^sitemaps/kml/(?P