From 19256f300e44b0a682f76fc1dda673862bae49d1 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 2 Nov 2013 10:18:46 -0700 Subject: [PATCH] Continue to attack E302 violations --- .../formtools/tests/wizard/namedwizardtests/forms.py | 6 ++++++ .../formtools/tests/wizard/namedwizardtests/urls.py | 2 ++ django/contrib/formtools/tests/wizard/test_forms.py | 2 ++ .../formtools/tests/wizard/wizardtests/forms.py | 7 +++++++ django/contrib/formtools/wizard/forms.py | 1 + .../contrib/formtools/wizard/storage/exceptions.py | 2 ++ django/contrib/formtools/wizard/views.py | 1 + django/contrib/gis/admin/options.py | 1 + django/contrib/gis/db/backends/base.py | 1 + django/contrib/gis/db/backends/mysql/compiler.py | 6 ++++++ django/contrib/gis/db/backends/mysql/creation.py | 2 +- .../contrib/gis/db/backends/mysql/introspection.py | 1 + django/contrib/gis/db/backends/oracle/adapter.py | 1 + django/contrib/gis/db/backends/oracle/compiler.py | 7 +++++++ django/contrib/gis/db/backends/oracle/creation.py | 1 + .../contrib/gis/db/backends/oracle/introspection.py | 1 + django/contrib/gis/db/backends/oracle/models.py | 2 ++ django/contrib/gis/db/backends/oracle/operations.py | 5 +++++ django/contrib/gis/db/backends/postgis/adapter.py | 1 + .../contrib/gis/db/backends/postgis/introspection.py | 2 ++ django/contrib/gis/db/backends/postgis/models.py | 2 ++ django/contrib/gis/db/backends/postgis/operations.py | 6 ++++++ django/contrib/gis/db/backends/spatialite/adapter.py | 1 + django/contrib/gis/db/backends/spatialite/base.py | 1 + django/contrib/gis/db/backends/spatialite/client.py | 1 + .../gis/db/backends/spatialite/introspection.py | 2 ++ django/contrib/gis/db/backends/spatialite/models.py | 2 ++ .../contrib/gis/db/backends/spatialite/operations.py | 6 ++++++ django/contrib/gis/db/backends/utils.py | 2 ++ django/contrib/gis/db/models/aggregates.py | 5 +++++ django/contrib/gis/db/models/fields.py | 9 +++++++++ django/contrib/gis/db/models/manager.py | 1 + django/contrib/gis/db/models/proxy.py | 1 + django/contrib/gis/db/models/query.py | 2 ++ django/contrib/gis/db/models/sql/aggregates.py | 6 ++++++ django/contrib/gis/db/models/sql/compiler.py | 7 +++++++ django/contrib/gis/db/models/sql/conversion.py | 4 ++++ django/contrib/gis/db/models/sql/query.py | 1 + django/contrib/gis/db/models/sql/where.py | 2 ++ django/contrib/gis/feeds.py | 5 +++++ django/contrib/gis/gdal/base.py | 1 + django/contrib/gis/gdal/datasource.py | 1 + django/contrib/gis/gdal/driver.py | 1 + django/contrib/gis/gdal/envelope.py | 2 ++ django/contrib/gis/gdal/error.py | 5 +++++ django/contrib/gis/gdal/feature.py | 1 + django/contrib/gis/gdal/field.py | 12 ++++++++++++ django/contrib/gis/gdal/geometries.py | 2 +- django/contrib/gis/gdal/layer.py | 1 + django/contrib/gis/gdal/srs.py | 1 + django/contrib/gis/geoip/base.py | 2 ++ django/contrib/gis/geos/base.py | 1 + django/contrib/gis/geos/io.py | 2 ++ django/contrib/gis/geos/mutable_list.py | 1 + django/contrib/gis/geos/polygon.py | 1 + django/contrib/gis/geos/prepared.py | 1 + django/contrib/gis/measure.py | 2 ++ django/contrib/gis/shortcuts.py | 4 ++++ django/contrib/gis/sitemaps/georss.py | 1 + django/contrib/gis/sitemaps/kml.py | 3 +++ django/contrib/gis/sitemaps/views.py | 1 + django/contrib/gis/tests/test_measure.py | 1 + django/contrib/gis/tests/utils.py | 4 ++++ django/contrib/gis/views.py | 1 + django/contrib/sites/management.py | 1 + django/contrib/staticfiles/handlers.py | 1 + django/contrib/staticfiles/urls.py | 1 + 67 files changed, 171 insertions(+), 2 deletions(-) diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py b/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py index c89f51e179c..fa9071d9dbe 100644 --- a/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py +++ b/django/contrib/formtools/tests/wizard/namedwizardtests/forms.py @@ -14,21 +14,25 @@ from django.contrib.formtools.wizard.views import NamedUrlWizardView temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR')) temp_storage = FileSystemStorage(location=temp_storage_location) + class Page1(forms.Form): name = forms.CharField(max_length=100) user = forms.ModelChoiceField(queryset=User.objects.all()) thirsty = forms.NullBooleanField() + class Page2(forms.Form): address1 = forms.CharField(max_length=100) address2 = forms.CharField(max_length=100) file1 = forms.FileField() + class Page3(forms.Form): random_crap = forms.CharField(max_length=100) Page4 = formset_factory(Page3, extra=2) + class ContactWizard(NamedUrlWizardView): file_storage = temp_storage @@ -44,8 +48,10 @@ class ContactWizard(NamedUrlWizardView): c['this_will_fail'] = self.get_cleaned_data_for_step('this_will_fail') return HttpResponse(Template('').render(c)) + class SessionContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage' + class CookieContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py b/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py index ac2cadc321a..a88e7117208 100644 --- a/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py +++ b/django/contrib/formtools/tests/wizard/namedwizardtests/urls.py @@ -2,6 +2,7 @@ from django.conf.urls import patterns, url from django.contrib.formtools.tests.wizard.namedwizardtests.forms import ( SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4) + def get_named_session_wizard(): return SessionContactWizard.as_view( [('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)], @@ -9,6 +10,7 @@ def get_named_session_wizard(): done_step_name='nwiz_session_done' ) + def get_named_cookie_wizard(): return CookieContactWizard.as_view( [('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)], diff --git a/django/contrib/formtools/tests/wizard/test_forms.py b/django/contrib/formtools/tests/wizard/test_forms.py index ba3fbfdd489..386e4484858 100644 --- a/django/contrib/formtools/tests/wizard/test_forms.py +++ b/django/contrib/formtools/tests/wizard/test_forms.py @@ -81,12 +81,14 @@ class TestWizard(WizardView): kwargs['test'] = True return kwargs + class TestWizardWithInitAttrs(TestWizard): form_list = [Step1, Step2] condition_dict = {'step2': True} initial_dict = {'start': {'name': 'value1'}} instance_dict = {'start': User()} + class FormTests(TestCase): def test_form_init(self): testform = TestWizard.get_initkwargs([Step1, Step2]) diff --git a/django/contrib/formtools/tests/wizard/wizardtests/forms.py b/django/contrib/formtools/tests/wizard/wizardtests/forms.py index ad565478d1e..5e4617c1cd7 100644 --- a/django/contrib/formtools/tests/wizard/wizardtests/forms.py +++ b/django/contrib/formtools/tests/wizard/wizardtests/forms.py @@ -15,21 +15,25 @@ from django.contrib.formtools.wizard.views import WizardView temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR')) temp_storage = FileSystemStorage(location=temp_storage_location) + class Page1(forms.Form): name = forms.CharField(max_length=100) user = forms.ModelChoiceField(queryset=User.objects.all()) thirsty = forms.NullBooleanField() + class Page2(forms.Form): address1 = forms.CharField(max_length=100) address2 = forms.CharField(max_length=100) file1 = forms.FileField() + class Page3(forms.Form): random_crap = forms.CharField(max_length=100) Page4 = formset_factory(Page3, extra=2) + class ContactWizard(WizardView): file_storage = temp_storage @@ -51,6 +55,7 @@ class ContactWizard(WizardView): context.update({'another_var': True}) return context + class UserForm(forms.ModelForm): class Meta: model = User @@ -58,8 +63,10 @@ class UserForm(forms.ModelForm): UserFormSet = modelformset_factory(User, form=UserForm) + class SessionContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage' + class CookieContactWizard(ContactWizard): storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' diff --git a/django/contrib/formtools/wizard/forms.py b/django/contrib/formtools/wizard/forms.py index bf46c5c992f..cd00517fa3c 100644 --- a/django/contrib/formtools/wizard/forms.py +++ b/django/contrib/formtools/wizard/forms.py @@ -1,5 +1,6 @@ from django import forms + class ManagementForm(forms.Form): """ ``ManagementForm`` is used to keep track of the current wizard step. diff --git a/django/contrib/formtools/wizard/storage/exceptions.py b/django/contrib/formtools/wizard/storage/exceptions.py index e273a8654b4..31cea93ba87 100644 --- a/django/contrib/formtools/wizard/storage/exceptions.py +++ b/django/contrib/formtools/wizard/storage/exceptions.py @@ -1,7 +1,9 @@ from django.core.exceptions import ImproperlyConfigured + class MissingStorage(ImproperlyConfigured): pass + class NoFileStorageConfigured(ImproperlyConfigured): pass diff --git a/django/contrib/formtools/wizard/views.py b/django/contrib/formtools/wizard/views.py index f1c54f5df4d..f19cfc76f3a 100644 --- a/django/contrib/formtools/wizard/views.py +++ b/django/contrib/formtools/wizard/views.py @@ -28,6 +28,7 @@ def normalize_name(name): new = re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', name) return new.lower().strip('_') + class StepsHelper(object): def __init__(self, wizard): diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py index 6ec6a23ffde..53a043c8f1e 100644 --- a/django/contrib/gis/admin/options.py +++ b/django/contrib/gis/admin/options.py @@ -3,6 +3,7 @@ from django.contrib.gis.admin.widgets import OpenLayersWidget from django.contrib.gis.gdal import OGRGeomType from django.contrib.gis.db import models + class GeoModelAdmin(ModelAdmin): """ The administration options class for Geographic models. Map settings diff --git a/django/contrib/gis/db/backends/base.py b/django/contrib/gis/db/backends/base.py index 3162ed3d001..4da0af0d270 100644 --- a/django/contrib/gis/db/backends/base.py +++ b/django/contrib/gis/db/backends/base.py @@ -143,6 +143,7 @@ class BaseSpatialOperations(object): def spatial_ref_sys(self): raise NotImplementedError('subclasses of BaseSpatialOperations must a provide spatial_ref_sys() method') + @python_2_unicode_compatible class SpatialRefSysMixin(object): """ diff --git a/django/contrib/gis/db/backends/mysql/compiler.py b/django/contrib/gis/db/backends/mysql/compiler.py index f4654eff840..74e666c165d 100644 --- a/django/contrib/gis/db/backends/mysql/compiler.py +++ b/django/contrib/gis/db/backends/mysql/compiler.py @@ -3,6 +3,7 @@ from django.db.backends.mysql import compiler SQLCompiler = compiler.SQLCompiler + class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler): def resolve_columns(self, row, fields=()): """ @@ -19,17 +20,22 @@ class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler): class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler): pass + class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler): pass + class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler): pass + class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler): pass + class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler): pass + class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler): pass diff --git a/django/contrib/gis/db/backends/mysql/creation.py b/django/contrib/gis/db/backends/mysql/creation.py index dda77ea6abd..303b8aef539 100644 --- a/django/contrib/gis/db/backends/mysql/creation.py +++ b/django/contrib/gis/db/backends/mysql/creation.py @@ -1,7 +1,7 @@ from django.db.backends.mysql.creation import DatabaseCreation -class MySQLCreation(DatabaseCreation): +class MySQLCreation(DatabaseCreation): def sql_indexes_for_field(self, model, f, style): from django.contrib.gis.db.models.fields import GeometryField output = super(MySQLCreation, self).sql_indexes_for_field(model, f, style) diff --git a/django/contrib/gis/db/backends/mysql/introspection.py b/django/contrib/gis/db/backends/mysql/introspection.py index 59d0f627ee3..aae1c1460c6 100644 --- a/django/contrib/gis/db/backends/mysql/introspection.py +++ b/django/contrib/gis/db/backends/mysql/introspection.py @@ -3,6 +3,7 @@ from MySQLdb.constants import FIELD_TYPE from django.contrib.gis.gdal import OGRGeomType from django.db.backends.mysql.introspection import DatabaseIntrospection + class MySQLIntrospection(DatabaseIntrospection): # Updating the data_types_reverse dictionary with the appropriate # type for Geometry fields. diff --git a/django/contrib/gis/db/backends/oracle/adapter.py b/django/contrib/gis/db/backends/oracle/adapter.py index ea340d93d95..ca627bd37dc 100644 --- a/django/contrib/gis/db/backends/oracle/adapter.py +++ b/django/contrib/gis/db/backends/oracle/adapter.py @@ -1,5 +1,6 @@ from cx_Oracle import CLOB from django.contrib.gis.db.backends.adapter import WKTAdapter + class OracleSpatialAdapter(WKTAdapter): input_size = CLOB diff --git a/django/contrib/gis/db/backends/oracle/compiler.py b/django/contrib/gis/db/backends/oracle/compiler.py index d00af7fa718..4fe65bce28d 100644 --- a/django/contrib/gis/db/backends/oracle/compiler.py +++ b/django/contrib/gis/db/backends/oracle/compiler.py @@ -3,23 +3,30 @@ from django.db.backends.oracle import compiler SQLCompiler = compiler.SQLCompiler + class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler): pass + class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler): pass + class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler): pass + class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler): pass + class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler): pass + class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler): pass + class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler): pass diff --git a/django/contrib/gis/db/backends/oracle/creation.py b/django/contrib/gis/db/backends/oracle/creation.py index 14f8d4d150f..4aa031220bc 100644 --- a/django/contrib/gis/db/backends/oracle/creation.py +++ b/django/contrib/gis/db/backends/oracle/creation.py @@ -1,6 +1,7 @@ from django.db.backends.oracle.creation import DatabaseCreation from django.db.backends.utils import truncate_name + class OracleCreation(DatabaseCreation): def sql_indexes_for_field(self, model, f, style): diff --git a/django/contrib/gis/db/backends/oracle/introspection.py b/django/contrib/gis/db/backends/oracle/introspection.py index d6c8f452df6..fbac2287e8e 100644 --- a/django/contrib/gis/db/backends/oracle/introspection.py +++ b/django/contrib/gis/db/backends/oracle/introspection.py @@ -3,6 +3,7 @@ import sys from django.db.backends.oracle.introspection import DatabaseIntrospection from django.utils import six + class OracleIntrospection(DatabaseIntrospection): # Associating any OBJECTVAR instances with GeometryField. Of course, # this won't work right on Oracle objects that aren't MDSYS.SDO_GEOMETRY, diff --git a/django/contrib/gis/db/backends/oracle/models.py b/django/contrib/gis/db/backends/oracle/models.py index dda698481e7..c907b8280df 100644 --- a/django/contrib/gis/db/backends/oracle/models.py +++ b/django/contrib/gis/db/backends/oracle/models.py @@ -11,6 +11,7 @@ from django.contrib.gis.db import models from django.contrib.gis.db.backends.base import SpatialRefSysMixin from django.utils.encoding import python_2_unicode_compatible + @python_2_unicode_compatible class GeometryColumns(models.Model): "Maps to the Oracle USER_SDO_GEOM_METADATA table." @@ -42,6 +43,7 @@ class GeometryColumns(models.Model): def __str__(self): return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid) + class SpatialRefSys(models.Model, SpatialRefSysMixin): "Maps to the Oracle MDSYS.CS_SRS table." cs_name = models.CharField(max_length=68) diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 5fced474c8e..14df0ff1d36 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -28,6 +28,7 @@ class SDOOperation(SpatialFunction): kwargs.setdefault('result', 'TRUE') super(SDOOperation, self).__init__(func, **kwargs) + class SDODistance(SpatialFunction): "Class for Distance queries." sql_template = ('%(function)s(%(geo_col)s, %(geometry)s, %(tolerance)s) ' @@ -39,6 +40,7 @@ class SDODistance(SpatialFunction): tolerance=tolerance, operator=op, result='%s') + class SDODWithin(SpatialFunction): dwithin_func = 'SDO_WITHIN_DISTANCE' sql_template = "%(function)s(%(geo_col)s, %(geometry)s, %%s) = 'TRUE'" @@ -46,6 +48,7 @@ class SDODWithin(SpatialFunction): def __init__(self): super(SDODWithin, self).__init__(self.dwithin_func) + class SDOGeomRelate(SpatialFunction): "Class for using SDO_GEOM.RELATE." relate_func = 'SDO_GEOM.RELATE' @@ -58,6 +61,7 @@ class SDOGeomRelate(SpatialFunction): super(SDOGeomRelate, self).__init__(self.relate_func, operator='=', mask=mask, tolerance=tolerance) + class SDORelate(SpatialFunction): "Class for using SDO_RELATE." masks = 'TOUCH|OVERLAPBDYDISJOINT|OVERLAPBDYINTERSECT|EQUAL|INSIDE|COVEREDBY|CONTAINS|COVERS|ANYINTERACT|ON' @@ -73,6 +77,7 @@ class SDORelate(SpatialFunction): # Valid distance types and substitutions dtypes = (Decimal, Distance, float) + six.integer_types + class OracleOperations(DatabaseOperations, BaseSpatialOperations): compiler_module = "django.contrib.gis.db.backends.oracle.compiler" diff --git a/django/contrib/gis/db/backends/postgis/adapter.py b/django/contrib/gis/db/backends/postgis/adapter.py index 8bb514d760b..172133693be 100644 --- a/django/contrib/gis/db/backends/postgis/adapter.py +++ b/django/contrib/gis/db/backends/postgis/adapter.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals from psycopg2 import Binary from psycopg2.extensions import ISQLQuote + class PostGISAdapter(object): def __init__(self, geom): "Initializes on the geometry." diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py index d9e1dd350ec..8edc13387d5 100644 --- a/django/contrib/gis/db/backends/postgis/introspection.py +++ b/django/contrib/gis/db/backends/postgis/introspection.py @@ -1,9 +1,11 @@ from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection from django.contrib.gis.gdal import OGRGeomType + class GeoIntrospectionError(Exception): pass + class PostGISIntrospection(DatabaseIntrospection): # Reverse dictionary for PostGIS geometry types not populated until # introspection is actually performed. diff --git a/django/contrib/gis/db/backends/postgis/models.py b/django/contrib/gis/db/backends/postgis/models.py index e8052594c65..058d440b50d 100644 --- a/django/contrib/gis/db/backends/postgis/models.py +++ b/django/contrib/gis/db/backends/postgis/models.py @@ -5,6 +5,7 @@ from django.db import models from django.contrib.gis.db.backends.base import SpatialRefSysMixin from django.utils.encoding import python_2_unicode_compatible + @python_2_unicode_compatible class GeometryColumns(models.Model): """ @@ -44,6 +45,7 @@ class GeometryColumns(models.Model): (self.f_table_name, self.f_geometry_column, self.coord_dimension, self.type, self.srid) + class SpatialRefSys(models.Model, SpatialRefSysMixin): """ The 'spatial_ref_sys' table from PostGIS. See the PostGIS diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 92e5323d36f..eae08479dff 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -22,15 +22,18 @@ class PostGISOperator(SpatialOperation): def __init__(self, operator): super(PostGISOperator, self).__init__(operator=operator) + class PostGISFunction(SpatialFunction): "For PostGIS function calls (e.g., `ST_Contains(table, geom)`)." def __init__(self, prefix, function, **kwargs): super(PostGISFunction, self).__init__(prefix + function, **kwargs) + class PostGISFunctionParam(PostGISFunction): "For PostGIS functions that take another parameter (e.g. DWithin, Relate)." sql_template = '%(function)s(%(geo_col)s, %(geometry)s, %%s)' + class PostGISDistance(PostGISFunction): "For PostGIS distance operations." dist_func = 'Distance' @@ -40,6 +43,7 @@ class PostGISDistance(PostGISFunction): super(PostGISDistance, self).__init__(prefix, self.dist_func, operator=operator) + class PostGISSpheroidDistance(PostGISFunction): "For PostGIS spherical distance operations (using the spheroid)." dist_func = 'distance_spheroid' @@ -50,10 +54,12 @@ class PostGISSpheroidDistance(PostGISFunction): super(PostGISSpheroidDistance, self).__init__(prefix, self.dist_func, operator=operator) + class PostGISSphereDistance(PostGISDistance): "For PostGIS spherical distance operations." dist_func = 'distance_sphere' + class PostGISRelate(PostGISFunctionParam): "For PostGIS Relate(, ) calls." pattern_regex = re.compile(r'^[012TF\*]{9}$') diff --git a/django/contrib/gis/db/backends/spatialite/adapter.py b/django/contrib/gis/db/backends/spatialite/adapter.py index d8fefbadd86..8a5c2d88bf9 100644 --- a/django/contrib/gis/db/backends/spatialite/adapter.py +++ b/django/contrib/gis/db/backends/spatialite/adapter.py @@ -1,6 +1,7 @@ from django.db.backends.sqlite3.base import Database from django.contrib.gis.db.backends.adapter import WKTAdapter + class SpatiaLiteAdapter(WKTAdapter): "SQLite adaptor for geometry objects." def __conform__(self, protocol): diff --git a/django/contrib/gis/db/backends/spatialite/base.py b/django/contrib/gis/db/backends/spatialite/base.py index 7b49d71a619..2efc2741064 100644 --- a/django/contrib/gis/db/backends/spatialite/base.py +++ b/django/contrib/gis/db/backends/spatialite/base.py @@ -11,6 +11,7 @@ from django.contrib.gis.db.backends.spatialite.introspection import SpatiaLiteIn from django.contrib.gis.db.backends.spatialite.operations import SpatiaLiteOperations from django.utils import six + class DatabaseWrapper(SQLiteDatabaseWrapper): def __init__(self, *args, **kwargs): # Before we get too far, make sure pysqlite 2.5+ is installed. diff --git a/django/contrib/gis/db/backends/spatialite/client.py b/django/contrib/gis/db/backends/spatialite/client.py index f9684877c5d..c9dfd1a5275 100644 --- a/django/contrib/gis/db/backends/spatialite/client.py +++ b/django/contrib/gis/db/backends/spatialite/client.py @@ -1,4 +1,5 @@ from django.db.backends.sqlite3.client import DatabaseClient + class SpatiaLiteClient(DatabaseClient): executable_name = 'spatialite' diff --git a/django/contrib/gis/db/backends/spatialite/introspection.py b/django/contrib/gis/db/backends/spatialite/introspection.py index c841d1ae6a9..9e1616c514a 100644 --- a/django/contrib/gis/db/backends/spatialite/introspection.py +++ b/django/contrib/gis/db/backends/spatialite/introspection.py @@ -2,6 +2,7 @@ from django.contrib.gis.gdal import OGRGeomType from django.db.backends.sqlite3.introspection import DatabaseIntrospection, FlexibleFieldLookupDict from django.utils import six + class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict): """ Sublcass that includes updates the `base_data_types_reverse` dict @@ -18,6 +19,7 @@ class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict): 'geometrycollection': 'GeometryField', }) + class SpatiaLiteIntrospection(DatabaseIntrospection): data_types_reverse = GeoFlexibleFieldLookupDict() diff --git a/django/contrib/gis/db/backends/spatialite/models.py b/django/contrib/gis/db/backends/spatialite/models.py index b281f0bc62b..9860779647f 100644 --- a/django/contrib/gis/db/backends/spatialite/models.py +++ b/django/contrib/gis/db/backends/spatialite/models.py @@ -5,6 +5,7 @@ from django.db import models from django.contrib.gis.db.backends.base import SpatialRefSysMixin from django.utils.encoding import python_2_unicode_compatible + @python_2_unicode_compatible class GeometryColumns(models.Model): """ @@ -42,6 +43,7 @@ class GeometryColumns(models.Model): (self.f_table_name, self.f_geometry_column, self.coord_dimension, self.type, self.srid) + class SpatialRefSys(models.Model, SpatialRefSysMixin): """ The 'spatial_ref_sys' table from SpatiaLite. diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 4954ba5210d..8d8435f8242 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -19,15 +19,18 @@ class SpatiaLiteOperator(SpatialOperation): def __init__(self, operator): super(SpatiaLiteOperator, self).__init__(operator=operator) + class SpatiaLiteFunction(SpatialFunction): "For SpatiaLite function calls." def __init__(self, function, **kwargs): super(SpatiaLiteFunction, self).__init__(function, **kwargs) + class SpatiaLiteFunctionParam(SpatiaLiteFunction): "For SpatiaLite functions that take another parameter." sql_template = '%(function)s(%(geo_col)s, %(geometry)s, %%s)' + class SpatiaLiteDistance(SpatiaLiteFunction): "For SpatiaLite distance operations." dist_func = 'Distance' @@ -37,6 +40,7 @@ class SpatiaLiteDistance(SpatiaLiteFunction): super(SpatiaLiteDistance, self).__init__(self.dist_func, operator=operator) + class SpatiaLiteRelate(SpatiaLiteFunctionParam): "For SpatiaLite Relate(, ) calls." pattern_regex = re.compile(r'^[012TF\*]{9}$') @@ -46,12 +50,14 @@ class SpatiaLiteRelate(SpatiaLiteFunctionParam): raise ValueError('Invalid intersection matrix pattern "%s".' % pattern) super(SpatiaLiteRelate, self).__init__('Relate') + # Valid distance types and substitutions dtypes = (Decimal, Distance, float) + six.integer_types def get_dist_ops(operator): "Returns operations for regular distances; spherical distances are not currently supported." return (SpatiaLiteDistance(operator),) + class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations): compiler_module = 'django.contrib.gis.db.models.sql.compiler' name = 'spatialite' diff --git a/django/contrib/gis/db/backends/utils.py b/django/contrib/gis/db/backends/utils.py index 53f1e1b6a40..b8b5b9525f1 100644 --- a/django/contrib/gis/db/backends/utils.py +++ b/django/contrib/gis/db/backends/utils.py @@ -3,6 +3,7 @@ A collection of utility routines and classes used by the spatial backends. """ + class SpatialOperation(object): """ Base class for generating spatial SQL. @@ -28,6 +29,7 @@ class SpatialOperation(object): params.update(self.extra) return params + class SpatialFunction(SpatialOperation): """ Base class for generating spatial SQL related to a function. diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index d0fc6d319d3..fbfabe0a1de 100644 --- a/django/contrib/gis/db/models/aggregates.py +++ b/django/contrib/gis/db/models/aggregates.py @@ -1,16 +1,21 @@ from django.db.models import Aggregate + class Collect(Aggregate): name = 'Collect' + class Extent(Aggregate): name = 'Extent' + class Extent3D(Aggregate): name = 'Extent3D' + class MakeLine(Aggregate): name = 'MakeLine' + class Union(Aggregate): name = 'Union' diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index e137ddffb53..662b20ae79a 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -11,6 +11,7 @@ from django.utils import six # for SRID info each time a distance query is constructed. _srid_cache = {} + def get_srid_info(srid, connection): """ Returns the units, unit name, and spheroid WKT associated with the @@ -39,6 +40,7 @@ def get_srid_info(srid, connection): return _srid_cache[connection.alias][srid] + class GeometryField(Field): "The base GIS field -- maps to the OpenGIS Specification Geometry type." @@ -269,37 +271,44 @@ class GeometryField(Field): """ return connection.ops.get_geom_placeholder(self, value) + # The OpenGIS Geometry Type Fields class PointField(GeometryField): geom_type = 'POINT' form_class = forms.PointField description = _("Point") + class LineStringField(GeometryField): geom_type = 'LINESTRING' form_class = forms.LineStringField description = _("Line string") + class PolygonField(GeometryField): geom_type = 'POLYGON' form_class = forms.PolygonField description = _("Polygon") + class MultiPointField(GeometryField): geom_type = 'MULTIPOINT' form_class = forms.MultiPointField description = _("Multi-point") + class MultiLineStringField(GeometryField): geom_type = 'MULTILINESTRING' form_class = forms.MultiLineStringField description = _("Multi-line string") + class MultiPolygonField(GeometryField): geom_type = 'MULTIPOLYGON' form_class = forms.MultiPolygonField description = _("Multi polygon") + class GeometryCollectionField(GeometryField): geom_type = 'GEOMETRYCOLLECTION' form_class = forms.GeometryCollectionField diff --git a/django/contrib/gis/db/models/manager.py b/django/contrib/gis/db/models/manager.py index aa57e3a5077..bbcbb579fa3 100644 --- a/django/contrib/gis/db/models/manager.py +++ b/django/contrib/gis/db/models/manager.py @@ -1,6 +1,7 @@ from django.db.models.manager import Manager from django.contrib.gis.db.models.query import GeoQuerySet + class GeoManager(Manager): "Overrides Manager to return Geographic QuerySets." diff --git a/django/contrib/gis/db/models/proxy.py b/django/contrib/gis/db/models/proxy.py index 513bf921bd8..91ded31dc01 100644 --- a/django/contrib/gis/db/models/proxy.py +++ b/django/contrib/gis/db/models/proxy.py @@ -8,6 +8,7 @@ Thanks to Robert Coup for providing this functionality (see #4322). from django.contrib.gis import memoryview from django.utils import six + class GeometryProxy(object): def __init__(self, klass, field): """ diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py index 2d13cbecc06..5f1d4623ab6 100644 --- a/django/contrib/gis/db/models/query.py +++ b/django/contrib/gis/db/models/query.py @@ -782,6 +782,7 @@ class GeoQuerySet(QuerySet): else: return self.query.get_compiler(self.db)._field_column(geo_field) + class GeoValuesQuerySet(ValuesQuerySet): def __init__(self, *args, **kwargs): super(GeoValuesQuerySet, self).__init__(*args, **kwargs) @@ -790,5 +791,6 @@ class GeoValuesQuerySet(ValuesQuerySet): # of string values are returned with `values()` or `values_list()`. self.query.geo_values = True + class GeoValuesListQuerySet(GeoValuesQuerySet, ValuesListQuerySet): pass diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py index a3a8f1258dd..07c3ddd2e59 100644 --- a/django/contrib/gis/db/models/sql/aggregates.py +++ b/django/contrib/gis/db/models/sql/aggregates.py @@ -1,6 +1,7 @@ from django.db.models.sql.aggregates import * from django.contrib.gis.db.models.fields import GeometryField + class GeoAggregate(Aggregate): # Default SQL template for spatial aggregates. sql_template = '%(function)s(%(field)s)' @@ -46,17 +47,22 @@ class GeoAggregate(Aggregate): return sql_template % substitutions, params + class Collect(GeoAggregate): pass + class Extent(GeoAggregate): is_extent = '2D' + class Extent3D(GeoAggregate): is_extent = '3D' + class MakeLine(GeoAggregate): pass + class Union(GeoAggregate): pass diff --git a/django/contrib/gis/db/models/sql/compiler.py b/django/contrib/gis/db/models/sql/compiler.py index 4cf52207f3f..21fb57a4170 100644 --- a/django/contrib/gis/db/models/sql/compiler.py +++ b/django/contrib/gis/db/models/sql/compiler.py @@ -10,6 +10,7 @@ from django.utils import timezone SQLCompiler = compiler.SQLCompiler + class GeoSQLCompiler(compiler.SQLCompiler): def get_columns(self, with_aliases=False): @@ -249,18 +250,23 @@ class GeoSQLCompiler(compiler.SQLCompiler): return "%s.%s" % (self.quote_name_unless_alias(table_alias), self.connection.ops.quote_name(column or field.column)) + class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler): pass + class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler): pass + class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler): pass + class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler): pass + class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler): """ This is overridden for GeoDjango to properly cast date columns, since @@ -286,6 +292,7 @@ class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler): date = date.date() yield date + class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler): """ This is overridden for GeoDjango to properly cast date columns, since diff --git a/django/contrib/gis/db/models/sql/conversion.py b/django/contrib/gis/db/models/sql/conversion.py index 7f1b914baa4..ee4f0e9e33f 100644 --- a/django/contrib/gis/db/models/sql/conversion.py +++ b/django/contrib/gis/db/models/sql/conversion.py @@ -3,6 +3,7 @@ This module holds simple classes used by GeoQuery.convert_values to convert geospatial values from the database. """ + class BaseField(object): empty_strings_allowed = True @@ -10,16 +11,19 @@ class BaseField(object): "Overloaded method so OracleQuery.convert_values doesn't balk." return None + class AreaField(BaseField): "Wrapper for Area values." def __init__(self, area_att): self.area_att = area_att + class DistanceField(BaseField): "Wrapper for Distance values." def __init__(self, distance_att): self.distance_att = distance_att + class GeomField(BaseField): """ Wrapper for Geometry values. It is a lightweight alternative to diff --git a/django/contrib/gis/db/models/sql/query.py b/django/contrib/gis/db/models/sql/query.py index b7891745254..3923bf460e8 100644 --- a/django/contrib/gis/db/models/sql/query.py +++ b/django/contrib/gis/db/models/sql/query.py @@ -21,6 +21,7 @@ ALL_TERMS = set([ ]) ALL_TERMS.update(sql.constants.QUERY_TERMS) + class GeoQuery(sql.Query): """ A single spatial SQL query. diff --git a/django/contrib/gis/db/models/sql/where.py b/django/contrib/gis/db/models/sql/where.py index 7a9e098b912..3a504274b6b 100644 --- a/django/contrib/gis/db/models/sql/where.py +++ b/django/contrib/gis/db/models/sql/where.py @@ -4,6 +4,7 @@ from django.db.models.sql.expressions import SQLEvaluator from django.db.models.sql.where import Constraint, WhereNode from django.contrib.gis.db.models.fields import GeometryField + class GeoConstraint(Constraint): """ This subclass overrides `process` to better handle geographic SQL @@ -27,6 +28,7 @@ class GeoConstraint(Constraint): params = self.field.get_db_prep_lookup(lookup_type, value, connection=connection) return (self.alias, self.col, db_type), params + class GeoWhereNode(WhereNode): """ Used to represent the SQL where-clause for spatial databases -- diff --git a/django/contrib/gis/feeds.py b/django/contrib/gis/feeds.py index 1482064fe25..7e7b872df6c 100644 --- a/django/contrib/gis/feeds.py +++ b/django/contrib/gis/feeds.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from django.contrib.syndication.views import Feed as BaseFeed from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed + class GeoFeedMixin(object): """ This mixin provides the necessary routines for SyndicationFeed subclasses @@ -79,6 +80,7 @@ class GeoFeedMixin(object): else: raise ValueError('Geometry type "%s" not supported.' % geom.geom_type) + ### SyndicationFeed subclasses ### class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin): def rss_attributes(self): @@ -94,6 +96,7 @@ class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin): super(GeoRSSFeed, self).add_root_elements(handler) self.add_georss_element(handler, self.feed) + class GeoAtom1Feed(Atom1Feed, GeoFeedMixin): def root_attributes(self): attrs = super(GeoAtom1Feed, self).root_attributes() @@ -108,6 +111,7 @@ class GeoAtom1Feed(Atom1Feed, GeoFeedMixin): super(GeoAtom1Feed, self).add_root_elements(handler) self.add_georss_element(handler, self.feed) + class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin): def rss_attributes(self): attrs = super(W3CGeoFeed, self).rss_attributes() @@ -122,6 +126,7 @@ class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin): super(W3CGeoFeed, self).add_root_elements(handler) self.add_georss_element(handler, self.feed, w3c_geo=True) + ### Feed subclass ### class Feed(BaseFeed): """ diff --git a/django/contrib/gis/gdal/base.py b/django/contrib/gis/gdal/base.py index ac9b8c0a2a9..74058104969 100644 --- a/django/contrib/gis/gdal/base.py +++ b/django/contrib/gis/gdal/base.py @@ -3,6 +3,7 @@ from ctypes import c_void_p from django.contrib.gis.gdal.error import GDALException from django.utils import six + class GDALBase(object): """ Base object for GDAL objects that has a pointer access property diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py index 0d7f78a7357..864f50af527 100644 --- a/django/contrib/gis/gdal/datasource.py +++ b/django/contrib/gis/gdal/datasource.py @@ -49,6 +49,7 @@ from django.utils.encoding import force_bytes, force_text from django.utils import six from django.utils.six.moves import xrange + # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py index 015785b8d18..58f736b1a30 100644 --- a/django/contrib/gis/gdal/driver.py +++ b/django/contrib/gis/gdal/driver.py @@ -7,6 +7,7 @@ from django.contrib.gis.gdal.prototypes import ds as capi from django.utils import six from django.utils.encoding import force_bytes + # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # diff --git a/django/contrib/gis/gdal/envelope.py b/django/contrib/gis/gdal/envelope.py index 9774f686e70..30da4a7c82d 100644 --- a/django/contrib/gis/gdal/envelope.py +++ b/django/contrib/gis/gdal/envelope.py @@ -13,6 +13,7 @@ from ctypes import Structure, c_double from django.contrib.gis.gdal.error import OGRException + # The OGR definition of an Envelope is a C structure containing four doubles. # See the 'ogr_core.h' source file for more information: # http://www.gdal.org/ogr/ogr__core_8h-source.html @@ -24,6 +25,7 @@ class OGREnvelope(Structure): ("MaxY", c_double), ] + class Envelope(object): """ The Envelope object is a C structure that contains the minimum and diff --git a/django/contrib/gis/gdal/error.py b/django/contrib/gis/gdal/error.py index 968b7f74aa7..5feef418732 100644 --- a/django/contrib/gis/gdal/error.py +++ b/django/contrib/gis/gdal/error.py @@ -3,16 +3,20 @@ check_err() routine which checks the status code returned by OGR methods. """ + #### OGR & SRS Exceptions #### 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 @@ -37,6 +41,7 @@ OGRERR_DICT = { } OGRERR_NONE = 0 + def check_err(code): "Checks the given OGRERR, and raises an exception where appropriate." diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py index a664be1598f..d020b344884 100644 --- a/django/contrib/gis/gdal/feature.py +++ b/django/contrib/gis/gdal/feature.py @@ -11,6 +11,7 @@ from django.utils.encoding import force_bytes, force_text from django.utils import six from django.utils.six.moves import xrange + # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py index 7c46226ad63..dd60f3b9534 100644 --- a/django/contrib/gis/gdal/field.py +++ b/django/contrib/gis/gdal/field.py @@ -102,6 +102,7 @@ class Field(GDALBase): "Returns the width of this Field." return capi.get_field_width(self.ptr) + ### The Field sub-classes for each OGR Field type. ### class OFTInteger(Field): _double = False @@ -125,22 +126,27 @@ class OFTInteger(Field): """ return 0 + class OFTReal(Field): @property def value(self): "Returns a float contained in this field." return self.as_double() + # String & Binary fields, just subclasses class OFTString(Field): pass + class OFTWideString(Field): pass + class OFTBinary(Field): pass + # OFTDate, OFTTime, OFTDateTime fields. class OFTDate(Field): @property @@ -152,6 +158,7 @@ class OFTDate(Field): except (ValueError, OGRException): return None + class OFTDateTime(Field): @property def value(self): @@ -166,6 +173,7 @@ class OFTDateTime(Field): except (ValueError, OGRException): return None + class OFTTime(Field): @property def value(self): @@ -176,16 +184,20 @@ class OFTTime(Field): except (ValueError, OGRException): return None + # List fields are also just subclasses class OFTIntegerList(Field): pass + class OFTRealList(Field): pass + class OFTStringList(Field): pass + class OFTWideStringList(Field): pass diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index 74a4e94450a..98ae5a1108c 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -67,7 +67,7 @@ from django.utils.six.moves import xrange # # The OGR_G_* routines are relevant here. -#### OGRGeometry Class #### + class OGRGeometry(GDALBase): "Generally encapsulates an OGR geometry." diff --git a/django/contrib/gis/gdal/layer.py b/django/contrib/gis/gdal/layer.py index 226013540c2..1fe5f52fb5d 100644 --- a/django/contrib/gis/gdal/layer.py +++ b/django/contrib/gis/gdal/layer.py @@ -18,6 +18,7 @@ from django.utils.encoding import force_bytes, force_text from django.utils import six from django.utils.six.moves import xrange + # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py index 0e5767967aa..2c05bfb9434 100644 --- a/django/contrib/gis/gdal/srs.py +++ b/django/contrib/gis/gdal/srs.py @@ -328,6 +328,7 @@ class SpatialReference(GDALBase): "Returns the XML representation of this Spatial Reference." return capi.to_xml(self.ptr, byref(c_char_p()), dialect) + class CoordTransform(GDALBase): "The coordinate system transformation object." diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py index c4188d88198..05e3b5c2686 100644 --- a/django/contrib/gis/geoip/base.py +++ b/django/contrib/gis/geoip/base.py @@ -17,10 +17,12 @@ from django.utils.encoding import force_bytes free_regex = re.compile(r'^GEO-\d{3}FREE') lite_regex = re.compile(r'^GEO-\d{3}LITE') + #### GeoIP classes #### class GeoIPException(Exception): pass + class GeoIP(object): # The flags for GeoIP memory caching. # GEOIP_STANDARD - read database from filesystem, uses least memory. diff --git a/django/contrib/gis/geos/base.py b/django/contrib/gis/geos/base.py index 1d44e0a8b62..ff54fe66955 100644 --- a/django/contrib/gis/geos/base.py +++ b/django/contrib/gis/geos/base.py @@ -18,6 +18,7 @@ try: except ImportError: numpy = False + class GEOSBase(object): """ Base object for GEOS objects that has a pointer access property diff --git a/django/contrib/gis/geos/io.py b/django/contrib/gis/geos/io.py index 1c13d365f70..97c4016865c 100644 --- a/django/contrib/gis/geos/io.py +++ b/django/contrib/gis/geos/io.py @@ -6,12 +6,14 @@ reader and writer classes. from django.contrib.gis.geos.geometry import GEOSGeometry from django.contrib.gis.geos.prototypes.io import _WKTReader, _WKBReader, WKBWriter, WKTWriter + # Public classes for (WKB|WKT)Reader, which return GEOSGeometry class WKBReader(_WKBReader): def read(self, wkb): "Returns a GEOSGeometry for the given WKB buffer." return GEOSGeometry(super(WKBReader, self).read(wkb)) + class WKTReader(_WKTReader): def read(self, wkt): "Returns a GEOSGeometry for the given WKT string." diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index 87ae6dd8f34..08ebb0a8e7c 100644 --- a/django/contrib/gis/geos/mutable_list.py +++ b/django/contrib/gis/geos/mutable_list.py @@ -12,6 +12,7 @@ from django.utils.functional import total_ordering from django.utils import six from django.utils.six.moves import xrange + @total_ordering class ListMixin(object): """ diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py index 0da90e3a19d..ef8eb27de52 100644 --- a/django/contrib/gis/geos/polygon.py +++ b/django/contrib/gis/geos/polygon.py @@ -6,6 +6,7 @@ from django.contrib.gis.geos import prototypes as capi from django.utils import six from django.utils.six.moves import xrange + class Polygon(GEOSGeometry): _minlength = 1 diff --git a/django/contrib/gis/geos/prepared.py b/django/contrib/gis/geos/prepared.py index d414d8ddf68..a6a205da5ee 100644 --- a/django/contrib/gis/geos/prepared.py +++ b/django/contrib/gis/geos/prepared.py @@ -2,6 +2,7 @@ from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.geometry import GEOSGeometry from django.contrib.gis.geos.prototypes import prepared as capi + class PreparedGeometry(GEOSBase): """ A geometry that is prepared for performing certain operations. diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py index 82d75e0cefd..03432114958 100644 --- a/django/contrib/gis/measure.py +++ b/django/contrib/gis/measure.py @@ -44,6 +44,7 @@ from django.utils import six NUMERIC_TYPES = six.integer_types + (float, Decimal) AREA_PREFIX = "sq_" + def pretty_name(obj): return obj.__name__ if obj.__class__ == type else obj.__class__.__name__ @@ -218,6 +219,7 @@ class MeasureBase(object): else: raise Exception('Could not find a unit keyword associated with "%s"' % unit_str) + class Distance(MeasureBase): STANDARD_UNIT = "m" UNITS = { diff --git a/django/contrib/gis/shortcuts.py b/django/contrib/gis/shortcuts.py index 85f9bfd0c03..a530228e847 100644 --- a/django/contrib/gis/shortcuts.py +++ b/django/contrib/gis/shortcuts.py @@ -5,6 +5,7 @@ from django.conf import settings from django.http import HttpResponse from django.template import loader + def compress_kml(kml): "Returns compressed KMZ from the given KML string." kmz = BytesIO() @@ -14,11 +15,13 @@ def compress_kml(kml): kmz.seek(0) return kmz.read() + def render_to_kml(*args, **kwargs): "Renders the response as KML (using the correct MIME type)." return HttpResponse(loader.render_to_string(*args, **kwargs), content_type='application/vnd.google-earth.kml+xml') + def render_to_kmz(*args, **kwargs): """ Compresses the KML content and returns as KMZ (using the correct @@ -27,6 +30,7 @@ def render_to_kmz(*args, **kwargs): return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)), content_type='application/vnd.google-earth.kmz') + def render_to_text(*args, **kwargs): "Renders the response using the MIME type for plain text." return HttpResponse(loader.render_to_string(*args, **kwargs), diff --git a/django/contrib/gis/sitemaps/georss.py b/django/contrib/gis/sitemaps/georss.py index 5201de913b9..effa06f98e9 100644 --- a/django/contrib/gis/sitemaps/georss.py +++ b/django/contrib/gis/sitemaps/georss.py @@ -1,6 +1,7 @@ from django.core import urlresolvers from django.contrib.sitemaps import Sitemap + class GeoRSSSitemap(Sitemap): """ A minimal hook to produce sitemaps for GeoRSS feeds. diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py index 68e2ffd7d95..5e74c6c47dc 100644 --- a/django/contrib/gis/sitemaps/kml.py +++ b/django/contrib/gis/sitemaps/kml.py @@ -3,6 +3,7 @@ from django.contrib.sitemaps import Sitemap from django.contrib.gis.db.models.fields import GeometryField from django.db import models + class KMLSitemap(Sitemap): """ A minimal hook to produce KML sitemaps. @@ -60,5 +61,7 @@ class KMLSitemap(Sitemap): 'field_name': obj[2], } ) + + class KMZSitemap(KMLSitemap): geo_format = 'kmz' diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index dac63658e6e..5dc3bc9273e 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -14,6 +14,7 @@ from django.utils.translation import ugettext as _ from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz + def index(request, sitemaps): """ This view generates a sitemap index that uses the proper view diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py index 5e0db3f9131..58a1af0bf11 100644 --- a/django/contrib/gis/tests/test_measure.py +++ b/django/contrib/gis/tests/test_measure.py @@ -144,6 +144,7 @@ class DistanceTest(unittest.TestCase): for nm, att in unit_tuple: self.assertEqual(att, D.unit_attname(nm)) + class AreaTest(unittest.TestCase): "Testing the Area object" diff --git a/django/contrib/gis/tests/utils.py b/django/contrib/gis/tests/utils.py index e6433e64890..a53b9a35649 100644 --- a/django/contrib/gis/tests/utils.py +++ b/django/contrib/gis/tests/utils.py @@ -14,17 +14,21 @@ def no_backend(test_func, backend): else: return test_func + # Decorators to disable entire test functions for specific # spatial backends. def no_oracle(func): return no_backend(func, 'oracle') + def no_postgis(func): return no_backend(func, 'postgis') + def no_mysql(func): return no_backend(func, 'mysql') + def no_spatialite(func): return no_backend(func, 'spatialite') diff --git a/django/contrib/gis/views.py b/django/contrib/gis/views.py index 3fa8f044ded..cc6844ba489 100644 --- a/django/contrib/gis/views.py +++ b/django/contrib/gis/views.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from django.http import Http404 from django.utils.translation import ugettext as _ + def feed(request, url, feed_dict=None): """Provided for backwards compatibility.""" if not feed_dict: diff --git a/django/contrib/sites/management.py b/django/contrib/sites/management.py index a4a0090dab3..7dec568fa4b 100644 --- a/django/contrib/sites/management.py +++ b/django/contrib/sites/management.py @@ -9,6 +9,7 @@ from django.contrib.sites.models import Site from django.contrib.sites import models as site_app from django.core.management.color import no_style + def create_default_site(app, created_models, verbosity, db, **kwargs): # Only create the default sites in databases where Django created the table if Site in created_models and router.allow_migrate(db, Site): diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py index e036f6b141a..3fe0c9da26b 100644 --- a/django/contrib/staticfiles/handlers.py +++ b/django/contrib/staticfiles/handlers.py @@ -6,6 +6,7 @@ from django.utils.six.moves.urllib.request import url2pathname from django.contrib.staticfiles import utils from django.contrib.staticfiles.views import serve + class StaticFilesHandler(WSGIHandler): """ WSGI middleware that intercepts calls to the static files directory, as diff --git a/django/contrib/staticfiles/urls.py b/django/contrib/staticfiles/urls.py index 04062c1162b..4a0feeaaf8c 100644 --- a/django/contrib/staticfiles/urls.py +++ b/django/contrib/staticfiles/urls.py @@ -3,6 +3,7 @@ from django.conf.urls.static import static urlpatterns = [] + def staticfiles_urlpatterns(prefix=None): """ Helper function to return a URL pattern for serving static files.