Permalink
Browse files

More attacking E302 violators

  • Loading branch information...
1 parent 65c4ac3 commit 7548aa8ffd46eb6e0f73730d1b2eb515ba581f95 @alex alex committed Nov 2, 2013
Showing with 433 additions and 1 deletion.
  1. +2 −0 django/contrib/gis/db/backends/spatialite/operations.py
  2. +1 −0 django/contrib/gis/gdal/error.py
  3. +8 −0 django/contrib/gis/gdal/geometries.py
  4. +1 −1 django/contrib/gis/gdal/geomtype.py
  5. +8 −0 django/contrib/gis/gdal/libgdal.py
  6. +11 −0 django/contrib/gis/gdal/prototypes/errcheck.py
  7. +9 −0 django/contrib/gis/gdal/prototypes/generation.py
  8. +3 −0 django/contrib/gis/gdal/prototypes/geom.py
  9. +2 −0 django/contrib/gis/gdal/prototypes/srs.py
  10. +7 −0 django/contrib/gis/geoip/prototypes.py
  11. +4 −0 django/contrib/gis/geos/collections.py
  12. +1 −0 django/contrib/gis/geos/coordseq.py
  13. +2 −0 django/contrib/gis/geos/error.py
  14. +11 −0 django/contrib/gis/geos/libgeos.py
  15. +2 −0 django/contrib/gis/geos/linestring.py
  16. +1 −0 django/contrib/gis/geos/point.py
  17. +6 −0 django/contrib/gis/geos/prototypes/coordseq.py
  18. +8 −0 django/contrib/gis/geos/prototypes/errcheck.py
  19. +7 −0 django/contrib/gis/geos/prototypes/geom.py
  20. +18 −0 django/contrib/gis/geos/prototypes/io.py
  21. +1 −0 django/contrib/gis/geos/prototypes/misc.py
  22. +2 −0 django/contrib/gis/geos/prototypes/predicates.py
  23. +1 −0 django/contrib/gis/geos/prototypes/prepared.py
  24. +3 −0 django/contrib/gis/geos/prototypes/threadsafe.py
  25. +1 −0 django/contrib/gis/geos/prototypes/topology.py
  26. +13 −0 django/contrib/gis/geos/tests/test_geos_mutation.py
  27. +4 −0 django/contrib/gis/geos/tests/test_mutable_list.py
  28. +1 −0 django/contrib/gis/management/commands/inspectdb.py
  29. +3 −0 django/contrib/gis/management/commands/ogrinspect.py
  30. +2 −0 django/contrib/gis/maps/google/gmap.py
  31. +4 −0 django/contrib/gis/maps/google/overlays.py
  32. +1 −0 django/contrib/gis/maps/google/zoom.py
  33. +3 −0 django/contrib/gis/sitemaps/views.py
  34. +7 −0 django/contrib/gis/tests/distapp/models.py
  35. +10 −0 django/contrib/gis/tests/geo3d/models.py
  36. +1 −0 django/contrib/gis/tests/geoadmin/models.py
  37. +6 −0 django/contrib/gis/tests/geoapp/feeds.py
  38. +6 −0 django/contrib/gis/tests/geoapp/models.py
  39. +3 −0 django/contrib/gis/tests/geogapp/models.py
  40. +1 −0 django/contrib/gis/tests/inspectapp/models.py
  41. +9 −0 django/contrib/gis/tests/layermap/models.py
  42. +1 −0 django/contrib/gis/tests/layermap/tests.py
  43. +8 −0 django/contrib/gis/tests/relatedapp/models.py
  44. +2 −0 django/contrib/gis/tests/test_measure.py
  45. +3 −0 django/contrib/gis/tests/test_spatialrefsys.py
  46. +5 −0 django/contrib/gis/utils/layermapping.py
  47. +1 −0 django/contrib/gis/utils/ogrinfo.py
  48. +3 −0 django/contrib/gis/utils/ogrinspect.py
  49. +1 −0 django/contrib/gis/utils/srs.py
  50. +1 −0 django/contrib/gis/utils/wkt.py
  51. +1 −0 django/contrib/messages/storage/cookie.py
  52. +1 −0 django/contrib/messages/storage/fallback.py
  53. +1 −0 django/contrib/messages/tests/test_mixins.py
  54. +4 −0 django/contrib/messages/tests/urls.py
  55. +1 −0 django/contrib/redirects/models.py
  56. +2 −0 django/contrib/sessions/backends/base.py
  57. +1 −0 django/contrib/sessions/backends/db.py
  58. +1 −0 django/contrib/sessions/backends/file.py
  59. +1 −0 django/contrib/sessions/middleware.py
  60. +1 −0 django/contrib/sitemaps/tests/test_flatpages.py
  61. +1 −0 django/contrib/sitemaps/tests/test_https.py
  62. +1 −0 django/contrib/sitemaps/tests/urls/https.py
  63. +3 −0 django/contrib/sitemaps/views.py
  64. +1 −0 django/contrib/sites/managers.py
  65. +1 −0 django/contrib/staticfiles/management/commands/findstatic.py
  66. +1 −0 django/contrib/staticfiles/management/commands/runserver.py
  67. +3 −0 django/contrib/staticfiles/utils.py
  68. +1 −0 django/contrib/staticfiles/views.py
  69. +4 −0 django/contrib/webdesign/lorem_ipsum.py
  70. +2 −0 django/contrib/webdesign/templatetags/webdesign.py
  71. +3 −0 django/core/cache/backends/db.py
  72. +2 −0 django/core/cache/backends/dummy.py
  73. +1 −0 django/core/cache/backends/filebased.py
  74. +2 −0 django/core/cache/backends/memcached.py
  75. +2 −0 django/core/checks/compatibility/django_1_6_0.py
  76. +6 −0 django/core/context_processors.py
  77. +2 −0 django/core/files/base.py
  78. +1 −0 django/core/files/locks.py
  79. +2 −0 django/core/files/move.py
  80. +4 −0 django/core/files/storage.py
  81. +7 −0 django/core/files/uploadhandler.py
  82. +1 −0 django/core/mail/backends/base.py
  83. +1 −0 django/core/mail/backends/console.py
  84. +1 −0 django/core/mail/backends/dummy.py
  85. +1 −0 django/core/mail/backends/filebased.py
  86. +1 −0 django/core/mail/backends/locmem.py
  87. +8 −0 django/core/management/__init__.py
  88. +3 −0 django/core/management/color.py
  89. +2 −0 django/core/management/commands/compilemessages.py
  90. +1 −0 django/core/management/commands/dbshell.py
  91. +2 −0 django/core/management/commands/diffsettings.py
  92. +1 −0 django/core/management/commands/dumpdata.py
  93. +1 −0 django/core/management/commands/makemessages.py
  94. +1 −0 django/core/management/commands/runfcgi.py
  95. +1 −0 django/core/management/commands/sql.py
  96. +1 −0 django/core/management/commands/sqlclear.py
  97. +1 −0 django/core/management/commands/sqlcustom.py
  98. +1 −0 django/core/management/commands/sqldropindexes.py
  99. +1 −0 django/core/management/commands/sqlflush.py
  100. +1 −0 django/core/management/commands/sqlindexes.py
  101. +1 −0 django/core/management/commands/sqlinitialdata.py
  102. +1 −0 django/core/management/commands/sqlsequencereset.py
  103. +1 −0 django/core/management/commands/testserver.py
  104. +1 −0 django/core/management/utils.py
  105. +7 −0 django/core/serializers/__init__.py
  106. +7 −0 django/core/serializers/base.py
  107. +1 −0 django/core/serializers/json.py
  108. +1 −0 django/core/serializers/python.py
  109. +2 −0 django/core/serializers/pyyaml.py
  110. +2 −0 django/core/serializers/xml_serializer.py
  111. +2 −0 django/core/servers/fastcgi.py
  112. +18 −0 django/core/urlresolvers.py
  113. +1 −0 django/db/migrations/optimizer.py
  114. +1 −0 django/db/models/fields/related.py
  115. +2 −0 django/db/models/loading.py
  116. +2 −0 django/db/models/options.py
  117. +4 −0 django/dispatch/saferef.py
  118. +1 −0 django/forms/forms.py
  119. +4 −0 django/forms/formsets.py
  120. +5 −0 django/forms/utils.py
  121. +2 −0 django/forms/widgets.py
  122. +3 −0 django/http/multipartparser.py
  123. +2 −0 django/middleware/cache.py
  124. +1 −0 django/middleware/clickjacking.py
  125. +1 −0 django/middleware/csrf.py
  126. +1 −0 django/middleware/gzip.py
  127. +1 −0 django/middleware/http.py
  128. +1 −0 django/middleware/transaction.py
  129. +7 −0 django/shortcuts/__init__.py
  130. +4 −0 django/template/base.py
  131. +1 −0 django/template/context.py
  132. +2 −0 django/template/debug.py
  133. +1 −0 django/template/defaultfilters.py
  134. +1 −0 django/template/smartif.py
  135. +1 −0 django/templatetags/cache.py
  136. +2 −0 django/utils/_os.py
  137. +1 −0 django/utils/autoreload.py
  138. +1 −0 django/utils/baseconv.py
  139. +1 −0 django/utils/checksums.py
  140. +2 −0 django/utils/datetime_safe.py
  141. +2 −0 django/utils/encoding.py
  142. +1 −0 django/utils/feedgenerator.py
  143. +2 −0 django/utils/html.py
  144. +3 −0 django/utils/ipv6.py
  145. +4 −0 django/utils/regex_helper.py
  146. +3 −0 django/utils/safestring.py
  147. +1 −0 django/utils/tree.py
  148. +1 −0 django/utils/tzinfo.py
  149. +2 −0 django/utils/version.py
  150. +1 −0 django/utils/xmlutils.py
@@ -53,6 +53,8 @@ def __init__(self, pattern):
# 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),)
@@ -4,6 +4,7 @@
OGR methods.
"""
+
#### OGR & SRS Exceptions ####
class GDALException(Exception):
pass
@@ -522,6 +522,7 @@ def union(self, other):
"""
return self._geomgen(capi.geom_union, other)
+
# The subclasses for OGR Geometry.
class Point(OGRGeometry):
@@ -550,6 +551,7 @@ def tuple(self):
return (self.x, self.y, self.z)
coords = tuple
+
class LineString(OGRGeometry):
def __getitem__(self, index):
@@ -605,10 +607,12 @@ def z(self):
if self.coord_dim == 3:
return self._listarr(capi.getz)
+
# LinearRings are used in Polygons.
class LinearRing(LineString):
pass
+
class Polygon(OGRGeometry):
def __len__(self):
@@ -654,6 +658,7 @@ def centroid(self):
capi.get_centroid(self.ptr, p.ptr)
return p
+
# Geometry Collection base class.
class GeometryCollection(OGRGeometry):
"The Geometry Collection class."
@@ -700,13 +705,16 @@ def tuple(self):
return tuple(self[i].tuple for i in xrange(self.geom_count))
coords = tuple
+
# Multiple Geometry types.
class MultiPoint(GeometryCollection):
pass
+
class MultiLineString(GeometryCollection):
pass
+
class MultiPolygon(GeometryCollection):
pass
@@ -2,7 +2,7 @@
from django.utils import six
-#### OGRGeomType ####
+
class OGRGeomType(object):
"Encapulates OGR Geometry Types."
@@ -55,6 +55,7 @@
from ctypes import WinDLL
lwingdal = WinDLL(lib_path)
+
def std_call(func):
"""
Returns the correct STDCALL function for certain OSR routines on Win32
@@ -72,15 +73,19 @@ def std_call(func):
_version_info.argtypes = [c_char_p]
_version_info.restype = c_char_p
+
def gdal_version():
"Returns only the GDAL version number information."
return _version_info(b'RELEASE_NAME')
+
def gdal_full_version():
"Returns the full GDAL version information."
return _version_info('')
version_regex = re.compile(r'^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<subminor>\d+))?')
+
+
def gdal_version_info():
ver = gdal_version().decode()
m = version_regex.match(ver)
@@ -97,10 +102,13 @@ def gdal_version_info():
# Set library error handling so as errors are logged
CPLErrorHandler = CFUNCTYPE(None, c_int, c_int, c_char_p)
+
+
def err_handler(error_class, error_number, message):
logger.error('GDAL_ERROR %d: %s' % (error_number, message))
err_handler = CPLErrorHandler(err_handler)
+
def function(name, args, restype):
func = std_call(name)
func.argtypes = args
@@ -15,10 +15,12 @@ def arg_byref(args, offset=-1):
"Returns the pointer argument's by-refernece value."
return args[offset]._obj.value
+
def ptr_byref(args, offset=-1):
"Returns the pointer argument passed in by-reference."
return args[offset]._obj
+
### String checking Routines ###
def check_const_string(result, func, cargs, offset=None):
"""
@@ -31,6 +33,7 @@ def check_const_string(result, func, cargs, offset=None):
else:
return result
+
def check_string(result, func, cargs, offset=-1, str_result=False):
"""
Checks the string output returned from the given function, and frees
@@ -61,12 +64,14 @@ def check_string(result, func, cargs, offset=-1, str_result=False):
### DataSource, Layer error-checking ###
+
### Envelope checking ###
def check_envelope(result, func, cargs, offset=-1):
"Checks a function that returns an OGR Envelope by reference."
env = ptr_byref(cargs, offset)
return env
+
### Geometry error-checking routines ###
def check_geom(result, func, cargs):
"Checks a function that returns a geometry."
@@ -78,12 +83,14 @@ def check_geom(result, func, cargs):
raise OGRException('Invalid geometry pointer returned from "%s".' % func.__name__)
return result
+
def check_geom_offset(result, func, cargs, offset=-1):
"Chcks the geometry at the given offset in the C parameter list."
check_err(result)
geom = ptr_byref(cargs, offset=offset)
return check_geom(geom, func, cargs)
+
### Spatial Reference error-checking routines ###
def check_srs(result, func, cargs):
if isinstance(result, six.integer_types):
@@ -92,6 +99,7 @@ def check_srs(result, func, cargs):
raise SRSException('Invalid spatial reference pointer returned from "%s".' % func.__name__)
return result
+
### Other error-checking routines ###
def check_arg_errcode(result, func, cargs):
"""
@@ -101,12 +109,14 @@ def check_arg_errcode(result, func, cargs):
check_err(arg_byref(cargs))
return result
+
def check_errcode(result, func, cargs):
"""
Check the error code returned (c_int).
"""
check_err(result)
+
def check_pointer(result, func, cargs):
"Makes sure the result pointer is valid."
if isinstance(result, six.integer_types):
@@ -116,6 +126,7 @@ def check_pointer(result, func, cargs):
else:
raise OGRException('Invalid pointer returned from "%s"' % func.__name__)
+
def check_str_arg(result, func, cargs):
"""
This is for the OSRGet[Angular|Linear]Units functions, which
@@ -8,9 +8,11 @@
check_arg_errcode, check_errcode, check_geom, check_geom_offset,
check_pointer, check_srs, check_str_arg, check_string, check_const_string)
+
class gdal_char_p(c_char_p):
pass
+
def double_output(func, argtypes, errcheck=False, strarg=False):
"Generates a ctypes function that returns a double value."
func.argtypes = argtypes
@@ -21,6 +23,7 @@ def double_output(func, argtypes, errcheck=False, strarg=False):
func.errcheck = check_str_arg
return func
+
def geom_output(func, argtypes, offset=None):
"""
Generates a function that returns a Geometry either by reference
@@ -43,12 +46,14 @@ def geomerrcheck(result, func, cargs):
return func
+
def int_output(func, argtypes):
"Generates a ctypes function that returns an integer value."
func.argtypes = argtypes
func.restype = c_int
return func
+
def srs_output(func, argtypes):
"""
Generates a ctypes prototype for the given function with
@@ -60,6 +65,7 @@ def srs_output(func, argtypes):
func.errcheck = check_srs
return func
+
def const_string_output(func, argtypes, offset=None, decoding=None):
func.argtypes = argtypes
if offset:
@@ -76,6 +82,7 @@ def _check_const(result, func, cargs):
return func
+
def string_output(func, argtypes, offset=-1, str_result=False, decoding=None):
"""
Generates a ctypes prototype for the given function with the
@@ -104,6 +111,7 @@ def _check_str(result, func, cargs):
func.errcheck = _check_str
return func
+
def void_output(func, argtypes, errcheck=True):
"""
For functions that don't only return an error code that needs to
@@ -121,6 +129,7 @@ def void_output(func, argtypes, errcheck=True):
return func
+
def voidptr_output(func, argtypes):
"For functions that return c_void_p."
func.argtypes = argtypes
@@ -5,6 +5,7 @@
from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
double_output, geom_output, int_output, srs_output, string_output, void_output)
+
### Generation routines specific to this module ###
def env_func(f, argtypes):
"For getting OGREnvelopes."
@@ -13,10 +14,12 @@ def env_func(f, argtypes):
f.errcheck = check_envelope
return f
+
def pnt_func(f):
"For accessing point information."
return double_output(f, [c_void_p, c_int])
+
def topology_func(f):
f.argtypes = [c_void_p, c_void_p]
f.restype = c_int
@@ -3,6 +3,7 @@
from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
double_output, int_output, srs_output, string_output, void_output)
+
## Shortcut generation for routines with known parameters.
def srs_double(f):
"""
@@ -11,6 +12,7 @@ def srs_double(f):
"""
return double_output(f, [c_void_p, POINTER(c_int)], errcheck=True)
+
def units_func(f):
"""
Creates a ctypes function prototype for OSR units functions, e.g.,
@@ -1,6 +1,7 @@
from ctypes import c_char_p, c_float, c_int, string_at, Structure, POINTER
from django.contrib.gis.geoip.libgeoip import lgeoip, free
+
#### GeoIP C Structure definitions ####
class GeoIPRecord(Structure):
@@ -27,6 +28,7 @@ class GeoIPRecord(Structure):
1: 'utf8',
}
+
class GeoIPTag(Structure):
pass
@@ -48,6 +50,7 @@ class GeoIPTag(Structure):
GeoIPRecord_delete.argtypes = [RECTYPE]
GeoIPRecord_delete.restype = None
+
# For retrieving records by name or address.
def check_record(result, func, cargs):
if result:
@@ -68,6 +71,7 @@ def check_record(result, func, cargs):
else:
return None
+
def record_output(func):
func.argtypes = [DBTYPE, c_char_p]
func.restype = RECTYPE
@@ -84,10 +88,12 @@ def record_output(func):
GeoIP_delete.argtypes = [DBTYPE]
GeoIP_delete.restype = None
+
# This is so the string pointer can be freed within Python.
class geoip_char_p(c_char_p):
pass
+
def check_string(result, func, cargs):
if result:
s = string_at(result)
@@ -100,6 +106,7 @@ def check_string(result, func, cargs):
GeoIP_database_info.restype = geoip_char_p
GeoIP_database_info.errcheck = check_string
+
# String output routines.
def string_output(func):
def _err_check(result, func, cargs):
@@ -12,6 +12,7 @@
from django.contrib.gis.geos import prototypes as capi
from django.utils.six.moves import xrange
+
class GeometryCollection(GEOSGeometry):
_typeid = 7
@@ -91,11 +92,13 @@ def tuple(self):
return tuple(g.tuple for g in self)
coords = tuple
+
# MultiPoint, MultiLineString, and MultiPolygon class definitions.
class MultiPoint(GeometryCollection):
_allowed = Point
_typeid = 4
+
class MultiLineString(GeometryCollection):
_allowed = (LineString, LinearRing)
_typeid = 5
@@ -108,6 +111,7 @@ def merged(self):
"""
return self._topology(capi.geos_linemerge(self.ptr))
+
class MultiPolygon(GeometryCollection):
_allowed = Polygon
_typeid = 6
@@ -10,6 +10,7 @@
from django.contrib.gis.geos import prototypes as capi
from django.utils.six.moves import xrange
+
class GEOSCoordSeq(GEOSBase):
"The internal representation of a list of coordinates inside a Geometry."
Oops, something went wrong. Retry.

0 comments on commit 7548aa8

Please sign in to comment.