Fixed E265 comment style
This commit is contained in:
parent
eb45a29565
commit
db77915c9f
|
@ -163,7 +163,7 @@ class GeometryField(GeoSelectFormatMixin, Field):
|
|||
self._get_srid_info(connection)
|
||||
return self._units_name
|
||||
|
||||
### Routines specific to GeometryField ###
|
||||
# ### Routines specific to GeometryField ###
|
||||
def geodetic(self, connection):
|
||||
"""
|
||||
Returns true if this field's SRID corresponds with a coordinate
|
||||
|
@ -236,7 +236,7 @@ class GeometryField(GeoSelectFormatMixin, Field):
|
|||
else:
|
||||
return gsrid
|
||||
|
||||
### Routines overloaded from Field ###
|
||||
# ### Routines overloaded from Field ###
|
||||
def contribute_to_class(self, cls, name, **kwargs):
|
||||
super(GeometryField, self).contribute_to_class(cls, name, **kwargs)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from django.utils.deprecation import RemovedInDjango20Warning
|
|||
class GeoQuerySet(QuerySet):
|
||||
"The Geographic QuerySet."
|
||||
|
||||
### GeoQuerySet Methods ###
|
||||
# ### GeoQuerySet Methods ###
|
||||
def area(self, tolerance=0.05, **kwargs):
|
||||
"""
|
||||
Returns the area of the geographic field in an `area` attribute on
|
||||
|
@ -426,7 +426,7 @@ class GeoQuerySet(QuerySet):
|
|||
)
|
||||
return self._spatial_aggregate(aggregates.Union, **kwargs)
|
||||
|
||||
### Private API -- Abstracted DRY routines. ###
|
||||
# ### Private API -- Abstracted DRY routines. ###
|
||||
def _spatial_setup(self, att, desc=None, field_name=None, geo_field_type=None):
|
||||
"""
|
||||
Performs set up for executing the spatial function.
|
||||
|
|
|
@ -81,7 +81,7 @@ class GeoFeedMixin(object):
|
|||
raise ValueError('Geometry type "%s" not supported.' % geom.geom_type)
|
||||
|
||||
|
||||
### SyndicationFeed subclasses ###
|
||||
# ### SyndicationFeed subclasses ###
|
||||
class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin):
|
||||
def rss_attributes(self):
|
||||
attrs = super(GeoRSSFeed, self).rss_attributes()
|
||||
|
@ -127,7 +127,7 @@ class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin):
|
|||
self.add_georss_element(handler, self.feed, w3c_geo=True)
|
||||
|
||||
|
||||
### Feed subclass ###
|
||||
# ### Feed subclass ###
|
||||
class Feed(BaseFeed):
|
||||
"""
|
||||
This is a subclass of the `Feed` from `django.contrib.syndication`.
|
||||
|
|
|
@ -52,7 +52,6 @@ from django.utils.six.moves import range
|
|||
class DataSource(GDALBase):
|
||||
"Wraps an OGR Data Source object."
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, ds_input, ds_driver=False, write=False, encoding='utf-8'):
|
||||
# The write flag.
|
||||
if write:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"""
|
||||
|
||||
|
||||
#### GDAL & SRS Exceptions ####
|
||||
# #### GDAL & SRS Exceptions ####
|
||||
class GDALException(Exception):
|
||||
pass
|
||||
|
||||
|
@ -27,7 +27,7 @@ class OGRIndexError(GDALException, KeyError):
|
|||
"""
|
||||
silent_variable_failure = True
|
||||
|
||||
#### GDAL/OGR error checking codes and routine ####
|
||||
# #### GDAL/OGR error checking codes and routine ####
|
||||
|
||||
# OGR Error Codes
|
||||
OGRERR_DICT = {
|
||||
|
|
|
@ -18,7 +18,6 @@ class Feature(GDALBase):
|
|||
from a Layer object.
|
||||
"""
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, feat, layer):
|
||||
"""
|
||||
Initializes Feature from a pointer and its Layer object.
|
||||
|
@ -65,7 +64,7 @@ class Feature(GDALBase):
|
|||
"Does equivalence testing on the features."
|
||||
return bool(capi.feature_equal(self.ptr, other._ptr))
|
||||
|
||||
#### Feature Properties ####
|
||||
# #### Feature Properties ####
|
||||
@property
|
||||
def encoding(self):
|
||||
return self._layer._ds.encoding
|
||||
|
@ -104,7 +103,7 @@ class Feature(GDALBase):
|
|||
"Returns the OGR Geometry Type for this Feture."
|
||||
return OGRGeomType(capi.get_fd_geom_type(self._layer._ldefn))
|
||||
|
||||
#### Feature Methods ####
|
||||
# #### Feature Methods ####
|
||||
def get(self, field):
|
||||
"""
|
||||
Returns the value of the field, instead of an instance of the Field
|
||||
|
|
|
@ -17,7 +17,6 @@ class Field(GDALBase):
|
|||
from a Feature object.
|
||||
"""
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, feat, index):
|
||||
"""
|
||||
Initializes on the feature object and the integer index of
|
||||
|
@ -45,7 +44,7 @@ class Field(GDALBase):
|
|||
"Returns the string representation of the Field."
|
||||
return str(self.value).strip()
|
||||
|
||||
#### Field Methods ####
|
||||
# #### Field Methods ####
|
||||
def as_double(self):
|
||||
"Retrieves the Field's value as a double (float)."
|
||||
return capi.get_field_as_double(self._feat.ptr, self._index)
|
||||
|
@ -70,7 +69,7 @@ class Field(GDALBase):
|
|||
else:
|
||||
raise GDALException('Unable to retrieve date & time information from the field.')
|
||||
|
||||
#### Field Properties ####
|
||||
# #### Field Properties ####
|
||||
@property
|
||||
def name(self):
|
||||
"Returns the name of this Field."
|
||||
|
@ -104,7 +103,7 @@ class Field(GDALBase):
|
|||
return capi.get_field_width(self.ptr)
|
||||
|
||||
|
||||
### The Field sub-classes for each OGR Field type. ###
|
||||
# ### The Field sub-classes for each OGR Field type. ###
|
||||
class OFTInteger(Field):
|
||||
_double = False
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ class OGRGeometry(GDALBase):
|
|||
return OGRGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % (
|
||||
x0, y0, x0, y1, x1, y1, x1, y0, x0, y0))
|
||||
|
||||
### Geometry set-like operations ###
|
||||
# ### Geometry set-like operations ###
|
||||
# g = g1 | g2
|
||||
def __or__(self, other):
|
||||
"Returns the union of the two geometries."
|
||||
|
@ -184,7 +184,7 @@ class OGRGeometry(GDALBase):
|
|||
"WKT is used for the string representation."
|
||||
return self.wkt
|
||||
|
||||
#### Geometry Properties ####
|
||||
# #### Geometry Properties ####
|
||||
@property
|
||||
def dimension(self):
|
||||
"Returns 0 for points, 1 for lines, and 2 for surfaces."
|
||||
|
@ -248,7 +248,7 @@ class OGRGeometry(GDALBase):
|
|||
"Returns the envelope as a 4-tuple, instead of as an Envelope object."
|
||||
return self.envelope.tuple
|
||||
|
||||
#### SpatialReference-related Properties ####
|
||||
# #### SpatialReference-related Properties ####
|
||||
|
||||
# The SRS property
|
||||
def _get_srs(self):
|
||||
|
@ -291,7 +291,7 @@ class OGRGeometry(GDALBase):
|
|||
|
||||
srid = property(_get_srid, _set_srid)
|
||||
|
||||
#### Output Methods ####
|
||||
# #### Output Methods ####
|
||||
@property
|
||||
def geos(self):
|
||||
"Returns a GEOSGeometry object from this OGRGeometry."
|
||||
|
@ -354,7 +354,7 @@ class OGRGeometry(GDALBase):
|
|||
else:
|
||||
return self.wkt
|
||||
|
||||
#### Geometry Methods ####
|
||||
# #### Geometry Methods ####
|
||||
def clone(self):
|
||||
"Clones this OGR Geometry."
|
||||
return OGRGeometry(capi.clone_geom(self.ptr), self.srs)
|
||||
|
@ -399,7 +399,7 @@ class OGRGeometry(GDALBase):
|
|||
"For backwards-compatibility."
|
||||
self.transform(srs)
|
||||
|
||||
#### Topology Methods ####
|
||||
# #### Topology Methods ####
|
||||
def _topology(self, func, other):
|
||||
"""A generalized function for topology operations, takes a GDAL function and
|
||||
the other geometry to perform the operation on."""
|
||||
|
@ -442,7 +442,7 @@ class OGRGeometry(GDALBase):
|
|||
"Returns True if this geometry overlaps the other."
|
||||
return self._topology(capi.ogr_overlaps, other)
|
||||
|
||||
#### Geometry-generation Methods ####
|
||||
# #### Geometry-generation Methods ####
|
||||
def _geomgen(self, gen_func, other=None):
|
||||
"A helper routine for the OGR routines that generate geometries."
|
||||
if isinstance(other, OGRGeometry):
|
||||
|
|
|
@ -25,7 +25,6 @@ from django.utils.six.moves import range
|
|||
class Layer(GDALBase):
|
||||
"A class that wraps an OGR Layer, needs to be instantiated from a DataSource object."
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, layer_ptr, ds):
|
||||
"""
|
||||
Initializes on an OGR C pointer to the Layer and the `DataSource` object
|
||||
|
@ -94,7 +93,7 @@ class Layer(GDALBase):
|
|||
# Should have returned a Feature, raise an OGRIndexError.
|
||||
raise OGRIndexError('Invalid feature id: %s.' % feat_id)
|
||||
|
||||
#### Layer properties ####
|
||||
# #### Layer properties ####
|
||||
@property
|
||||
def extent(self):
|
||||
"Returns the extent (an Envelope) of this layer."
|
||||
|
@ -188,7 +187,7 @@ class Layer(GDALBase):
|
|||
|
||||
spatial_filter = property(_get_spatial_filter, _set_spatial_filter)
|
||||
|
||||
#### Layer Methods ####
|
||||
# #### Layer Methods ####
|
||||
def get_fields(self, field_name):
|
||||
"""
|
||||
Returns a list containing the given field name for every Feature
|
||||
|
|
|
@ -66,7 +66,7 @@ def std_call(func):
|
|||
else:
|
||||
return lgdal[func]
|
||||
|
||||
#### Version-information functions. ####
|
||||
# #### Version-information functions. ####
|
||||
|
||||
# Returns GDAL library version information with the given key.
|
||||
_version_info = std_call('GDALVersionInfo')
|
||||
|
|
|
@ -14,7 +14,7 @@ from django.contrib.gis.gdal.prototypes.generation import (
|
|||
|
||||
c_int_p = POINTER(c_int) # shortcut type
|
||||
|
||||
### Driver Routines ###
|
||||
# Driver Routines
|
||||
register_all = void_output(lgdal.OGRRegisterAll, [], errcheck=False)
|
||||
cleanup_all = void_output(lgdal.OGRCleanupAll, [], errcheck=False)
|
||||
get_driver = voidptr_output(lgdal.OGRGetDriver, [c_int])
|
||||
|
@ -22,7 +22,7 @@ get_driver_by_name = voidptr_output(lgdal.OGRGetDriverByName, [c_char_p], errche
|
|||
get_driver_count = int_output(lgdal.OGRGetDriverCount, [])
|
||||
get_driver_name = const_string_output(lgdal.OGR_Dr_GetName, [c_void_p], decoding='ascii')
|
||||
|
||||
### DataSource ###
|
||||
# DataSource
|
||||
open_ds = voidptr_output(lgdal.OGROpen, [c_char_p, c_int, POINTER(c_void_p)])
|
||||
destroy_ds = void_output(lgdal.OGR_DS_Destroy, [c_void_p], errcheck=False)
|
||||
release_ds = void_output(lgdal.OGRReleaseDataSource, [c_void_p])
|
||||
|
@ -31,7 +31,7 @@ get_layer = voidptr_output(lgdal.OGR_DS_GetLayer, [c_void_p, c_int])
|
|||
get_layer_by_name = voidptr_output(lgdal.OGR_DS_GetLayerByName, [c_void_p, c_char_p])
|
||||
get_layer_count = int_output(lgdal.OGR_DS_GetLayerCount, [c_void_p])
|
||||
|
||||
### Layer Routines ###
|
||||
# Layer Routines
|
||||
get_extent = void_output(lgdal.OGR_L_GetExtent, [c_void_p, POINTER(OGREnvelope), c_int])
|
||||
get_feature = voidptr_output(lgdal.OGR_L_GetFeature, [c_void_p, c_long])
|
||||
get_feature_count = int_output(lgdal.OGR_L_GetFeatureCount, [c_void_p, c_int])
|
||||
|
@ -46,14 +46,14 @@ set_spatial_filter_rect = void_output(lgdal.OGR_L_SetSpatialFilterRect,
|
|||
[c_void_p, c_double, c_double, c_double, c_double], errcheck=False
|
||||
)
|
||||
|
||||
### Feature Definition Routines ###
|
||||
# Feature Definition Routines
|
||||
get_fd_geom_type = int_output(lgdal.OGR_FD_GetGeomType, [c_void_p])
|
||||
get_fd_name = const_string_output(lgdal.OGR_FD_GetName, [c_void_p])
|
||||
get_feat_name = const_string_output(lgdal.OGR_FD_GetName, [c_void_p])
|
||||
get_field_count = int_output(lgdal.OGR_FD_GetFieldCount, [c_void_p])
|
||||
get_field_defn = voidptr_output(lgdal.OGR_FD_GetFieldDefn, [c_void_p, c_int])
|
||||
|
||||
### Feature Routines ###
|
||||
# Feature Routines
|
||||
clone_feature = voidptr_output(lgdal.OGR_F_Clone, [c_void_p])
|
||||
destroy_feature = void_output(lgdal.OGR_F_Destroy, [c_void_p], errcheck=False)
|
||||
feature_equal = int_output(lgdal.OGR_F_Equal, [c_void_p, c_void_p])
|
||||
|
@ -69,7 +69,7 @@ get_field_as_integer = int_output(lgdal.OGR_F_GetFieldAsInteger, [c_void_p, c_in
|
|||
get_field_as_string = const_string_output(lgdal.OGR_F_GetFieldAsString, [c_void_p, c_int])
|
||||
get_field_index = int_output(lgdal.OGR_F_GetFieldIndex, [c_void_p, c_char_p])
|
||||
|
||||
### Field Routines ###
|
||||
# Field Routines
|
||||
get_field_name = const_string_output(lgdal.OGR_Fld_GetNameRef, [c_void_p])
|
||||
get_field_precision = int_output(lgdal.OGR_Fld_GetPrecision, [c_void_p])
|
||||
get_field_type = int_output(lgdal.OGR_Fld_GetType, [c_void_p])
|
||||
|
|
|
@ -23,7 +23,7 @@ def ptr_byref(args, offset=-1):
|
|||
return args[offset]._obj
|
||||
|
||||
|
||||
### String checking Routines ###
|
||||
# ### String checking Routines ###
|
||||
def check_const_string(result, func, cargs, offset=None, cpl=False):
|
||||
"""
|
||||
Similar functionality to `check_string`, but does not free the pointer.
|
||||
|
@ -64,17 +64,17 @@ def check_string(result, func, cargs, offset=-1, str_result=False):
|
|||
lgdal.VSIFree(ptr)
|
||||
return s
|
||||
|
||||
### DataSource, Layer error-checking ###
|
||||
# ### DataSource, Layer error-checking ###
|
||||
|
||||
|
||||
### Envelope 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 ###
|
||||
# ### Geometry error-checking routines ###
|
||||
def check_geom(result, func, cargs):
|
||||
"Checks a function that returns a geometry."
|
||||
# OGR_G_Clone may return an integer, even though the
|
||||
|
@ -93,7 +93,7 @@ def check_geom_offset(result, func, cargs, offset=-1):
|
|||
return check_geom(geom, func, cargs)
|
||||
|
||||
|
||||
### Spatial Reference error-checking routines ###
|
||||
# ### Spatial Reference error-checking routines ###
|
||||
def check_srs(result, func, cargs):
|
||||
if isinstance(result, six.integer_types):
|
||||
result = c_void_p(result)
|
||||
|
@ -102,7 +102,7 @@ def check_srs(result, func, cargs):
|
|||
return result
|
||||
|
||||
|
||||
### Other error-checking routines ###
|
||||
# ### Other error-checking routines ###
|
||||
def check_arg_errcode(result, func, cargs, cpl=False):
|
||||
"""
|
||||
The error code is returned in the last argument, by reference.
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.contrib.gis.gdal.prototypes.generation import (
|
|||
)
|
||||
|
||||
|
||||
### Generation routines specific to this module ###
|
||||
# ### Generation routines specific to this module ###
|
||||
def env_func(f, argtypes):
|
||||
"For getting OGREnvelopes."
|
||||
f.argtypes = argtypes
|
||||
|
@ -29,7 +29,7 @@ def topology_func(f):
|
|||
f.errchck = bool
|
||||
return f
|
||||
|
||||
### OGR_G ctypes function prototypes ###
|
||||
# ### OGR_G ctypes function prototypes ###
|
||||
|
||||
# GeoJSON routines.
|
||||
from_json = geom_output(lgdal.OGR_G_CreateGeometryFromJson, [c_char_p])
|
||||
|
|
|
@ -20,14 +20,14 @@ void_output = partial(void_output, cpl=True)
|
|||
const_string_output = partial(const_string_output, cpl=True)
|
||||
double_output = partial(double_output, cpl=True)
|
||||
|
||||
### Raster Driver Routines ###
|
||||
# Raster Driver Routines
|
||||
register_all = void_output(lgdal.GDALAllRegister, [])
|
||||
get_driver = voidptr_output(lgdal.GDALGetDriver, [c_int])
|
||||
get_driver_by_name = voidptr_output(lgdal.GDALGetDriverByName, [c_char_p], errcheck=False)
|
||||
get_driver_count = int_output(lgdal.GDALGetDriverCount, [])
|
||||
get_driver_description = const_string_output(lgdal.GDALGetDescription, [c_void_p])
|
||||
|
||||
### Raster Data Source Routines ###
|
||||
# Raster Data Source Routines
|
||||
create_ds = voidptr_output(lgdal.GDALCreate, [c_void_p, c_char_p, c_int, c_int, c_int, c_int])
|
||||
open_ds = voidptr_output(lgdal.GDALOpen, [c_char_p, c_int])
|
||||
close_ds = void_output(lgdal.GDALClose, [c_void_p])
|
||||
|
@ -45,7 +45,7 @@ set_ds_projection_ref = void_output(lgdal.GDALSetProjection, [c_void_p, c_char_p
|
|||
get_ds_geotransform = void_output(lgdal.GDALGetGeoTransform, [c_void_p, POINTER(c_double * 6)], errcheck=False)
|
||||
set_ds_geotransform = void_output(lgdal.GDALSetGeoTransform, [c_void_p, POINTER(c_double * 6)])
|
||||
|
||||
### Raster Band Routines ###
|
||||
# Raster Band Routines
|
||||
band_io = void_output(lgdal.GDALRasterIO, [c_void_p, c_int, c_int, c_int, c_int, c_int,
|
||||
c_void_p, c_int, c_int, c_int, c_int, c_int])
|
||||
get_band_xsize = int_output(lgdal.GDALGetRasterBandXSize, [c_void_p])
|
||||
|
@ -59,7 +59,7 @@ set_band_nodata_value = void_output(lgdal.GDALSetRasterNoDataValue, [c_void_p, c
|
|||
get_band_minimum = double_output(lgdal.GDALGetRasterMinimum, [c_void_p, POINTER(c_int)])
|
||||
get_band_maximum = double_output(lgdal.GDALGetRasterMaximum, [c_void_p, POINTER(c_int)])
|
||||
|
||||
### Reprojection routine ###
|
||||
# Reprojection routine
|
||||
reproject_image = void_output(lgdal.GDALReprojectImage, [c_void_p, c_char_p, c_void_p, c_char_p,
|
||||
c_int, c_double, c_double,
|
||||
c_void_p, c_void_p, c_void_p])
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.contrib.gis.gdal.prototypes.generation import (
|
|||
)
|
||||
|
||||
|
||||
## Shortcut generation for routines with known parameters.
|
||||
# Shortcut generation for routines with known parameters.
|
||||
def srs_double(f):
|
||||
"""
|
||||
Creates a function prototype for the OSR routines that take
|
||||
|
|
|
@ -42,7 +42,6 @@ class SpatialReference(GDALBase):
|
|||
systems (projections and datums) and to transform between them."
|
||||
"""
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, srs_input='', srs_type='user'):
|
||||
"""
|
||||
Creates a GDAL OSR Spatial Reference object from the given input.
|
||||
|
@ -132,7 +131,7 @@ class SpatialReference(GDALBase):
|
|||
"The string representation uses 'pretty' WKT."
|
||||
return self.pretty_wkt
|
||||
|
||||
#### SpatialReference Methods ####
|
||||
# #### SpatialReference Methods ####
|
||||
def attr_value(self, target, index=0):
|
||||
"""
|
||||
The attribute value for the given target node (e.g. 'PROJCS'). The index
|
||||
|
@ -173,7 +172,7 @@ class SpatialReference(GDALBase):
|
|||
"Checks to see if the given spatial reference is valid."
|
||||
capi.srs_validate(self.ptr)
|
||||
|
||||
#### Name & SRID properties ####
|
||||
# #### Name & SRID properties ####
|
||||
@property
|
||||
def name(self):
|
||||
"Returns the name of this Spatial Reference."
|
||||
|
@ -194,7 +193,7 @@ class SpatialReference(GDALBase):
|
|||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
#### Unit Properties ####
|
||||
# #### Unit Properties ####
|
||||
@property
|
||||
def linear_name(self):
|
||||
"Returns the name of the linear units."
|
||||
|
@ -235,7 +234,7 @@ class SpatialReference(GDALBase):
|
|||
name = force_text(name)
|
||||
return (units, name)
|
||||
|
||||
#### Spheroid/Ellipsoid Properties ####
|
||||
# #### Spheroid/Ellipsoid Properties ####
|
||||
@property
|
||||
def ellipsoid(self):
|
||||
"""
|
||||
|
@ -259,7 +258,7 @@ class SpatialReference(GDALBase):
|
|||
"Returns the Inverse Flattening for this Spatial Reference."
|
||||
return capi.invflattening(self.ptr, byref(c_int()))
|
||||
|
||||
#### Boolean Properties ####
|
||||
# #### Boolean Properties ####
|
||||
@property
|
||||
def geographic(self):
|
||||
"""
|
||||
|
@ -281,7 +280,7 @@ class SpatialReference(GDALBase):
|
|||
"""
|
||||
return bool(capi.isprojected(self.ptr))
|
||||
|
||||
#### Import Routines #####
|
||||
# #### Import Routines #####
|
||||
def import_epsg(self, epsg):
|
||||
"Imports the Spatial Reference from the EPSG code (an integer)."
|
||||
capi.from_epsg(self.ptr, epsg)
|
||||
|
@ -302,7 +301,7 @@ class SpatialReference(GDALBase):
|
|||
"Imports the Spatial Reference from an XML string."
|
||||
capi.from_xml(self.ptr, xml)
|
||||
|
||||
#### Export Properties ####
|
||||
# #### Export Properties ####
|
||||
@property
|
||||
def wkt(self):
|
||||
"Returns the WKT representation of this Spatial Reference."
|
||||
|
|
|
@ -18,7 +18,6 @@ free_regex = re.compile(r'^GEO-\d{3}FREE')
|
|||
lite_regex = re.compile(r'^GEO-\d{3}LITE')
|
||||
|
||||
|
||||
#### GeoIP classes ####
|
||||
class GeoIPException(Exception):
|
||||
pass
|
||||
|
||||
|
@ -201,7 +200,7 @@ class GeoIP(object):
|
|||
'country_name': self.country_name(query),
|
||||
}
|
||||
|
||||
#### Coordinate retrieval routines ####
|
||||
# #### Coordinate retrieval routines ####
|
||||
def coords(self, query, ordering=('longitude', 'latitude')):
|
||||
cdict = self.city(query)
|
||||
if cdict is None:
|
||||
|
@ -226,7 +225,7 @@ class GeoIP(object):
|
|||
else:
|
||||
return None
|
||||
|
||||
#### GeoIP Database Information Routines ####
|
||||
# #### GeoIP Database Information Routines ####
|
||||
@property
|
||||
def country_info(self):
|
||||
"Returns information about the GeoIP country database."
|
||||
|
@ -253,7 +252,7 @@ class GeoIP(object):
|
|||
info += 'GeoIP Library:\n\t%s\n' % GeoIP_lib_version()
|
||||
return info + 'Country:\n\t%s\nCity:\n\t%s' % (self.country_info, self.city_info)
|
||||
|
||||
#### Methods for compatibility w/the GeoIP-Python API. ####
|
||||
# #### Methods for compatibility w/the GeoIP-Python API. ####
|
||||
@classmethod
|
||||
def open(cls, full_path, cache):
|
||||
return GeoIP(full_path, cache)
|
||||
|
|
|
@ -3,7 +3,7 @@ from ctypes import POINTER, Structure, c_char_p, c_float, c_int, string_at
|
|||
from django.contrib.gis.geoip.libgeoip import free, lgeoip
|
||||
|
||||
|
||||
#### GeoIP C Structure definitions ####
|
||||
# #### GeoIP C Structure definitions ####
|
||||
|
||||
class GeoIPRecord(Structure):
|
||||
_fields_ = [('country_code', c_char_p),
|
||||
|
@ -37,7 +37,7 @@ class GeoIPTag(Structure):
|
|||
RECTYPE = POINTER(GeoIPRecord)
|
||||
DBTYPE = POINTER(GeoIPTag)
|
||||
|
||||
#### ctypes function prototypes ####
|
||||
# #### ctypes function prototypes ####
|
||||
|
||||
# GeoIP_lib_version appeared in version 1.4.7.
|
||||
if hasattr(lgeoip, 'GeoIP_lib_version'):
|
||||
|
|
|
@ -50,7 +50,7 @@ class GeometryCollection(GEOSGeometry):
|
|||
"Returns the number of geometries in this Collection."
|
||||
return self.num_geom
|
||||
|
||||
### Methods for compatibility with ListMixin ###
|
||||
# ### Methods for compatibility with ListMixin ###
|
||||
def _create_collection(self, length, items):
|
||||
# Creating the geometry pointer array.
|
||||
geoms = get_pointer_arr(length)
|
||||
|
|
|
@ -17,7 +17,6 @@ class GEOSCoordSeq(GEOSBase):
|
|||
|
||||
ptr_type = CS_PTR
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, ptr, z=False):
|
||||
"Initializes from a GEOS pointer."
|
||||
if not isinstance(ptr, CS_PTR):
|
||||
|
@ -69,7 +68,7 @@ class GEOSCoordSeq(GEOSBase):
|
|||
if set_3d:
|
||||
self.setZ(index, value[2])
|
||||
|
||||
#### Internal Routines ####
|
||||
# #### Internal Routines ####
|
||||
def _checkindex(self, index):
|
||||
"Checks the given index."
|
||||
sz = self.size
|
||||
|
@ -81,7 +80,7 @@ class GEOSCoordSeq(GEOSBase):
|
|||
if dim < 0 or dim > 2:
|
||||
raise GEOSException('invalid ordinate dimension "%d"' % dim)
|
||||
|
||||
#### Ordinate getting and setting routines ####
|
||||
# #### Ordinate getting and setting routines ####
|
||||
def getOrdinate(self, dimension, index):
|
||||
"Returns the value for the given dimension and index."
|
||||
self._checkindex(index)
|
||||
|
@ -118,7 +117,7 @@ class GEOSCoordSeq(GEOSBase):
|
|||
"Set Z with the value at the given index."
|
||||
self.setOrdinate(2, index, value)
|
||||
|
||||
### Dimensions ###
|
||||
# ### Dimensions ###
|
||||
@property
|
||||
def size(self):
|
||||
"Returns the size of this coordinate sequence."
|
||||
|
@ -137,7 +136,7 @@ class GEOSCoordSeq(GEOSBase):
|
|||
"""
|
||||
return self._z
|
||||
|
||||
### Other Methods ###
|
||||
# ### Other Methods ###
|
||||
def clone(self):
|
||||
"Clones this coordinate sequence."
|
||||
return GEOSCoordSeq(capi.cs_clone(self.ptr), self.hasz)
|
||||
|
|
|
@ -30,7 +30,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
|
||||
ptr_type = GEOM_PTR
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, geo_input, srid=None):
|
||||
"""
|
||||
The base constructor for GEOS geometry objects, and may take the
|
||||
|
@ -162,7 +161,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
"The not equals operator."
|
||||
return not (self == other)
|
||||
|
||||
### Geometry set-like operations ###
|
||||
# ### Geometry set-like operations ###
|
||||
# Thanks to Sean Gillies for inspiration:
|
||||
# http://lists.gispython.org/pipermail/community/2007-July/001034.html
|
||||
# g = g1 | g2
|
||||
|
@ -185,7 +184,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
"Return the symmetric difference of this Geometry and the other."
|
||||
return self.sym_difference(other)
|
||||
|
||||
#### Coordinate Sequence Routines ####
|
||||
# #### Coordinate Sequence Routines ####
|
||||
@property
|
||||
def has_cs(self):
|
||||
"Returns True if this Geometry has a coordinate sequence, False if not."
|
||||
|
@ -208,7 +207,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
if self.has_cs:
|
||||
return self._cs.clone()
|
||||
|
||||
#### Geometry Info ####
|
||||
# #### Geometry Info ####
|
||||
@property
|
||||
def geom_type(self):
|
||||
"Returns a string representing the Geometry type, e.g. 'Polygon'"
|
||||
|
@ -243,7 +242,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
"Converts this Geometry to normal form (or canonical form)."
|
||||
return capi.geos_normalize(self.ptr)
|
||||
|
||||
#### Unary predicates ####
|
||||
# #### Unary predicates ####
|
||||
@property
|
||||
def empty(self):
|
||||
"""
|
||||
|
@ -279,7 +278,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
"""
|
||||
return capi.geos_isvalidreason(self.ptr).decode()
|
||||
|
||||
#### Binary predicates. ####
|
||||
# #### Binary predicates. ####
|
||||
def contains(self, other):
|
||||
"Returns true if other.within(this) returns true."
|
||||
return capi.geos_contains(self.ptr, other.ptr)
|
||||
|
@ -347,7 +346,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
"""
|
||||
return capi.geos_within(self.ptr, other.ptr)
|
||||
|
||||
#### SRID Routines ####
|
||||
# #### SRID Routines ####
|
||||
def get_srid(self):
|
||||
"Gets the SRID for the geometry, returns None if no SRID is set."
|
||||
s = capi.geos_get_srid(self.ptr)
|
||||
|
@ -361,7 +360,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
capi.geos_set_srid(self.ptr, srid)
|
||||
srid = property(get_srid, set_srid)
|
||||
|
||||
#### Output Routines ####
|
||||
# #### Output Routines ####
|
||||
@property
|
||||
def ewkt(self):
|
||||
"""
|
||||
|
@ -441,7 +440,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
"""
|
||||
return PreparedGeometry(self)
|
||||
|
||||
#### GDAL-specific output routines ####
|
||||
# #### GDAL-specific output routines ####
|
||||
@property
|
||||
def ogr(self):
|
||||
"Returns the OGR Geometry for this Geometry."
|
||||
|
@ -512,7 +511,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
else:
|
||||
raise GEOSException('Transformed WKB was invalid.')
|
||||
|
||||
#### Topology Routines ####
|
||||
# #### Topology Routines ####
|
||||
def _topology(self, gptr):
|
||||
"Helper routine to return Geometry from the given pointer."
|
||||
return GEOSGeometry(gptr, srid=self.srid)
|
||||
|
@ -626,7 +625,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
|
|||
"Returns a Geometry representing all the points in this Geometry and other."
|
||||
return self._topology(capi.geos_union(self.ptr, other.ptr))
|
||||
|
||||
#### Other Routines ####
|
||||
# #### Other Routines ####
|
||||
@property
|
||||
def area(self):
|
||||
"Returns the area of the Geometry."
|
||||
|
|
|
@ -87,7 +87,7 @@ def error_h(fmt, lst):
|
|||
logger.error('GEOS_ERROR: %s\n' % err_msg)
|
||||
error_h = ERRORFUNC(error_h)
|
||||
|
||||
#### GEOS Geometry C data structures, and utility functions. ####
|
||||
# #### GEOS Geometry C data structures, and utility functions. ####
|
||||
|
||||
|
||||
# Opaque GEOS geometry structures, used for GEOM_PTR and CS_PTR
|
||||
|
|
|
@ -11,7 +11,6 @@ class LineString(GEOSGeometry):
|
|||
_init_func = capi.create_linestring
|
||||
_minlength = 2
|
||||
|
||||
#### Python 'magic' routines ####
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Initializes on the given sequence -- may take lists, tuples, NumPy arrays
|
||||
|
@ -116,7 +115,7 @@ class LineString(GEOSGeometry):
|
|||
if dim not in (2, 3):
|
||||
raise TypeError('Dimension mismatch.')
|
||||
|
||||
#### Sequence Properties ####
|
||||
# #### Sequence Properties ####
|
||||
@property
|
||||
def tuple(self):
|
||||
"Returns a tuple version of the geometry from the coordinate sequence."
|
||||
|
|
|
@ -63,7 +63,7 @@ class ListMixin(object):
|
|||
_maxlength = None
|
||||
_IndexError = IndexError
|
||||
|
||||
### Python initialization and special list interface methods ###
|
||||
# ### Python initialization and special list interface methods ###
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if not hasattr(self, '_get_single_internal'):
|
||||
|
@ -117,7 +117,7 @@ class ListMixin(object):
|
|||
for i in range(len(self)):
|
||||
yield self[i]
|
||||
|
||||
### Special methods for arithmetic operations ###
|
||||
# ### Special methods for arithmetic operations ###
|
||||
def __add__(self, other):
|
||||
'add another list-like object'
|
||||
return self.__class__(list(self) + list(other))
|
||||
|
@ -175,8 +175,8 @@ class ListMixin(object):
|
|||
return False
|
||||
return len(self) < olen
|
||||
|
||||
### Public list interface Methods ###
|
||||
## Non-mutating ##
|
||||
# ### Public list interface Methods ###
|
||||
# ## Non-mutating ##
|
||||
def count(self, val):
|
||||
"Standard list count method"
|
||||
count = 0
|
||||
|
@ -192,7 +192,7 @@ class ListMixin(object):
|
|||
return i
|
||||
raise ValueError('%s not found in object' % str(val))
|
||||
|
||||
## Mutating ##
|
||||
# ## Mutating ##
|
||||
def append(self, val):
|
||||
"Standard list append method"
|
||||
self[len(self):] = [val]
|
||||
|
@ -235,7 +235,7 @@ class ListMixin(object):
|
|||
temp.sort(reverse=reverse)
|
||||
self[:] = temp
|
||||
|
||||
### Private routines ###
|
||||
# ### Private routines ###
|
||||
def _rebuild(self, newLen, newItems):
|
||||
if newLen < self._minlength:
|
||||
raise ValueError('Must have at least %d items' % self._minlength)
|
||||
|
|
|
@ -129,7 +129,7 @@ class Point(GEOSGeometry):
|
|||
y = property(get_y, set_y)
|
||||
z = property(get_z, set_z)
|
||||
|
||||
### Tuple setting and retrieval routines. ###
|
||||
# ### Tuple setting and retrieval routines. ###
|
||||
def get_coords(self):
|
||||
"Returns a tuple of the point."
|
||||
return self._cs.tuple
|
||||
|
|
|
@ -67,7 +67,7 @@ class Polygon(GEOSGeometry):
|
|||
(x0, y0, x0, y1, x1, y1, x1, y0, x0, y0))
|
||||
return Polygon(((x0, y0), (x0, y1), (x1, y1), (x1, y0), (x0, y0)))
|
||||
|
||||
### These routines are needed for list-like operation w/ListMixin ###
|
||||
# ### These routines are needed for list-like operation w/ListMixin ###
|
||||
def _create_polygon(self, length, items):
|
||||
# Instantiate LinearRing objects if necessary, but don't clone them yet
|
||||
# _construct_ring will throw a TypeError if a parameter isn't a valid ring
|
||||
|
@ -144,7 +144,7 @@ class Polygon(GEOSGeometry):
|
|||
_set_single = GEOSGeometry._set_single_rebuild
|
||||
_assign_extended_slice = GEOSGeometry._assign_extended_slice_rebuild
|
||||
|
||||
#### Polygon Properties ####
|
||||
# #### Polygon Properties ####
|
||||
@property
|
||||
def num_interior_rings(self):
|
||||
"Returns the number of interior rings."
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.contrib.gis.geos.prototypes.errcheck import (
|
|||
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
|
||||
|
||||
|
||||
## Error-checking routines specific to coordinate sequences. ##
|
||||
# ## Error-checking routines specific to coordinate sequences. ##
|
||||
def check_cs_ptr(result, func, cargs):
|
||||
"Error checking on routines that return Geometries."
|
||||
if not result:
|
||||
|
@ -33,7 +33,7 @@ def check_cs_get(result, func, cargs):
|
|||
return last_arg_byref(cargs)
|
||||
|
||||
|
||||
## Coordinate sequence prototype generation functions. ##
|
||||
# ## Coordinate sequence prototype generation functions. ##
|
||||
def cs_int(func):
|
||||
"For coordinate sequence routines that return an integer."
|
||||
func.argtypes = [CS_PTR, POINTER(c_uint)]
|
||||
|
@ -69,7 +69,7 @@ def cs_output(func, argtypes):
|
|||
func.errcheck = check_cs_ptr
|
||||
return func
|
||||
|
||||
## Coordinate Sequence ctypes prototypes ##
|
||||
# ## Coordinate Sequence ctypes prototypes ##
|
||||
|
||||
# Coordinate Sequence constructors & cloning.
|
||||
cs_clone = cs_output(GEOSFunc('GEOSCoordSeq_clone'), [CS_PTR])
|
||||
|
|
|
@ -13,7 +13,6 @@ free.argtypes = [c_void_p]
|
|||
free.restype = None
|
||||
|
||||
|
||||
### ctypes error checking routines ###
|
||||
def last_arg_byref(args):
|
||||
"Returns the last C argument's value by reference."
|
||||
return args[-1]._obj.value
|
||||
|
|
|
@ -21,7 +21,7 @@ class geos_char_p(c_char_p):
|
|||
pass
|
||||
|
||||
|
||||
### ctypes generation functions ###
|
||||
# ### ctypes generation functions ###
|
||||
def bin_constructor(func):
|
||||
"Generates a prototype for binary construction (HEX, WKB) GEOS routines."
|
||||
func.argtypes = [c_char_p, c_size_t]
|
||||
|
@ -71,7 +71,7 @@ def string_from_geom(func):
|
|||
func.errcheck = check_string
|
||||
return func
|
||||
|
||||
### ctypes prototypes ###
|
||||
# ### ctypes prototypes ###
|
||||
|
||||
# Deprecated creation routines from WKB, HEX, WKT
|
||||
from_hex = bin_constructor(GEOSFunc('GEOSGeomFromHEX_buf'))
|
||||
|
|
|
@ -12,7 +12,7 @@ from django.utils import six
|
|||
from django.utils.encoding import force_bytes
|
||||
|
||||
|
||||
### The WKB/WKT Reader/Writer structures and pointers ###
|
||||
# ### The WKB/WKT Reader/Writer structures and pointers ###
|
||||
class WKTReader_st(Structure):
|
||||
pass
|
||||
|
||||
|
@ -33,7 +33,7 @@ WKT_WRITE_PTR = POINTER(WKTWriter_st)
|
|||
WKB_READ_PTR = POINTER(WKBReader_st)
|
||||
WKB_WRITE_PTR = POINTER(WKBReader_st)
|
||||
|
||||
### WKTReader routines ###
|
||||
# WKTReader routines
|
||||
wkt_reader_create = GEOSFunc('GEOSWKTReader_create')
|
||||
wkt_reader_create.restype = WKT_READ_PTR
|
||||
|
||||
|
@ -45,7 +45,7 @@ wkt_reader_read.argtypes = [WKT_READ_PTR, c_char_p]
|
|||
wkt_reader_read.restype = GEOM_PTR
|
||||
wkt_reader_read.errcheck = check_geom
|
||||
|
||||
### WKTWriter routines ###
|
||||
# WKTWriter routines
|
||||
wkt_writer_create = GEOSFunc('GEOSWKTWriter_create')
|
||||
wkt_writer_create.restype = WKT_WRITE_PTR
|
||||
|
||||
|
@ -69,7 +69,7 @@ except AttributeError:
|
|||
wkt_writer_get_outdim = lambda ptr: 2
|
||||
wkt_writer_set_outdim = lambda ptr, dim: None
|
||||
|
||||
### WKBReader routines ###
|
||||
# WKBReader routines
|
||||
wkb_reader_create = GEOSFunc('GEOSWKBReader_create')
|
||||
wkb_reader_create.restype = WKB_READ_PTR
|
||||
|
||||
|
@ -91,7 +91,7 @@ def wkb_read_func(func):
|
|||
wkb_reader_read = wkb_read_func(GEOSFunc('GEOSWKBReader_read'))
|
||||
wkb_reader_read_hex = wkb_read_func(GEOSFunc('GEOSWKBReader_readHEX'))
|
||||
|
||||
### WKBWriter routines ###
|
||||
# WKBWriter routines
|
||||
wkb_writer_create = GEOSFunc('GEOSWKBWriter_create')
|
||||
wkb_writer_create.restype = WKB_WRITE_PTR
|
||||
|
||||
|
@ -129,7 +129,7 @@ wkb_writer_get_include_srid = wkb_writer_get(GEOSFunc('GEOSWKBWriter_getIncludeS
|
|||
wkb_writer_set_include_srid = wkb_writer_set(GEOSFunc('GEOSWKBWriter_setIncludeSRID'), argtype=c_char)
|
||||
|
||||
|
||||
### Base I/O Class ###
|
||||
# ### Base I/O Class ###
|
||||
class IOBase(GEOSBase):
|
||||
"Base class for GEOS I/O objects."
|
||||
def __init__(self):
|
||||
|
@ -141,7 +141,7 @@ class IOBase(GEOSBase):
|
|||
if self._ptr:
|
||||
self._destructor(self._ptr)
|
||||
|
||||
### Base WKB/WKT Reading and Writing objects ###
|
||||
# ### Base WKB/WKT Reading and Writing objects ###
|
||||
|
||||
|
||||
# Non-public WKB/WKT reader classes for internal use because
|
||||
|
@ -174,7 +174,7 @@ class _WKBReader(IOBase):
|
|||
raise TypeError
|
||||
|
||||
|
||||
### WKB/WKT Writer Classes ###
|
||||
# ### WKB/WKT Writer Classes ###
|
||||
class WKTWriter(IOBase):
|
||||
_constructor = wkt_writer_create
|
||||
_destructor = wkt_writer_destroy
|
||||
|
@ -208,7 +208,7 @@ class WKBWriter(IOBase):
|
|||
"Returns the HEXEWKB representation of the given geometry."
|
||||
return wkb_writer_write_hex(self.ptr, geom.ptr, byref(c_size_t()))
|
||||
|
||||
### WKBWriter Properties ###
|
||||
# ### WKBWriter Properties ###
|
||||
|
||||
# Property for getting/setting the byteorder.
|
||||
def _get_byteorder(self):
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.utils.six.moves import range
|
|||
__all__ = ['geos_area', 'geos_distance', 'geos_length', 'geos_isvalidreason']
|
||||
|
||||
|
||||
### ctypes generator function ###
|
||||
# ### ctypes generator function ###
|
||||
def dbl_from_geom(func, num_geom=1):
|
||||
"""
|
||||
Argument is a Geometry, return type is double that is passed
|
||||
|
@ -26,7 +26,7 @@ def dbl_from_geom(func, num_geom=1):
|
|||
func.errcheck = check_dbl
|
||||
return func
|
||||
|
||||
### ctypes prototypes ###
|
||||
# ### ctypes prototypes ###
|
||||
|
||||
# Area, distance, and length prototypes.
|
||||
geos_area = dbl_from_geom(GEOSFunc('GEOSArea'))
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.contrib.gis.geos.prototypes.errcheck import check_predicate
|
|||
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
|
||||
|
||||
|
||||
## Binary & unary predicate functions ##
|
||||
# ## Binary & unary predicate functions ##
|
||||
def binary_predicate(func, *args):
|
||||
"For GEOS binary predicate functions."
|
||||
argtypes = [GEOM_PTR, GEOM_PTR]
|
||||
|
@ -28,14 +28,14 @@ def unary_predicate(func):
|
|||
func.errcheck = check_predicate
|
||||
return func
|
||||
|
||||
## Unary Predicates ##
|
||||
# ## Unary Predicates ##
|
||||
geos_hasz = unary_predicate(GEOSFunc('GEOSHasZ'))
|
||||
geos_isempty = unary_predicate(GEOSFunc('GEOSisEmpty'))
|
||||
geos_isring = unary_predicate(GEOSFunc('GEOSisRing'))
|
||||
geos_issimple = unary_predicate(GEOSFunc('GEOSisSimple'))
|
||||
geos_isvalid = unary_predicate(GEOSFunc('GEOSisValid'))
|
||||
|
||||
## Binary Predicates ##
|
||||
# ## Binary Predicates ##
|
||||
geos_contains = binary_predicate(GEOSFunc('GEOSContains'))
|
||||
geos_crosses = binary_predicate(GEOSFunc('GEOSCrosses'))
|
||||
geos_disjoint = binary_predicate(GEOSFunc('GEOSDisjoint'))
|
||||
|
|
|
@ -30,7 +30,7 @@ def topology(func, *args, **kwargs):
|
|||
func.errcheck = kwargs.get('errcheck', check_geom)
|
||||
return func
|
||||
|
||||
### Topology Routines ###
|
||||
# Topology Routines
|
||||
geos_boundary = topology(GEOSFunc('GEOSBoundary'))
|
||||
geos_buffer = topology(GEOSFunc('GEOSBuffer'), c_double, c_int)
|
||||
geos_centroid = topology(GEOSFunc('GEOSGetCentroid'))
|
||||
|
|
|
@ -464,7 +464,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
|||
|
||||
def test_memory_hijinks(self):
|
||||
"Testing Geometry __del__() on rings and polygons."
|
||||
#### Memory issues with rings and polygons
|
||||
# #### Memory issues with rings and poly
|
||||
|
||||
# These tests are needed to ensure sanity with writable geometries.
|
||||
|
||||
|
@ -659,7 +659,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
|||
|
||||
def test_mutable_geometries(self):
|
||||
"Testing the mutability of Polygons and Geometry Collections."
|
||||
### Testing the mutability of Polygons ###
|
||||
# ### Testing the mutability of Polygons ###
|
||||
for p in self.geometries.polygons:
|
||||
poly = fromstr(p.wkt)
|
||||
|
||||
|
@ -679,7 +679,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
|||
self.assertEqual(poly.exterior_ring, new_shell)
|
||||
self.assertEqual(poly[0], new_shell)
|
||||
|
||||
### Testing the mutability of Geometry Collections
|
||||
# ### Testing the mutability of Geometry Collections
|
||||
for tg in self.geometries.multipoints:
|
||||
mp = fromstr(tg.wkt)
|
||||
for i in range(len(mp)):
|
||||
|
|
|
@ -39,7 +39,7 @@ class GeoModelTest(TestCase):
|
|||
|
||||
def test_proxy(self):
|
||||
"Testing Lazy-Geometry support (using the GeometryProxy)."
|
||||
## Testing on a Point
|
||||
# Testing on a Point
|
||||
pnt = Point(0, 0)
|
||||
nullcity = City(name='NullCity', point=pnt)
|
||||
nullcity.save()
|
||||
|
@ -76,7 +76,7 @@ class GeoModelTest(TestCase):
|
|||
self.assertEqual(Point(23, 5), City.objects.get(name='NullCity').point)
|
||||
nullcity.delete()
|
||||
|
||||
## Testing on a Polygon
|
||||
# Testing on a Polygon
|
||||
shell = LinearRing((0, 0), (0, 100), (100, 100), (100, 0), (0, 0))
|
||||
inner = LinearRing((40, 40), (40, 60), (60, 60), (60, 40), (40, 40))
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ class LayerMapping(object):
|
|||
else:
|
||||
raise LayerMapError('Unrecognized transaction mode: %s' % transaction_mode)
|
||||
|
||||
#### Checking routines used during initialization ####
|
||||
# #### Checking routines used during initialization ####
|
||||
def check_fid_range(self, fid_range):
|
||||
"This checks the `fid_range` keyword."
|
||||
if fid_range:
|
||||
|
@ -334,7 +334,7 @@ class LayerMapping(object):
|
|||
else:
|
||||
return {fld: kwargs[fld] for fld in self.unique}
|
||||
|
||||
#### Verification routines used in constructing model keyword arguments. ####
|
||||
# #### Verification routines used in constructing model keyword arguments. ####
|
||||
def verify_ogr_field(self, ogr_field, model_field):
|
||||
"""
|
||||
Verifies if the OGR Field contents are acceptable to the Django
|
||||
|
@ -444,7 +444,7 @@ class LayerMapping(object):
|
|||
# Returning the WKT of the geometry.
|
||||
return g.wkt
|
||||
|
||||
#### Other model methods ####
|
||||
# #### Other model methods ####
|
||||
def coord_transform(self):
|
||||
"Returns the coordinate transformation object."
|
||||
SpatialRefSys = self.spatial_backend.spatial_ref_sys()
|
||||
|
|
|
@ -83,7 +83,7 @@ class BaseDatabaseWrapper(object):
|
|||
"will be returned.".format(self.queries_log.maxlen))
|
||||
return list(self.queries_log)
|
||||
|
||||
##### Backend-specific methods for creating connections and cursors #####
|
||||
# ##### Backend-specific methods for creating connections and cursors #####
|
||||
|
||||
def get_connection_params(self):
|
||||
"""Returns a dict of parameters suitable for get_new_connection."""
|
||||
|
@ -101,7 +101,7 @@ class BaseDatabaseWrapper(object):
|
|||
"""Creates a cursor. Assumes that a connection is established."""
|
||||
raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a create_cursor() method')
|
||||
|
||||
##### Backend-specific methods for creating connections #####
|
||||
# ##### Backend-specific methods for creating connections #####
|
||||
|
||||
def connect(self):
|
||||
"""Connects to the database. Assumes that the connection is closed."""
|
||||
|
@ -129,7 +129,7 @@ class BaseDatabaseWrapper(object):
|
|||
with self.wrap_database_errors:
|
||||
self.connect()
|
||||
|
||||
##### Backend-specific wrappers for PEP-249 connection methods #####
|
||||
# ##### Backend-specific wrappers for PEP-249 connection methods #####
|
||||
|
||||
def _cursor(self):
|
||||
self.ensure_connection()
|
||||
|
@ -151,7 +151,7 @@ class BaseDatabaseWrapper(object):
|
|||
with self.wrap_database_errors:
|
||||
return self.connection.close()
|
||||
|
||||
##### Generic wrappers for PEP-249 connection methods #####
|
||||
# ##### Generic wrappers for PEP-249 connection methods #####
|
||||
|
||||
def cursor(self):
|
||||
"""
|
||||
|
@ -203,7 +203,7 @@ class BaseDatabaseWrapper(object):
|
|||
else:
|
||||
self.connection = None
|
||||
|
||||
##### Backend-specific savepoint management methods #####
|
||||
# ##### Backend-specific savepoint management methods #####
|
||||
|
||||
def _savepoint(self, sid):
|
||||
with self.cursor() as cursor:
|
||||
|
@ -221,7 +221,7 @@ class BaseDatabaseWrapper(object):
|
|||
# Savepoints cannot be created outside a transaction
|
||||
return self.features.uses_savepoints and not self.get_autocommit()
|
||||
|
||||
##### Generic savepoint management methods #####
|
||||
# ##### Generic savepoint management methods #####
|
||||
|
||||
def savepoint(self):
|
||||
"""
|
||||
|
@ -269,7 +269,7 @@ class BaseDatabaseWrapper(object):
|
|||
"""
|
||||
self.savepoint_state = 0
|
||||
|
||||
##### Backend-specific transaction management methods #####
|
||||
# ##### Backend-specific transaction management methods #####
|
||||
|
||||
def _set_autocommit(self, autocommit):
|
||||
"""
|
||||
|
@ -277,7 +277,7 @@ class BaseDatabaseWrapper(object):
|
|||
"""
|
||||
raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a _set_autocommit() method')
|
||||
|
||||
##### Generic transaction management methods #####
|
||||
# ##### Generic transaction management methods #####
|
||||
|
||||
def get_autocommit(self):
|
||||
"""
|
||||
|
@ -327,7 +327,7 @@ class BaseDatabaseWrapper(object):
|
|||
"An error occurred in the current transaction. You can't "
|
||||
"execute queries until the end of the 'atomic' block.")
|
||||
|
||||
##### Foreign key constraints checks handling #####
|
||||
# ##### Foreign key constraints checks handling #####
|
||||
|
||||
@contextmanager
|
||||
def constraint_checks_disabled(self):
|
||||
|
@ -364,7 +364,7 @@ class BaseDatabaseWrapper(object):
|
|||
"""
|
||||
pass
|
||||
|
||||
##### Connection termination handling #####
|
||||
# ##### Connection termination handling #####
|
||||
|
||||
def is_usable(self):
|
||||
"""
|
||||
|
@ -403,7 +403,7 @@ class BaseDatabaseWrapper(object):
|
|||
self.close()
|
||||
return
|
||||
|
||||
##### Thread safety handling #####
|
||||
# ##### Thread safety handling #####
|
||||
|
||||
def validate_thread_sharing(self):
|
||||
"""
|
||||
|
@ -420,7 +420,7 @@ class BaseDatabaseWrapper(object):
|
|||
"thread id %s."
|
||||
% (self.alias, self._thread_ident, thread.get_ident()))
|
||||
|
||||
##### Miscellaneous #####
|
||||
# ##### Miscellaneous #####
|
||||
|
||||
def prepare_database(self):
|
||||
"""
|
||||
|
|
|
@ -39,7 +39,7 @@ Shared:
|
|||
|
||||
"""
|
||||
|
||||
### Multiple Template Engines
|
||||
# Multiple Template Engines
|
||||
|
||||
from .engine import Engine
|
||||
|
||||
|
@ -51,7 +51,7 @@ engines = EngineHandler()
|
|||
__all__ = ('Engine', 'engines')
|
||||
|
||||
|
||||
### Django Template Language
|
||||
# Django Template Language
|
||||
|
||||
# Public exceptions
|
||||
from .base import (TemplateDoesNotExist, TemplateSyntaxError, # NOQA
|
||||
|
|
|
@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
|
|||
|
||||
[flake8]
|
||||
exclude=build,.git,./django/utils/lru_cache.py,./django/utils/six.py,./django/conf/app_template/*,./django/dispatch/weakref_backports.py,./tests/.env,./xmlrunner
|
||||
ignore=E123,E128,E265,E501,W601
|
||||
ignore=E123,E128,E501,W601
|
||||
max-line-length = 119
|
||||
|
||||
[isort]
|
||||
|
|
|
@ -467,7 +467,7 @@ class EscapingChecks(TestCase):
|
|||
@unittest.skipUnless(connection.vendor == 'sqlite',
|
||||
"This is an sqlite-specific issue")
|
||||
def test_sqlite_parameter_escaping(self):
|
||||
#13648: '%s' escaping support for sqlite3
|
||||
# '%s' escaping support for sqlite3 #13648
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("select strftime('%s', date('now'))")
|
||||
response = cursor.fetchall()[0][0]
|
||||
|
@ -505,7 +505,7 @@ class BackendTestCase(TransactionTestCase):
|
|||
cursor.execute(query, args)
|
||||
|
||||
def test_cursor_executemany(self):
|
||||
#4896: Test cursor.executemany
|
||||
# Test cursor.executemany #4896
|
||||
args = [(i, i ** 2) for i in range(-5, 6)]
|
||||
self.create_squares_with_executemany(args)
|
||||
self.assertEqual(models.Square.objects.count(), 11)
|
||||
|
@ -514,13 +514,13 @@ class BackendTestCase(TransactionTestCase):
|
|||
self.assertEqual(square.square, i ** 2)
|
||||
|
||||
def test_cursor_executemany_with_empty_params_list(self):
|
||||
#4765: executemany with params=[] does nothing
|
||||
# Test executemany with params=[] does nothing #4765
|
||||
args = []
|
||||
self.create_squares_with_executemany(args)
|
||||
self.assertEqual(models.Square.objects.count(), 0)
|
||||
|
||||
def test_cursor_executemany_with_iterator(self):
|
||||
#10320: executemany accepts iterators
|
||||
# Test executemany accepts iterators #10320
|
||||
args = iter((i, i ** 2) for i in range(-3, 2))
|
||||
self.create_squares_with_executemany(args)
|
||||
self.assertEqual(models.Square.objects.count(), 5)
|
||||
|
@ -533,14 +533,14 @@ class BackendTestCase(TransactionTestCase):
|
|||
|
||||
@skipUnlessDBFeature('supports_paramstyle_pyformat')
|
||||
def test_cursor_execute_with_pyformat(self):
|
||||
#10070: Support pyformat style passing of parameters
|
||||
# Support pyformat style passing of parameters #10070
|
||||
args = {'root': 3, 'square': 9}
|
||||
self.create_squares(args, 'pyformat', multiple=False)
|
||||
self.assertEqual(models.Square.objects.count(), 1)
|
||||
|
||||
@skipUnlessDBFeature('supports_paramstyle_pyformat')
|
||||
def test_cursor_executemany_with_pyformat(self):
|
||||
#10070: Support pyformat style passing of parameters
|
||||
# Support pyformat style passing of parameters #10070
|
||||
args = [{'root': i, 'square': i ** 2} for i in range(-5, 6)]
|
||||
self.create_squares(args, 'pyformat', multiple=True)
|
||||
self.assertEqual(models.Square.objects.count(), 11)
|
||||
|
@ -561,7 +561,7 @@ class BackendTestCase(TransactionTestCase):
|
|||
self.assertEqual(models.Square.objects.count(), 9)
|
||||
|
||||
def test_unicode_fetches(self):
|
||||
#6254: fetchone, fetchmany, fetchall return strings as unicode objects
|
||||
# fetchone, fetchmany, fetchall return strings as unicode objects #6254
|
||||
qn = connection.ops.quote_name
|
||||
models.Person(first_name="John", last_name="Doe").save()
|
||||
models.Person(first_name="Jane", last_name="Doe").save()
|
||||
|
|
|
@ -30,7 +30,7 @@ class IntrospectionTests(TransactionTestCase):
|
|||
"django_table_names() returned a non-Django table")
|
||||
|
||||
def test_django_table_names_retval_type(self):
|
||||
#15216 - Table name is a list
|
||||
# Table name is a list #15216
|
||||
tl = connection.introspection.django_table_names(only_existing=True)
|
||||
self.assertIs(type(tl), list)
|
||||
tl = connection.introspection.django_table_names(only_existing=False)
|
||||
|
|
|
@ -360,7 +360,7 @@ class MakeMigrationsTests(MigrationTestBase):
|
|||
self.assertIn('\\u201c\\xd0j\\xe1\\xf1g\\xf3\\u201d', content) # title.default
|
||||
|
||||
def test_failing_migration(self):
|
||||
#21280 - If a migration fails to serialize, it shouldn't generate an empty file.
|
||||
# If a migration fails to serialize, it shouldn't generate an empty file. #21280
|
||||
apps.register_model('migrations', UnserializableModel)
|
||||
|
||||
with six.assertRaisesRegex(self, ValueError, r'Cannot serialize'):
|
||||
|
|
|
@ -28,7 +28,7 @@ class Article(models.Model):
|
|||
|
||||
|
||||
class Movie(models.Model):
|
||||
#5218: Test models with non-default primary keys / AutoFields
|
||||
# Test models with non-default primary keys / AutoFields #5218
|
||||
movie_id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=60)
|
||||
|
||||
|
@ -72,7 +72,7 @@ class NonAutoPK(models.Model):
|
|||
name = models.CharField(max_length=10, primary_key=True)
|
||||
|
||||
|
||||
#18432: Chained foreign keys with to_field produce incorrect query
|
||||
# Chained foreign keys with to_field produce incorrect query #18432
|
||||
class Model1(models.Model):
|
||||
pkey = models.IntegerField(unique=True, db_index=True)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.db import models
|
|||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
|
||||
## Basic tests
|
||||
# Basic tests
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Author(models.Model):
|
||||
|
@ -88,7 +88,7 @@ class BookReview(models.Model):
|
|||
notes = models.TextField(null=True, blank=True)
|
||||
|
||||
|
||||
## Models for default manager tests
|
||||
# Models for default manager tests
|
||||
|
||||
class Qualification(models.Model):
|
||||
name = models.CharField(max_length=10)
|
||||
|
@ -124,7 +124,7 @@ class Department(models.Model):
|
|||
ordering = ['id']
|
||||
|
||||
|
||||
## GenericRelation/GenericForeignKey tests
|
||||
# GenericRelation/GenericForeignKey tests
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class TaggedItem(models.Model):
|
||||
|
@ -172,7 +172,7 @@ class Comment(models.Model):
|
|||
ordering = ['id']
|
||||
|
||||
|
||||
## Models for lookup ordering tests
|
||||
# Models for lookup ordering tests
|
||||
|
||||
class House(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
|
@ -209,7 +209,7 @@ class Person(models.Model):
|
|||
ordering = ['id']
|
||||
|
||||
|
||||
## Models for nullable FK tests
|
||||
# Models for nullable FK tests
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Employee(models.Model):
|
||||
|
@ -224,7 +224,7 @@ class Employee(models.Model):
|
|||
ordering = ['id']
|
||||
|
||||
|
||||
## Ticket #19607
|
||||
# Ticket #19607
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class LessonEntry(models.Model):
|
||||
|
@ -244,7 +244,7 @@ class WordEntry(models.Model):
|
|||
return "%s (%s)" % (self.name, self.id)
|
||||
|
||||
|
||||
## Ticket #21410: Regression when related_name="+"
|
||||
# Ticket #21410: Regression when related_name="+"
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Author2(models.Model):
|
||||
|
|
|
@ -93,7 +93,6 @@ class SyndicationFeedTest(FeedTestCase):
|
|||
'link': 'http://example.com/blog/',
|
||||
'language': 'en',
|
||||
'lastBuildDate': last_build_date,
|
||||
#'atom:link': '',
|
||||
'ttl': '600',
|
||||
'copyright': 'Copyright (c) 2007, Sally Smith',
|
||||
})
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#from django.conf.urls import patterns, url, include
|
Loading…
Reference in New Issue