mirror of
https://github.com/django/django.git
synced 2025-03-06 07:22:32 +00:00
[5.2.x] Applied Black's 2025 stable style.
https://github.com/psf/black/releases/tag/25.1.0 Backport of ff3aaf036f0cb66cd8f404cd51c603e68aaa7676 from main
This commit is contained in:
parent
b8ceda4a51
commit
53bb1d5a24
@ -1,15 +1,15 @@
|
||||
repos:
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 24.10.0
|
||||
rev: 25.1.0
|
||||
hooks:
|
||||
- id: black
|
||||
exclude: \.py-tpl$
|
||||
- repo: https://github.com/adamchainz/blacken-docs
|
||||
rev: 1.19.0
|
||||
rev: 1.19.1
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
additional_dependencies:
|
||||
- black==24.10.0
|
||||
- black==25.1.0
|
||||
files: 'docs/.*\.txt$'
|
||||
args: ["--rst-literal-block"]
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
|
@ -1,11 +1,11 @@
|
||||
"""
|
||||
The GeometryColumns and SpatialRefSys models for the Oracle spatial
|
||||
backend.
|
||||
The GeometryColumns and SpatialRefSys models for the Oracle spatial
|
||||
backend.
|
||||
|
||||
It should be noted that Oracle Spatial does not have database tables
|
||||
named according to the OGC standard, so the closest analogs are used.
|
||||
For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns
|
||||
model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model.
|
||||
It should be noted that Oracle Spatial does not have database tables
|
||||
named according to the OGC standard, so the closest analogs are used.
|
||||
For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns
|
||||
model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model.
|
||||
"""
|
||||
|
||||
from django.contrib.gis.db import models
|
||||
@ -14,6 +14,7 @@ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
|
||||
|
||||
class OracleGeometryColumns(models.Model):
|
||||
"Maps to the Oracle USER_SDO_GEOM_METADATA table."
|
||||
|
||||
table_name = models.CharField(max_length=32)
|
||||
column_name = models.CharField(max_length=1024)
|
||||
srid = models.IntegerField(primary_key=True)
|
||||
@ -46,6 +47,7 @@ class OracleGeometryColumns(models.Model):
|
||||
|
||||
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||
"Maps to the Oracle MDSYS.CS_SRS table."
|
||||
|
||||
cs_name = models.CharField(max_length=68)
|
||||
srid = models.IntegerField(primary_key=True)
|
||||
auth_srid = models.IntegerField()
|
||||
|
@ -1,11 +1,11 @@
|
||||
"""
|
||||
This module contains the spatial lookup types, and the `get_geo_where_clause`
|
||||
routine for Oracle Spatial.
|
||||
This module contains the spatial lookup types, and the `get_geo_where_clause`
|
||||
routine for Oracle Spatial.
|
||||
|
||||
Please note that WKT support is broken on the XE version, and thus
|
||||
this backend will not work on such platforms. Specifically, XE lacks
|
||||
support for an internal JVM, and Java libraries are required to use
|
||||
the WKT constructors.
|
||||
Please note that WKT support is broken on the XE version, and thus
|
||||
this backend will not work on such platforms. Specifically, XE lacks
|
||||
support for an internal JVM, and Java libraries are required to use
|
||||
the WKT constructors.
|
||||
"""
|
||||
|
||||
import re
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
|
||||
This object provides quoting for GEOS geometries into PostgreSQL/PostGIS.
|
||||
"""
|
||||
|
||||
from django.contrib.gis.db.backends.postgis.pgraster import to_pgraster
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
The GeometryColumns and SpatialRefSys models for the PostGIS backend.
|
||||
The GeometryColumns and SpatialRefSys models for the PostGIS backend.
|
||||
"""
|
||||
|
||||
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
The GeometryColumns and SpatialRefSys models for the SpatiaLite backend.
|
||||
The GeometryColumns and SpatialRefSys models for the SpatiaLite backend.
|
||||
"""
|
||||
|
||||
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
|
||||
|
@ -1,29 +1,29 @@
|
||||
"""
|
||||
This module houses ctypes interfaces for GDAL objects. The following GDAL
|
||||
objects are supported:
|
||||
This module houses ctypes interfaces for GDAL objects. The following GDAL
|
||||
objects are supported:
|
||||
|
||||
CoordTransform: Used for coordinate transformations from one spatial
|
||||
reference system to another.
|
||||
CoordTransform: Used for coordinate transformations from one spatial
|
||||
reference system to another.
|
||||
|
||||
Driver: Wraps an OGR data source driver.
|
||||
Driver: Wraps an OGR data source driver.
|
||||
|
||||
DataSource: Wrapper for the OGR data source object, supports
|
||||
OGR-supported data sources.
|
||||
DataSource: Wrapper for the OGR data source object, supports
|
||||
OGR-supported data sources.
|
||||
|
||||
Envelope: A ctypes structure for bounding boxes (GDAL library
|
||||
not required).
|
||||
Envelope: A ctypes structure for bounding boxes (GDAL library
|
||||
not required).
|
||||
|
||||
OGRGeometry: Object for accessing OGR Geometry functionality.
|
||||
OGRGeometry: Object for accessing OGR Geometry functionality.
|
||||
|
||||
OGRGeomType: A class for representing the different OGR Geometry
|
||||
types (GDAL library not required).
|
||||
OGRGeomType: A class for representing the different OGR Geometry
|
||||
types (GDAL library not required).
|
||||
|
||||
SpatialReference: Represents OSR Spatial Reference objects.
|
||||
SpatialReference: Represents OSR Spatial Reference objects.
|
||||
|
||||
The GDAL library will be imported from the system path using the default
|
||||
library name for the current OS. The default library path may be overridden
|
||||
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
|
||||
library on your system.
|
||||
The GDAL library will be imported from the system path using the default
|
||||
library name for the current OS. The default library path may be overridden
|
||||
by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C
|
||||
library on your system.
|
||||
"""
|
||||
|
||||
from django.contrib.gis.gdal.datasource import DataSource
|
||||
|
@ -1,37 +1,37 @@
|
||||
"""
|
||||
DataSource is a wrapper for the OGR Data Source object, which provides
|
||||
an interface for reading vector geometry data from many different file
|
||||
formats (including ESRI shapefiles).
|
||||
DataSource is a wrapper for the OGR Data Source object, which provides
|
||||
an interface for reading vector geometry data from many different file
|
||||
formats (including ESRI shapefiles).
|
||||
|
||||
When instantiating a DataSource object, use the filename of a
|
||||
GDAL-supported data source. For example, a SHP file or a
|
||||
TIGER/Line file from the government.
|
||||
When instantiating a DataSource object, use the filename of a
|
||||
GDAL-supported data source. For example, a SHP file or a
|
||||
TIGER/Line file from the government.
|
||||
|
||||
The ds_driver keyword is used internally when a ctypes pointer
|
||||
is passed in directly.
|
||||
The ds_driver keyword is used internally when a ctypes pointer
|
||||
is passed in directly.
|
||||
|
||||
Example:
|
||||
ds = DataSource('/home/foo/bar.shp')
|
||||
for layer in ds:
|
||||
for feature in layer:
|
||||
# Getting the geometry for the feature.
|
||||
g = feature.geom
|
||||
Example:
|
||||
ds = DataSource('/home/foo/bar.shp')
|
||||
for layer in ds:
|
||||
for feature in layer:
|
||||
# Getting the geometry for the feature.
|
||||
g = feature.geom
|
||||
|
||||
# Getting the 'description' field for the feature.
|
||||
desc = feature['description']
|
||||
# Getting the 'description' field for the feature.
|
||||
desc = feature['description']
|
||||
|
||||
# We can also increment through all of the fields
|
||||
# attached to this feature.
|
||||
for field in feature:
|
||||
# Get the name of the field (e.g. 'description')
|
||||
nm = field.name
|
||||
# We can also increment through all of the fields
|
||||
# attached to this feature.
|
||||
for field in feature:
|
||||
# Get the name of the field (e.g. 'description')
|
||||
nm = field.name
|
||||
|
||||
# Get the type (integer) of the field, e.g. 0 => OFTInteger
|
||||
t = field.type
|
||||
# Get the type (integer) of the field, e.g. 0 => OFTInteger
|
||||
t = field.type
|
||||
|
||||
# Returns the value the field; OFTIntegers return ints,
|
||||
# OFTReal returns floats, all else returns string.
|
||||
val = field.value
|
||||
# Returns the value the field; OFTIntegers return ints,
|
||||
# OFTReal returns floats, all else returns string.
|
||||
val = field.value
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
@ -50,6 +50,7 @@ from django.utils.encoding import force_bytes, force_str
|
||||
# The OGR_DS_* routines are relevant here.
|
||||
class DataSource(GDALBase):
|
||||
"Wraps an OGR Data Source object."
|
||||
|
||||
destructor = capi.destroy_ds
|
||||
|
||||
def __init__(self, ds_input, ds_driver=False, write=False, encoding="utf-8"):
|
||||
|
@ -1,14 +1,14 @@
|
||||
"""
|
||||
The GDAL/OGR library uses an Envelope structure to hold the bounding
|
||||
box information for a geometry. The envelope (bounding box) contains
|
||||
two pairs of coordinates, one for the lower left coordinate and one
|
||||
for the upper right coordinate:
|
||||
The GDAL/OGR library uses an Envelope structure to hold the bounding
|
||||
box information for a geometry. The envelope (bounding box) contains
|
||||
two pairs of coordinates, one for the lower left coordinate and one
|
||||
for the upper right coordinate:
|
||||
|
||||
+----------o Upper right; (max_x, max_y)
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
Lower left (min_x, min_y) o----------+
|
||||
+----------o Upper right; (max_x, max_y)
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
Lower left (min_x, min_y) o----------+
|
||||
"""
|
||||
|
||||
from ctypes import Structure, c_double
|
||||
@ -21,6 +21,7 @@ from django.contrib.gis.gdal.error import GDALException
|
||||
# https://gdal.org/doxygen/ogr__core_8h_source.html
|
||||
class OGREnvelope(Structure):
|
||||
"Represent the OGREnvelope C Structure."
|
||||
|
||||
_fields_ = [
|
||||
("MinX", c_double),
|
||||
("MaxX", c_double),
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""
|
||||
This module houses the GDAL & SRS Exception objects, and the
|
||||
check_err() routine which checks the status code returned by
|
||||
GDAL/OGR methods.
|
||||
This module houses the GDAL & SRS Exception objects, and the
|
||||
check_err() routine which checks the status code returned by
|
||||
GDAL/OGR methods.
|
||||
"""
|
||||
|
||||
|
||||
|
@ -1,42 +1,42 @@
|
||||
"""
|
||||
The OGRGeometry is a wrapper for using the OGR Geometry class
|
||||
(see https://gdal.org/api/ogrgeometry_cpp.html#_CPPv411OGRGeometry).
|
||||
OGRGeometry may be instantiated when reading geometries from OGR Data Sources
|
||||
(e.g. SHP files), or when given OGC WKT (a string).
|
||||
The OGRGeometry is a wrapper for using the OGR Geometry class
|
||||
(see https://gdal.org/api/ogrgeometry_cpp.html#_CPPv411OGRGeometry).
|
||||
OGRGeometry may be instantiated when reading geometries from OGR Data Sources
|
||||
(e.g. SHP files), or when given OGC WKT (a string).
|
||||
|
||||
While the 'full' API is not present yet, the API is "pythonic" unlike
|
||||
the traditional and "next-generation" OGR Python bindings. One major
|
||||
advantage OGR Geometries have over their GEOS counterparts is support
|
||||
for spatial reference systems and their transformation.
|
||||
While the 'full' API is not present yet, the API is "pythonic" unlike
|
||||
the traditional and "next-generation" OGR Python bindings. One major
|
||||
advantage OGR Geometries have over their GEOS counterparts is support
|
||||
for spatial reference systems and their transformation.
|
||||
|
||||
Example:
|
||||
>>> from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, SpatialReference
|
||||
>>> wkt1, wkt2 = 'POINT(-90 30)', 'POLYGON((0 0, 5 0, 5 5, 0 5)'
|
||||
>>> pnt = OGRGeometry(wkt1)
|
||||
>>> print(pnt)
|
||||
POINT (-90 30)
|
||||
>>> mpnt = OGRGeometry(OGRGeomType('MultiPoint'), SpatialReference('WGS84'))
|
||||
>>> mpnt.add(wkt1)
|
||||
>>> mpnt.add(wkt1)
|
||||
>>> print(mpnt)
|
||||
MULTIPOINT (-90 30,-90 30)
|
||||
>>> print(mpnt.srs.name)
|
||||
WGS 84
|
||||
>>> print(mpnt.srs.proj)
|
||||
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
|
||||
>>> mpnt.transform(SpatialReference('NAD27'))
|
||||
>>> print(mpnt.proj)
|
||||
+proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
|
||||
>>> print(mpnt)
|
||||
MULTIPOINT (-89.99993037860248 29.99979788655764,-89.99993037860248 29.99979788655764)
|
||||
Example:
|
||||
>>> from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, SpatialReference
|
||||
>>> wkt1, wkt2 = 'POINT(-90 30)', 'POLYGON((0 0, 5 0, 5 5, 0 5)'
|
||||
>>> pnt = OGRGeometry(wkt1)
|
||||
>>> print(pnt)
|
||||
POINT (-90 30)
|
||||
>>> mpnt = OGRGeometry(OGRGeomType('MultiPoint'), SpatialReference('WGS84'))
|
||||
>>> mpnt.add(wkt1)
|
||||
>>> mpnt.add(wkt1)
|
||||
>>> print(mpnt)
|
||||
MULTIPOINT (-90 30,-90 30)
|
||||
>>> print(mpnt.srs.name)
|
||||
WGS 84
|
||||
>>> print(mpnt.srs.proj)
|
||||
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
|
||||
>>> mpnt.transform(SpatialReference('NAD27'))
|
||||
>>> print(mpnt.proj)
|
||||
+proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
|
||||
>>> print(mpnt)
|
||||
MULTIPOINT (-89.99993037860248 29.99979788655764,-89.99993037860248 29.99979788655764)
|
||||
|
||||
The OGRGeomType class is to make it easy to specify an OGR geometry type:
|
||||
>>> from django.contrib.gis.gdal import OGRGeomType
|
||||
>>> gt1 = OGRGeomType(3) # Using an integer for the type
|
||||
>>> gt2 = OGRGeomType('Polygon') # Using a string
|
||||
>>> gt3 = OGRGeomType('POLYGON') # It's case-insensitive
|
||||
>>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
|
||||
True True
|
||||
The OGRGeomType class is to make it easy to specify an OGR geometry type:
|
||||
>>> from django.contrib.gis.gdal import OGRGeomType
|
||||
>>> gt1 = OGRGeomType(3) # Using an integer for the type
|
||||
>>> gt2 = OGRGeomType('Polygon') # Using a string
|
||||
>>> gt3 = OGRGeomType('POLYGON') # It's case-insensitive
|
||||
>>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
|
||||
True True
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""
|
||||
This module houses the ctypes function prototypes for OGR DataSource
|
||||
related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*,
|
||||
OGR_Fld_* routines are relevant here.
|
||||
This module houses the ctypes function prototypes for OGR DataSource
|
||||
related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*,
|
||||
OGR_Fld_* routines are relevant here.
|
||||
"""
|
||||
|
||||
from ctypes import POINTER, c_char_p, c_double, c_int, c_long, c_uint, c_void_p
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
This module houses the error-checking routines used by the GDAL
|
||||
ctypes prototypes.
|
||||
This module houses the error-checking routines used by the GDAL
|
||||
ctypes prototypes.
|
||||
"""
|
||||
|
||||
from ctypes import c_void_p, string_at
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
This module contains functions that generate ctypes prototypes for the
|
||||
GDAL routines.
|
||||
This module contains functions that generate ctypes prototypes for the
|
||||
GDAL routines.
|
||||
"""
|
||||
|
||||
from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_int64, c_void_p
|
||||
|
@ -1,30 +1,30 @@
|
||||
"""
|
||||
The Spatial Reference class, represents OGR Spatial Reference objects.
|
||||
The Spatial Reference class, represents OGR Spatial Reference objects.
|
||||
|
||||
Example:
|
||||
>>> from django.contrib.gis.gdal import SpatialReference
|
||||
>>> srs = SpatialReference('WGS84')
|
||||
>>> print(srs)
|
||||
GEOGCS["WGS 84",
|
||||
DATUM["WGS_1984",
|
||||
SPHEROID["WGS 84",6378137,298.257223563,
|
||||
AUTHORITY["EPSG","7030"]],
|
||||
TOWGS84[0,0,0,0,0,0,0],
|
||||
AUTHORITY["EPSG","6326"]],
|
||||
PRIMEM["Greenwich",0,
|
||||
AUTHORITY["EPSG","8901"]],
|
||||
UNIT["degree",0.01745329251994328,
|
||||
AUTHORITY["EPSG","9122"]],
|
||||
AUTHORITY["EPSG","4326"]]
|
||||
>>> print(srs.proj)
|
||||
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
|
||||
>>> print(srs.ellipsoid)
|
||||
(6378137.0, 6356752.3142451793, 298.25722356300003)
|
||||
>>> print(srs.projected, srs.geographic)
|
||||
False True
|
||||
>>> srs.import_epsg(32140)
|
||||
>>> print(srs.name)
|
||||
NAD83 / Texas South Central
|
||||
Example:
|
||||
>>> from django.contrib.gis.gdal import SpatialReference
|
||||
>>> srs = SpatialReference('WGS84')
|
||||
>>> print(srs)
|
||||
GEOGCS["WGS 84",
|
||||
DATUM["WGS_1984",
|
||||
SPHEROID["WGS 84",6378137,298.257223563,
|
||||
AUTHORITY["EPSG","7030"]],
|
||||
TOWGS84[0,0,0,0,0,0,0],
|
||||
AUTHORITY["EPSG","6326"]],
|
||||
PRIMEM["Greenwich",0,
|
||||
AUTHORITY["EPSG","8901"]],
|
||||
UNIT["degree",0.01745329251994328,
|
||||
AUTHORITY["EPSG","9122"]],
|
||||
AUTHORITY["EPSG","4326"]]
|
||||
>>> print(srs.proj)
|
||||
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
|
||||
>>> print(srs.ellipsoid)
|
||||
(6378137.0, 6356752.3142451793, 298.25722356300003)
|
||||
>>> print(srs.projected, srs.geographic)
|
||||
False True
|
||||
>>> srs.import_epsg(32140)
|
||||
>>> print(srs.name)
|
||||
NAD83 / Texas South Central
|
||||
"""
|
||||
|
||||
from ctypes import byref, c_char_p, c_int
|
||||
@ -345,6 +345,7 @@ class SpatialReference(GDALBase):
|
||||
|
||||
class CoordTransform(GDALBase):
|
||||
"The coordinate system transformation object."
|
||||
|
||||
destructor = capi.destroy_ct
|
||||
|
||||
def __init__(self, source, target):
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
This module houses the Geometry Collection objects:
|
||||
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
|
||||
This module houses the Geometry Collection objects:
|
||||
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
|
||||
"""
|
||||
|
||||
from django.contrib.gis.geos import prototypes as capi
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""
|
||||
This module houses the GEOSCoordSeq object, which is used internally
|
||||
by GEOSGeometry to house the actual coordinates of the Point,
|
||||
LineString, and LinearRing geometries.
|
||||
This module houses the GEOSCoordSeq object, which is used internally
|
||||
by GEOSGeometry to house the actual coordinates of the Point,
|
||||
LineString, and LinearRing geometries.
|
||||
"""
|
||||
|
||||
from ctypes import byref, c_byte, c_double, c_uint
|
||||
|
@ -1,3 +1,4 @@
|
||||
class GEOSException(Exception):
|
||||
"The base GEOS exception, indicates a GEOS-related error."
|
||||
|
||||
pass
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
|
||||
inherit from this object.
|
||||
This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
|
||||
inherit from this object.
|
||||
"""
|
||||
|
||||
import re
|
||||
|
@ -1,10 +1,10 @@
|
||||
"""
|
||||
This module houses the ctypes initialization procedures, as well
|
||||
as the notice and error handler function callbacks (get called
|
||||
when an error occurs in GEOS).
|
||||
This module houses the ctypes initialization procedures, as well
|
||||
as the notice and error handler function callbacks (get called
|
||||
when an error occurs in GEOS).
|
||||
|
||||
This module also houses GEOS Pointer utilities, including
|
||||
get_pointer_arr(), and GEOM_PTR.
|
||||
This module also houses GEOS Pointer utilities, including
|
||||
get_pointer_arr(), and GEOM_PTR.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""
|
||||
This module contains all of the GEOS ctypes function prototypes. Each
|
||||
prototype handles the interaction between the GEOS library and Python
|
||||
via ctypes.
|
||||
This module contains all of the GEOS ctypes function prototypes. Each
|
||||
prototype handles the interaction between the GEOS library and Python
|
||||
via ctypes.
|
||||
"""
|
||||
|
||||
from django.contrib.gis.geos.prototypes.coordseq import ( # NOQA
|
||||
|
@ -23,6 +23,7 @@ def check_cs_get(result, func, cargs):
|
||||
# ## Coordinate sequence prototype factory classes. ##
|
||||
class CsInt(GEOSFuncFactory):
|
||||
"For coordinate sequence routines that return an integer."
|
||||
|
||||
argtypes = [CS_PTR, POINTER(c_uint)]
|
||||
restype = c_int
|
||||
errcheck = staticmethod(check_cs_get)
|
||||
@ -30,6 +31,7 @@ class CsInt(GEOSFuncFactory):
|
||||
|
||||
class CsOperation(GEOSFuncFactory):
|
||||
"For coordinate sequence operations."
|
||||
|
||||
restype = c_int
|
||||
|
||||
def __init__(self, *args, ordinate=False, get=False, **kwargs):
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
Error checking functions for GEOS ctypes prototype functions.
|
||||
Error checking functions for GEOS ctypes prototype functions.
|
||||
"""
|
||||
|
||||
from ctypes import c_void_p, string_at
|
||||
|
@ -25,12 +25,14 @@ class geos_char_p(c_char_p):
|
||||
# ### ctypes factory classes ###
|
||||
class GeomOutput(GEOSFuncFactory):
|
||||
"For GEOS routines that return a geometry."
|
||||
|
||||
restype = GEOM_PTR
|
||||
errcheck = staticmethod(check_geom)
|
||||
|
||||
|
||||
class IntFromGeom(GEOSFuncFactory):
|
||||
"Argument is a geometry, return type is an integer."
|
||||
|
||||
argtypes = [GEOM_PTR]
|
||||
restype = c_int
|
||||
errcheck = staticmethod(check_minus_one)
|
||||
@ -38,6 +40,7 @@ class IntFromGeom(GEOSFuncFactory):
|
||||
|
||||
class StringFromGeom(GEOSFuncFactory):
|
||||
"Argument is a Geometry, return type is a string."
|
||||
|
||||
argtypes = [GEOM_PTR]
|
||||
restype = geos_char_p
|
||||
errcheck = staticmethod(check_string)
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
This module is for the miscellaneous GEOS routines, particularly the
|
||||
ones that return the area, distance, and length.
|
||||
This module is for the miscellaneous GEOS routines, particularly the
|
||||
ones that return the area, distance, and length.
|
||||
"""
|
||||
|
||||
from ctypes import POINTER, c_double, c_int
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
This module houses the GEOS ctypes prototype functions for the
|
||||
unary and binary predicate operations on geometries.
|
||||
This module houses the GEOS ctypes prototype functions for the
|
||||
unary and binary predicate operations on geometries.
|
||||
"""
|
||||
|
||||
from ctypes import c_byte, c_char_p, c_double
|
||||
@ -12,6 +12,7 @@ from django.contrib.gis.geos.prototypes.errcheck import check_predicate
|
||||
# ## Binary & unary predicate factories ##
|
||||
class UnaryPredicate(GEOSFuncFactory):
|
||||
"For GEOS unary predicate functions."
|
||||
|
||||
argtypes = [GEOM_PTR]
|
||||
restype = c_byte
|
||||
errcheck = staticmethod(check_predicate)
|
||||
@ -19,6 +20,7 @@ class UnaryPredicate(GEOSFuncFactory):
|
||||
|
||||
class BinaryPredicate(UnaryPredicate):
|
||||
"For GEOS binary predicate functions."
|
||||
|
||||
argtypes = [GEOM_PTR, GEOM_PTR]
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
This module houses the GEOS ctypes prototype functions for the
|
||||
topological operations on geometries.
|
||||
This module houses the GEOS ctypes prototype functions for the
|
||||
topological operations on geometries.
|
||||
"""
|
||||
|
||||
from ctypes import c_double, c_int
|
||||
@ -16,6 +16,7 @@ from django.contrib.gis.geos.prototypes.geom import geos_char_p
|
||||
|
||||
class Topology(GEOSFuncFactory):
|
||||
"For GEOS unary topology functions."
|
||||
|
||||
argtypes = [GEOM_PTR]
|
||||
restype = GEOM_PTR
|
||||
errcheck = staticmethod(check_geom)
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
This module contains useful utilities for GeoDjango.
|
||||
This module contains useful utilities for GeoDjango.
|
||||
"""
|
||||
|
||||
from django.contrib.gis.utils.ogrinfo import ogrinfo
|
||||
|
@ -1,10 +1,10 @@
|
||||
# LayerMapping -- A Django Model/OGR Layer Mapping Utility
|
||||
"""
|
||||
The LayerMapping class provides a way to map the contents of OGR
|
||||
vector files (e.g. SHP files) to Geographic-enabled Django models.
|
||||
The LayerMapping class provides a way to map the contents of OGR
|
||||
vector files (e.g. SHP files) to Geographic-enabled Django models.
|
||||
|
||||
For more information, please consult the GeoDjango documentation:
|
||||
https://docs.djangoproject.com/en/dev/ref/contrib/gis/layermapping/
|
||||
For more information, please consult the GeoDjango documentation:
|
||||
https://docs.djangoproject.com/en/dev/ref/contrib/gis/layermapping/
|
||||
"""
|
||||
import sys
|
||||
from decimal import Decimal
|
||||
|
1
django/core/cache/backends/base.py
vendored
1
django/core/cache/backends/base.py
vendored
@ -1,4 +1,5 @@
|
||||
"Base Cache class."
|
||||
|
||||
import time
|
||||
import warnings
|
||||
|
||||
|
1
django/core/cache/backends/db.py
vendored
1
django/core/cache/backends/db.py
vendored
@ -1,4 +1,5 @@
|
||||
"Database cache backend."
|
||||
|
||||
import base64
|
||||
import pickle
|
||||
from datetime import datetime, timezone
|
||||
|
1
django/core/cache/backends/filebased.py
vendored
1
django/core/cache/backends/filebased.py
vendored
@ -1,4 +1,5 @@
|
||||
"File-based cache backend"
|
||||
|
||||
import glob
|
||||
import os
|
||||
import pickle
|
||||
|
1
django/core/cache/backends/locmem.py
vendored
1
django/core/cache/backends/locmem.py
vendored
@ -1,4 +1,5 @@
|
||||
"Thread-safe in-memory cache backend."
|
||||
|
||||
import pickle
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
|
@ -431,6 +431,7 @@ class BaseForm(RenderableFormMixin):
|
||||
|
||||
class Form(BaseForm, metaclass=DeclarativeFieldsMetaclass):
|
||||
"A collection of Fields, plus their associated data."
|
||||
|
||||
# This is a separate class from BaseForm in order to abstract the way
|
||||
# self.fields is specified. This class (Form) is the one that does the
|
||||
# fancy metaclass stuff purely for the semantic sugar -- it allows one
|
||||
|
@ -7,6 +7,7 @@ _builtin_context_processors = ("django.template.context_processors.csrf",)
|
||||
|
||||
class ContextPopException(Exception):
|
||||
"pop() has been called more times than push()"
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
@ -546,6 +546,7 @@ class SuperVillain(Villain):
|
||||
|
||||
class FunkyTag(models.Model):
|
||||
"Because we all know there's only one real use case for GFKs."
|
||||
|
||||
name = models.CharField(max_length=25)
|
||||
content_type = models.ForeignKey(ContentType, models.CASCADE)
|
||||
object_id = models.PositiveIntegerField()
|
||||
|
@ -7159,7 +7159,7 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase):
|
||||
url = reverse("admin:admin_views_pizza_change", args=(pizza.pk,))
|
||||
with self.settings(LANGUAGE_CODE="fr"):
|
||||
response = self.client.get(url)
|
||||
self.assertContains(response, "<label>Toppings\u00A0:</label>", html=True)
|
||||
self.assertContains(response, "<label>Toppings\u00a0:</label>", html=True)
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF="admin_views.urls")
|
||||
|
@ -350,10 +350,10 @@ class UsernameValidatorsTests(SimpleTestCase):
|
||||
invalid_usernames = [
|
||||
"o'connell",
|
||||
"عبد ال",
|
||||
"zerowidth\u200Bspace",
|
||||
"nonbreaking\u00A0space",
|
||||
"zerowidth\u200bspace",
|
||||
"nonbreaking\u00a0space",
|
||||
"en\u2013dash",
|
||||
"trailingnewline\u000A",
|
||||
"trailingnewline\u000a",
|
||||
]
|
||||
v = validators.UnicodeUsernameValidator()
|
||||
for valid in valid_usernames:
|
||||
|
@ -90,7 +90,7 @@ class LastExecutedQueryTest(TestCase):
|
||||
|
||||
def test_query_encoding(self):
|
||||
"""last_executed_query() returns a string."""
|
||||
data = RawData.objects.filter(raw_data=b"\x00\x46 \xFE").extra(
|
||||
data = RawData.objects.filter(raw_data=b"\x00\x46 \xfe").extra(
|
||||
select={"föö": 1}
|
||||
)
|
||||
sql, params = data.query.sql_with_params()
|
||||
|
@ -73,7 +73,7 @@ class FormsUtilsTestCase(SimpleTestCase):
|
||||
)
|
||||
# Can take a Unicode string.
|
||||
self.assertHTMLEqual(
|
||||
str(ErrorList(ValidationError("Not \u03C0.").messages)),
|
||||
str(ErrorList(ValidationError("Not \u03c0.").messages)),
|
||||
'<ul class="errorlist"><li>Not π.</li></ul>',
|
||||
)
|
||||
# Can take a lazy string.
|
||||
@ -107,7 +107,7 @@ class FormsUtilsTestCase(SimpleTestCase):
|
||||
ValidationError(
|
||||
[
|
||||
"1. First error.",
|
||||
"2. Not \u03C0.",
|
||||
"2. Not \u03c0.",
|
||||
gettext_lazy("3. Error."),
|
||||
{
|
||||
"error_1": "4. First dict error.",
|
||||
|
@ -15,17 +15,20 @@ class NamedModel(models.Model):
|
||||
|
||||
class SouthTexasCity(NamedModel):
|
||||
"City model on projected coordinate system for South Texas."
|
||||
|
||||
point = models.PointField(srid=32140)
|
||||
radius = models.IntegerField(default=10000)
|
||||
|
||||
|
||||
class SouthTexasCityFt(NamedModel):
|
||||
"Same City model as above, but U.S. survey feet are the units."
|
||||
|
||||
point = models.PointField(srid=2278)
|
||||
|
||||
|
||||
class AustraliaCity(NamedModel):
|
||||
"City model for Australia, using WGS84."
|
||||
|
||||
point = models.PointField()
|
||||
radius = models.IntegerField(default=10000)
|
||||
allowed_distance = models.FloatField(default=0.5)
|
||||
@ -34,19 +37,23 @@ class AustraliaCity(NamedModel):
|
||||
|
||||
class CensusZipcode(NamedModel):
|
||||
"Model for a few South Texas ZIP codes (in original Census NAD83)."
|
||||
|
||||
poly = models.PolygonField(srid=4269)
|
||||
|
||||
|
||||
class SouthTexasZipcode(NamedModel):
|
||||
"Model for a few South Texas ZIP codes."
|
||||
|
||||
poly = models.PolygonField(srid=32140, null=gisfield_may_be_null)
|
||||
|
||||
|
||||
class Interstate(NamedModel):
|
||||
"Geodetic model for U.S. Interstates."
|
||||
|
||||
path = models.LineStringField()
|
||||
|
||||
|
||||
class SouthTexasInterstate(NamedModel):
|
||||
"Projected model for South Texas Interstates."
|
||||
|
||||
path = models.LineStringField(srid=32140)
|
||||
|
@ -6,7 +6,7 @@ from .models import DataModel
|
||||
|
||||
|
||||
class BinaryFieldTests(TestCase):
|
||||
binary_data = b"\x00\x46\xFE"
|
||||
binary_data = b"\x00\x46\xfe"
|
||||
|
||||
def test_set_and_retrieve(self):
|
||||
data_set = (
|
||||
|
@ -309,7 +309,7 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
|
||||
def test_invalid_expressions(self):
|
||||
msg = "The expressions must be a list of 2-tuples."
|
||||
for expressions in (["foo"], [("foo")], [("foo_1", "foo_2", "foo_3")]):
|
||||
for expressions in (["foo"], ["foo"], [("foo_1", "foo_2", "foo_3")]):
|
||||
with self.subTest(expressions), self.assertRaisesMessage(ValueError, msg):
|
||||
ExclusionConstraint(
|
||||
index_type="GIST",
|
||||
|
@ -257,7 +257,7 @@ uuid_obj = uuid.uuid4()
|
||||
|
||||
test_data = [
|
||||
# Format: (test helper, PK value, Model Class, data)
|
||||
(data_obj, 1, BinaryData, memoryview(b"\x05\xFD\x00")),
|
||||
(data_obj, 1, BinaryData, memoryview(b"\x05\xfd\x00")),
|
||||
(data_obj, 5, BooleanData, True),
|
||||
(data_obj, 6, BooleanData, False),
|
||||
(data_obj, 7, BooleanData, None),
|
||||
|
@ -70,7 +70,7 @@ class XmlSerializerTestCase(SerializersTestBase, TestCase):
|
||||
msg = "Article.headline (pk:%s) contains unserializable characters" % self.a1.pk
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
serializers.serialize(self.serializer_name, [self.a1])
|
||||
self.a1.headline = "HT \u0009, LF \u000A, and CR \u000D are allowed"
|
||||
self.a1.headline = "HT \u0009, LF \u000a, and CR \u000d are allowed"
|
||||
self.assertIn(
|
||||
"HT \t, LF \n, and CR \r are allowed",
|
||||
serializers.serialize(self.serializer_name, [self.a1]),
|
||||
|
@ -9,7 +9,7 @@ from django.utils.functional import lazystr
|
||||
from django.utils.text import format_lazy
|
||||
from django.utils.translation import gettext_lazy, override
|
||||
|
||||
IS_WIDE_BUILD = len("\U0001F4A9") == 1
|
||||
IS_WIDE_BUILD = len("\U0001f4a9") == 1
|
||||
|
||||
|
||||
class TestUtilsText(SimpleTestCase):
|
||||
@ -76,16 +76,16 @@ class TestUtilsText(SimpleTestCase):
|
||||
# Ensure the final length is calculated correctly when there are
|
||||
# combining characters with no precomposed form, and that combining
|
||||
# characters are not split up.
|
||||
truncator = text.Truncator("-B\u030AB\u030A----8")
|
||||
self.assertEqual("-B\u030A…", truncator.chars(3))
|
||||
self.assertEqual("-B\u030AB\u030A-…", truncator.chars(5))
|
||||
self.assertEqual("-B\u030AB\u030A----8", truncator.chars(8))
|
||||
truncator = text.Truncator("-B\u030aB\u030a----8")
|
||||
self.assertEqual("-B\u030a…", truncator.chars(3))
|
||||
self.assertEqual("-B\u030aB\u030a-…", truncator.chars(5))
|
||||
self.assertEqual("-B\u030aB\u030a----8", truncator.chars(8))
|
||||
|
||||
# Ensure the length of the end text is correctly calculated when it
|
||||
# contains combining characters with no precomposed form.
|
||||
truncator = text.Truncator("-----")
|
||||
self.assertEqual("---B\u030A", truncator.chars(4, "B\u030A"))
|
||||
self.assertEqual("-----", truncator.chars(5, "B\u030A"))
|
||||
self.assertEqual("---B\u030a", truncator.chars(4, "B\u030a"))
|
||||
self.assertEqual("-----", truncator.chars(5, "B\u030a"))
|
||||
|
||||
# Make a best effort to shorten to the desired length, but requesting
|
||||
# a length shorter than the ellipsis shouldn't break
|
||||
|
Loading…
x
Reference in New Issue
Block a user