hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
5024bd98fae4859e582fff51312ae003bb960d3cef2f3a922eafcb4975578a63 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('admin', '0002_logentry_remove_auto_add'),
]
# No database changes; adds choices to action_flag.
operations = [
migrations.AlterField(
model_name='logentry',
name... |
d29e538ed7ab4fcd053ab0b184eed8a993da83ec67c918a7fe6434d508f9efda | import django.contrib.admin.models
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('contenttypes', '__first__'),
]
operations = [
migratio... |
1aa1d9ffffb77c2e8885d69838a97997ee8e49722e92e6f0965770875dc4fc23 | #!/usr/bin/env python
import argparse
import subprocess
import sys
from pathlib import Path
try:
import closure
except ImportError:
closure_compiler = None
else:
closure_compiler = closure.get_jar_filename()
js_path = Path(__file__).parent.parent / 'static' / 'admin' / 'js'
def main():
description =... |
278c18732685afffb163500d97a405e1c1613aea51be38e6068b4dd05b215588 | from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import user_passes_test
def staff_member_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME,
login_url='admin:login'):
"""
Decorator for views that checks that the user is logged in ... |
0981bc24ac03e7fc4eeaec049f8c05d14ac49f475504699a27091271d2c324a6 | from collections import OrderedDict
from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.admin import FieldListFilter
from django.contrib.admin.exceptions import (
DisallowedModelAdminLookup, DisallowedModelAdminToField,
)
from django.contrib.admin.options import (
IS_P... |
bdf2dad983d935148795b65754d9e5a41b53c0bb58f86435cafbc277c0f57c76 | from django.http import Http404, JsonResponse
from django.views.generic.list import BaseListView
class AutocompleteJsonView(BaseListView):
"""Handle AutocompleteWidget's AJAX requests for data."""
paginate_by = 20
model_admin = None
def get(self, request, *args, **kwargs):
"""
Return ... |
5908ad578b9d78b7c3f01dfab11267ed0aa770fd0a59ce5af00f372ec20e21e5 | import warnings
from django.template import Library
from django.templatetags.static import static as _static
from django.utils.deprecation import RemovedInDjango30Warning
register = Library()
@register.simple_tag
def static(path):
warnings.warn(
'{% load admin_static %} is deprecated in favor of {% load... |
e7899d0cfc829da312e0dd1636064125a931fded76d3808d4a7ebcbda2cfe418 | from inspect import getfullargspec
from django.template.library import InclusionNode, parse_bits
class InclusionAdminNode(InclusionNode):
"""
Template tag that allows its template to be overridden per model, per app,
or globally.
"""
def __init__(self, parser, token, func, template_name, takes_c... |
9b157a9af7d5268d2a4427a59234413567ebbab2c006166f19095ca79067e085 | from django import template
from django.contrib.admin.models import LogEntry
register = template.Library()
class AdminLogNode(template.Node):
def __init__(self, limit, varname, user):
self.limit, self.varname, self.user = limit, varname, user
def __repr__(self):
return "<GetAdminLog Node>"
... |
58b2a5d85d82f60369784e75f85b961d6d2242515d381e011a5d8928dad550b6 | import datetime
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.admin.utils import (
display_for_field, display_for_value, label_for_field, lookup_field,
)
from django.contrib.admin.views.main import (
ALL_VAR, ORDER_VAR, PAGE_VAR, SEARCH_VAR,
)
from django.co... |
6ff4710cb47bc8b05331efbfca5ccefa6d11dc84eadd93ffa6775d47233f368b | from urllib.parse import parse_qsl, unquote, urlparse, urlunparse
from django import template
from django.contrib.admin.utils import quote
from django.urls import Resolver404, get_script_prefix, resolve
from django.utils.http import urlencode
register = template.Library()
@register.filter
def admin_urlname(value, a... |
cabef72915ee8b304888aad2b207fc8dab73886ad44cc17bbf07e6e261e501c8 | import json
from django import template
from django.template.context import Context
from .base import InclusionAdminNode
register = template.Library()
def prepopulated_fields_js(context):
"""
Create a list of prepopulated_fields that should render Javascript for
the prepopulated fields for both the adm... |
87212382af1f01fbfc0b4b4b93a7d424da9408ee508766ac1f2acc486a2a5999 | import re
from datetime import date, datetime
from decimal import Decimal
from django import template
from django.conf import settings
from django.template import defaultfilters
from django.utils.formats import number_format
from django.utils.safestring import mark_safe
from django.utils.timezone import is_aware, utc
... |
eebccaaaa4e15cef42acb38fe64ab7bb34bcd1dce4b02f5c44435cf3a1bdf90a | import warnings
from django import template
from django.templatetags.static import (
do_static as _do_static, static as _static,
)
from django.utils.deprecation import RemovedInDjango30Warning
register = template.Library()
def static(path):
warnings.warn(
'django.contrib.staticfiles.templatetags.sta... |
baffa1e9af003acd1cf7620b4ffdccbb45130680a24334e1a5412647e6e58fbd | from django.conf import settings
from django.contrib.staticfiles.handlers import StaticFilesHandler
from django.core.management.commands.runserver import (
Command as RunserverCommand,
)
class Command(RunserverCommand):
help = "Starts a lightweight Web server for development and also serves static files."
... |
f7d54262736d038a79bbbcfc89a9f2facf54cf0f4ffcf2f0c694b2fbd0b43ba3 | import os
from collections import OrderedDict
from django.apps import apps
from django.contrib.staticfiles.finders import get_finders
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.files.storage import FileSystemStorage
from django.core.management.base import BaseCommand, CommandEr... |
47908def98c69efb15d7a310db77966a47bf10113b346f7813128bfb9e0da984 | import os
from django.contrib.staticfiles import finders
from django.core.management.base import LabelCommand
class Command(LabelCommand):
help = "Finds the absolute paths for the given static file(s)."
label = 'staticfile'
def add_arguments(self, parser):
super().add_arguments(parser)
p... |
74b4a53e98df73a8cc2a1c583ecc3ac8aa21c67e1e8d15d5389d55c897f5dabe | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sites', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='FlatPage',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=Fals... |
ab4c2c190a971e14821f8fd447ec07923fe926cc413a8fe588e0c14ff0597137 | from django import template
from django.conf import settings
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.shortcuts import get_current_site
register = template.Library()
class FlatpageNode(template.Node):
def __init__(self, context_name, starts_with=None, user=None):
sel... |
1c4096a8fd11d21a7bee9fee6c8e5b23d0ea11722218e4d3b3302be04a60b551 | import django.contrib.sites.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sites', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='site',
name='domain',
field=models.CharFi... |
0a4cd0e8f80e4704a892ba6ae838fabbe58212d72e49fe0f6aee94ca20694a50 | import django.contrib.sites.models
from django.contrib.sites.models import _simple_domain_name_validator
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name='Site',
fields=[
... |
a376d556bf8efde50d8a5a000b5cfe2481c3a02250e227dd03ee8385d554ae9f | import django.contrib.contenttypes.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='ContentType',
fields=[
('id', models.AutoField(verbose_name='ID', seri... |
e21d4051649602fc1f10c01aa2925971efb2363d4056909814093613e52bfb03 | from django.db import migrations, models
def add_legacy_name(apps, schema_editor):
ContentType = apps.get_model('contenttypes', 'ContentType')
for ct in ContentType.objects.all():
try:
ct.name = apps.get_model(ct.app_label, ct.model)._meta.object_name
except LookupError:
... |
28a7f8616baebd400e7f99765e7e7310847858703cbca439479a5a55f6003de3 | from django.apps import apps as global_apps
from django.db import DEFAULT_DB_ALIAS, migrations, router, transaction
from django.db.utils import IntegrityError
class RenameContentType(migrations.RunPython):
def __init__(self, app_label, old_model, new_model):
self.app_label = app_label
self.old_mod... |
01c511d50f7f951fc1ce8ba2aa220da9edf88d9a8db1568a6da8676ebf53ed16 | from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from django.core.management import BaseCommand
from django.db import DEFAULT_DB_ALIAS, router
from django.db.models.deletion import Collector
from ...management import get_contenttypes_and_models
class Command(BaseCommand):
... |
17b7f393677d8433e3530c76c3e9577597051b58781f21e791f709e9a2bb0bed | import django.contrib.sessions.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Session',
fields=[
('session_key', models.CharField(
m... |
35cb1da486ffe2ad5913396b6a5c75c0df3cf887114e933391548f31664d71ac | import datetime
import logging
import os
import shutil
import tempfile
from django.conf import settings
from django.contrib.sessions.backends.base import (
VALID_KEY_CHARS, CreateError, SessionBase, UpdateError,
)
from django.contrib.sessions.exceptions import InvalidSessionKey
from django.core.exceptions import I... |
cf386fd2743838815ec8cd905eb2141b6ea5fc8268b1a80a686388d8d7199f3e | import logging
from django.contrib.sessions.backends.base import (
CreateError, SessionBase, UpdateError,
)
from django.core.exceptions import SuspiciousOperation
from django.db import DatabaseError, IntegrityError, router, transaction
from django.utils import timezone
from django.utils.functional import cached_pr... |
b926e5f31e01bab02e0d86aea459c0e3af5b0b6fd5c9d50032e2dafe0d52b243 | import base64
import logging
import string
from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.sessions.exceptions import SuspiciousSession
from django.core.exceptions import SuspiciousOperation
from django.utils import timezone
from django.utils.crypto import (
constant_t... |
8dc06b0f78141eb7444d67fa26fc0354215ee1e02245b1fc8b6a0c263c295cfb | from django.conf import settings
from django.contrib.sessions.backends.base import SessionBase
from django.core import signing
class SessionStore(SessionBase):
def load(self):
"""
Load the data from the key itself instead of fetching from some
external data store. Opposite of _get_session... |
73d26d197c72258453ecc315aeac28d23c35bf7242a5a04d5de2fc775b407c11 | """
Cached, database-backed sessions.
"""
from django.conf import settings
from django.contrib.sessions.backends.db import SessionStore as DBStore
from django.core.cache import caches
KEY_PREFIX = "django.contrib.sessions.cached_db"
class SessionStore(DBStore):
"""
Implement cached, database backed sessions... |
faa792cf4ee052276263fc6aee298c27748fd7b27facbb083b9d0ac4e86affc1 | from django.conf import settings
from django.contrib.sessions.backends.base import (
CreateError, SessionBase, UpdateError,
)
from django.core.cache import caches
KEY_PREFIX = "django.contrib.sessions.cache"
class SessionStore(SessionBase):
"""
A cache-based session store.
"""
cache_key_prefix = ... |
c8371298aeb99791f5fb68621e10e5374ce2bd0af19bf8a134a2cab7a3264624 | from importlib import import_module
from django.conf import settings
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = (
"Can be run as a cronjob or directly to clean out expired sessions "
"(only with the database backend at the moment)."
)
def handl... |
91b2b222dfbfbbbcd9241f2e3c6e027e2edac40e66b3696d7689dcb66e737b00 | from django.apps import apps
from django.contrib.gis.db.models.fields import GeometryField
from django.contrib.sitemaps import Sitemap
from django.db import models
from django.urls import reverse
class KMLSitemap(Sitemap):
"""
A minimal hook to produce KML sitemaps.
"""
geo_format = 'kml'
def __i... |
7951d4c5fcf0d55427e9ba87dc3f1b138ef5b3c6cd252077a61b8023ece0f600 | # Geo-enabled Sitemap classes.
from django.contrib.gis.sitemaps.kml import KMLSitemap, KMZSitemap
__all__ = ['KMLSitemap', 'KMZSitemap']
|
e31addd8d1108ec3f1f79f363dad11d88133c793693f9ba7a8252c3e351182da | from django.apps import apps
from django.contrib.gis.db.models.fields import GeometryField
from django.contrib.gis.db.models.functions import AsKML, Transform
from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz
from django.core.exceptions import FieldDoesNotExist
from django.db import DEFAULT_DB_ALIAS... |
3a69e048d872c048eb34a197cac325abf88562fc7bc9c0d6a23a42a85e8960ba | """
This module contains useful utilities for GeoDjango.
"""
from django.contrib.gis.utils.ogrinfo import ogrinfo # NOQA
from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect # NOQA
from django.contrib.gis.utils.srs import add_srs_entry # NOQA
from django.core.exceptions import ImproperlyConfigured
t... |
5666f1439462e338ed4f13729aec49a77b777009ed502f37601329f4fb8c3125 | """
This module includes some utility functions for inspecting the layout
of a GDAL data source -- the functionality is analogous to the output
produced by the `ogrinfo` utility.
"""
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.gdal.geometries import GEO_CLASSES
def ogrinfo(data_source, num... |
0c48ad19c241a6c14a5a31f3170410ba422ec0147dd27dbe3532add2f614f956 | """
This module is for inspecting OGR data sources and generating either
models for GeoDjango and/or mapping dictionaries for use with the
`LayerMapping` utility.
"""
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.gdal.field import (
OFTDate, OFTDateTime, OFTInteger, OFTInteger64, OFTReal, O... |
aef4117c46b9941ae75ca30f8f2ac6e4d9a257702effa63026f754ed880278f4 | # 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.
For more information, please consult the GeoDjango documentation:
https://docs.djangoproject.com/en/dev/ref/contrib/gi... |
e0ed6943e0f4937b1c09acf9f02975465d624f60126a8ec31ec82f918df5334c | from django.contrib.gis.gdal import SpatialReference
from django.db import DEFAULT_DB_ALIAS, connections
def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
database=None):
"""
Take a GDAL SpatialReference system and add its information to the
`spatial_ref_sys` ta... |
b8851643232c6d2ad82fea15a85b2686a424606ae1ee91cb215bc83375bf106e | """
This module houses the GeoIP2 object, a wrapper for the MaxMind GeoIP2(R)
Python API (https://geoip2.readthedocs.io/). This is an alternative to the
Python GeoIP2 interface provided by MaxMind.
GeoIP(R) is a registered trademark of MaxMind, Inc.
For IP-based geolocation, this module requires the GeoLite2 Country ... |
af3f0a632c51b96041ad6214d8e5e842c166ee68f8def1dcf55b019221e2e196 | import socket
from pathlib import Path
import geoip2.database
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import validate_ipv46_address
from .resources import City, Country
# Creating the settings dictionary with any settings, if needed.
GEOIP_SETT... |
62595d08641efd4f89f74ce731d0044344b158891f66f92e0fbb9218a1d5706f | def City(response):
return {
'city': response.city.name,
'continent_code': response.continent.code,
'continent_name': response.continent.name,
'country_code': response.country.iso_code,
'country_name': response.country.name,
'dma_code': response.location.metro_code,
... |
7d111a9b53929035abf6e81430d64c167f18f53b9fa510a7dc6963d780d331b4 | from django.forms import * # NOQA
from .fields import ( # NOQA
GeometryCollectionField, GeometryField, LineStringField,
MultiLineStringField, MultiPointField, MultiPolygonField, PointField,
PolygonField,
)
from .widgets import BaseGeometryWidget, OpenLayersWidget, OSMWidget # NOQA
|
27c10c264987ac691956a7fa92d23065b3bc9589a0eb708941b51820b56c54d7 | import logging
from django.conf import settings
from django.contrib.gis import gdal
from django.contrib.gis.geometry import json_regex
from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Widget
from django.utils import translation
logger = logging.getLogger('django.contrib... |
d414d7da2dadaa92c42068e78e16709a5a6e60f1ffbfa6bce0f8b171739cc4a0 | from django import forms
from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.utils.translation import gettext_lazy as _
from .widgets import OpenLayersWidget
class GeometryField(forms.Field):
"""
This is the basic form field for a Geometry. Any textual input that is
accepted by G... |
27b5c8c25cc4ca128917bc7ee07f918e75dace43726ec5febc5a71cf92273506 | from django.contrib.gis.gdal import CoordTransform, SpatialReference
from django.core.serializers.base import SerializerDoesNotExist
from django.core.serializers.json import Serializer as JSONSerializer
class Serializer(JSONSerializer):
"""
Convert a queryset to GeoJSON, http://geojson.org/
"""
def _i... |
22d4dcd23acc9f47d30c12281d58e18ec908ad18ca29811768fe46eaddb52c76 | """
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... |
c15f6f5bd95a94cb4c4848dad7ad7131d655aa669feab47e3c2d86773788c0cb | from django.contrib.gis.gdal.error import GDALException
class OGRGeomType:
"Encapsulate OGR Geometry Types."
wkb25bit = -2147483648
# Dictionary of acceptable OGRwkbGeometryType s and their string names.
_types = {0: 'Unknown',
1: 'Point',
2: 'LineString',
3... |
40a921c955b1ddfc09b7e948c3b723cce3e3220edc0b9e805e59321d747966f2 | """
The OGRGeometry is a wrapper for using the OGR Geometry class
(see http://www.gdal.org/classOGRGeometry.html). 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" unlik... |
66cf5b3869bd452b588619560a7a913428491b82bfa160cf45763296996eaf54 | """
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.
Driver: Wraps an OGR data source driver.
DataSource: Wrapper for the OGR data source object, supports
OGR-su... |
eb8fc12754b2257a81c953e2401d8753aff92a23d27b6204fb95aae2178a6c4a | from ctypes import byref, c_int
from datetime import date, datetime, time
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.prototypes import ds as capi
from django.utils.encoding import force_text
# For more information, see the OG... |
e35a8174cd5b5662a1e16fb940eebede6ac46f22fed650841a0725b0e2090338 | from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.field import Field
from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType
from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api
from django.utils.... |
cb29b22f4bd944c05f885533ade86f69e6ae9c8c4c1f9b9c1a33d17ca8feac0a | from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.ptr import CPointerBase
class GDALBase(CPointerBase):
null_ptr_exception_class = GDALException
|
58db6f9b493e32c6e8e695b6aced7fe5f0ef2d1aa817c0f991af540ba85f7253 | """
This module houses the GDAL & SRS Exception objects, and the
check_err() routine which checks the status code returned by
GDAL/OGR methods.
"""
# #### GDAL & SRS Exceptions ####
class GDALException(Exception):
pass
class SRSException(Exception):
pass
# #### GDAL/OGR error checking codes and routine... |
66c5f840fb60eb4c9597930c8dcfe66e89676c0d2559657ef39656e081d621b5 | """
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)
... |
881a76564e9457e7cf256b08c4173ea54755986e751874d280ec830fe0e0f657 | from ctypes import c_void_p
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
from django.utils.encoding import force_bytes, force_text
class Driver(GDALBase):
"""
Wrap a GDAL/O... |
4cf33cbf29d75650831cbc86d3418213f1666f8b0a347f08e2aad400b54f19b1 | import logging
import os
import re
from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int
from ctypes.util import find_library
from django.contrib.gis.gdal.error import GDALException
from django.core.exceptions import ImproperlyConfigured
logger = logging.getLogger('django.contrib.gis')
# Custom library path set?
try:
... |
35e15befc4f83bc281b8051f31d476b7eb4ae543b818209219ddd96394de9b2a | from ctypes import byref, c_double
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope
from django.contrib.gis.gdal.error import GDALException, SRSException
from django.contrib.gis.gdal.feature import Feature
from django.contrib.gis.gdal.field import OGR... |
8c90c802944f3219ba8103552a6a82ceb82e7f1d4c168e3812eeed93f125bbb9 | """
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... |
1e78b6242c398a156ea2bd87ba9c437dfa24881386d75b6eef811c2a188ef3dc | from django.contrib.admin import (
HORIZONTAL, VERTICAL, AdminSite, ModelAdmin, StackedInline, TabularInline,
autodiscover, register, site,
)
from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin
from django.contrib.gis.admin.widgets import OpenLayersWidget
__all__ = [
'HORIZONTAL', 'VERT... |
4c157cb338346c20d261f62ea57ff0c0f7f9e69068fbc93f29fb8ce45515f2f5 | from django.contrib.admin import ModelAdmin
from django.contrib.gis.admin.widgets import OpenLayersWidget
from django.contrib.gis.db import models
from django.contrib.gis.gdal import OGRGeomType
from django.forms import Media
spherical_mercator_srid = 3857
class GeoModelAdmin(ModelAdmin):
"""
The administrat... |
fd7dcb8be93dab49bbb2806fbb456ede3c3098e0d9593c7d03722cc1829e5cb3 | import logging
from django.contrib.gis.gdal import GDALException
from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Textarea
from django.utils import translation
# Creating a template context that contains Django settings
# values needed by admin map templates.
geo_contex... |
fdd1ce7bf085f63406bf45056ca5304aa2d6725e0440114b274c2d3bc71fe58e | # Copyright (c) 2008-2009 Aryeh Leib Taurog, all rights reserved.
# Released under the New BSD license.
"""
This module contains a base type which provides list-style mutations
without specific data storage methods.
See also http://static.aryehleib.com/oldsite/MutableLists.html
Author: Aryeh Leib Taurog.
"""
from fun... |
387a41668aee0a4febc92059e20a440366562ce0c5087c243b21889f5c311897 | """
This module houses the Geometry Collection objects:
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
"""
from ctypes import byref, c_int, c_uint
from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.geometry im... |
5a33754f0d1a655a71e302b0af05adbc4bc976f80bf909c4ab195948cd6f5db2 | """
This module contains the 'base' GEOSGeometry object -- all GEOS Geometries
inherit from this object.
"""
import re
from ctypes import addressof, byref, c_double
from django.contrib.gis import gdal
from django.contrib.gis.geometry import hex_regex, json_regex, wkt_regex
from django.contrib.gis.geos import prototy... |
7fabb69b502d99860793f2ab202f5fc6ded51ac268909568496131f8390f5b1d | from django.contrib.gis.geos.geometry import GEOSGeometry, hex_regex, wkt_regex
def fromfile(file_h):
"""
Given a string file name, returns a GEOSGeometry. The file may contain WKB,
WKT, or HEX.
"""
# If given a file name, get a real handle.
if isinstance(file_h, str):
with open(file_h... |
0d715a963569ea07fe1345c06df3b52676233d84837c6650d952ed19805c5194 | """
The GeoDjango GEOS module. Please consult the GeoDjango documentation
for more details: https://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
"""
from .collections import ( # NOQA
GeometryCollection, MultiLineString, MultiPoint, MultiPolygon,
)
from .error import GEOSException # NOQA
from .factory impo... |
bc106675a8dcec65e2b137510eb88710945cd22ae3349b1317ca83b47af9a385 | from ctypes import c_uint
from django.contrib.gis import gdal
from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.geometry import GEOSGeometry
class Point(GEOSGeometry):
_minlength = 2
_maxlength = 3
has_cs = True
... |
35d94583997d6a4bc3a7cedaab387d764d00dd91f64c8ddc3aad749a69ae1c19 | from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.ptr import CPointerBase
class GEOSBase(CPointerBase):
null_ptr_exception_class = GEOSException
|
af748d4e7c03048e87b6ec8bde643f88411e2a53aaaaa7641e784da1490ca21c | class GEOSException(Exception):
"The base GEOS exception, indicates a GEOS-related error."
pass
|
02d30fe463c68233cf43383393c1be7f10c55a585dedef8b591e22740ddd5e1f | """
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.
"""
import logging
import os
from ctypes import CDLL, CFUNCT... |
e8272da6585164a8bc52f2be076909191672495b289d427089e43c4b49318fa5 | from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.coordseq import GEOSCoordSeq
from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin
from django.contrib.gis.geos.point import Point
from django.contrib.gis.... |
3a6e4305296db62c547375900066438733dd6f92537bcdbbdbca089888ff9779 | """
Module that holds classes for performing I/O operations on GEOS geometry
objects. Specifically, this has Python implementations of WKB/WKT
reader and writer classes.
"""
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.prototypes.io import (
WKBWriter, WKTWriter, _WKBReade... |
ac97f7e47393c4faeb93fc80f9847d6d094bfe93c329e72e870665730c3c9716 | from .base import GEOSBase
from .prototypes import prepared as capi
class PreparedGeometry(GEOSBase):
"""
A geometry that is prepared for performing certain operations.
At the moment this includes the contains covers, and intersects
operations.
"""
ptr_type = capi.PREPGEOM_PTR
destructor =... |
70c1a0dd73e6db1dd5623918cacf2ba23446eeeccc7b3f05a4eaf61c3f89cbc4 | """
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_double, c_uint
from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.base import... |
8ad7a5fee1af0d0c6b8580f956c42dfe3147c960745e00d6e31930abc7f72a22 | from ctypes import byref, c_uint
from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.libgeos import GEOM_PTR
from django.contrib.gis.geos.linestring import LinearRing
class Polygon(GEOSGeometry):
_minlength = 1
def __i... |
ea9bb4f0f5a75c58457b6c963a868129593cee97089b92d229294894cde1276e | from django.contrib.gis.db.models.fields import (
ExtentField, GeometryCollectionField, GeometryField, LineStringField,
)
from django.db.models.aggregates import Aggregate
from django.utils.functional import cached_property
__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union']
class GeoAggregate(Aggre... |
b8efb7e40ea632bae2b60cdfad9bc37c47b6c3b4d7f41b2785827b28c8ef8a52 | """
The SpatialProxy object allows for lazy-geometries and lazy-rasters. The proxy
uses Python descriptors for instantiating and setting Geometry or Raster
objects corresponding to geographic model fields.
Thanks to Robert Coup for providing this functionality (see #4322).
"""
from django.db.models.query_utils import ... |
051de440079f22fe0ed4d92c8950944a1c2548ee0e08da1419a9fa7424462325 | from django.db.models import * # NOQA isort:skip
from django.db.models import __all__ as models_all # isort:skip
import django.contrib.gis.db.models.functions # NOQA
import django.contrib.gis.db.models.lookups # NOQA
from django.contrib.gis.db.models.aggregates import * # NOQA
from django.contrib.gis.db.models.agg... |
06e49d7f728306c1ad8bc7e7086fc73f9e08fc9ab253fd677dc7188df54699c5 | from collections import defaultdict, namedtuple
from django.contrib.gis import forms, gdal
from django.contrib.gis.db.models.proxy import SpatialProxy
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.geos import (
GeometryCollection, GEOSException, GEOSGeometry, LineString,
Multi... |
77d0a4cd91f1e7a5389fd1b120ed64a9d9a0f4b48a36e70024689e36a64292a5 | import warnings
from decimal import Decimal
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
from django.contrib.gis.db.models.sql import AreaField, DistanceField
from django.contrib.gis.geos import GEOSGeometry
from django.core.exceptions import FieldError
from django.db.models import (... |
ca57862d76b4a0b918ac7e10805577779ce0ce0982a54d83222dc9fd38760e64 | import re
from django.contrib.gis.db.models.fields import BaseSpatialField
from django.db.models.expressions import Expression
from django.db.models.lookups import Lookup, Transform
from django.db.models.sql.query import Query
class RasterBandTransform(Transform):
def as_sql(self, compiler, connection):
... |
cb8ab4374a03a65a2de9d6502059e318fa95b13886c8b4e610cb79fb18fed9be | """
A collection of utility routines and classes used by the spatial
backends.
"""
class SpatialOperator:
"""
Class encapsulating the behavior specific to a GIS operation (used by lookups).
"""
sql_template = None
def __init__(self, op=None, func=None):
self.op = op
self.func = fu... |
a182582fee4300ef8321ca4843b2667aafdcb8a6a9441f3757528b548b3fe625 | from django.contrib.gis.db.models.sql.conversion import (
AreaField, DistanceField,
)
__all__ = [
'AreaField', 'DistanceField',
]
|
806d664d459bdf760afd47f5649460e4c4619024cbb606a30f7c718bbb613830 | """
This module holds simple classes to convert geospatial values from the
database.
"""
from decimal import Decimal
from django.contrib.gis.measure import Area, Distance
from django.db import models
class AreaField(models.FloatField):
"Wrapper for Area values."
def __init__(self, geo_field):
super()... |
9478f1bc5e1b42a96ff1540681784236b7e70e06d4526e86c2361ebdae0728c7 | from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
from django.db.backends.oracle.features import (
DatabaseFeatures as OracleDatabaseFeatures,
)
class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
supports_add_srs_entry = False
supports_geometry_field_introspect... |
d268a43f441b3ac338166da11d753d896bf6dddb35dd45d772ece0164851c43b | import cx_Oracle
from django.db.backends.oracle.introspection import DatabaseIntrospection
class OracleIntrospection(DatabaseIntrospection):
# Associating any OBJECTVAR instances with GeometryField. Of course,
# this won't work right on Oracle objects that aren't MDSYS.SDO_GEOMETRY,
# but it is the only... |
aa7d936b24ee0baecc0fb804668f79e0329ae5d741f42352e2b4e45e4757a3c1 | """
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_... |
35062512f1388a8a1bbcc77bbb6582eef32d0e246afcab62946a6b0faa9f242a | from django.db.backends.oracle.base import (
DatabaseWrapper as OracleDatabaseWrapper,
)
from .features import DatabaseFeatures
from .introspection import OracleIntrospection
from .operations import OracleOperations
from .schema import OracleGISSchemaEditor
class DatabaseWrapper(OracleDatabaseWrapper):
Schem... |
66446bf2b29ac051b869e215ec1afe601892ddd4d252b55d39b5a18405e10b19 | """
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... |
c276f9e8227d12be34138630ed12b584e3986401d124915b34634af44f481d19 | from django.contrib.gis.db.models.fields import GeometryField
from django.db.backends.oracle.schema import DatabaseSchemaEditor
from django.db.backends.utils import strip_quotes, truncate_name
class OracleGISSchemaEditor(DatabaseSchemaEditor):
sql_add_geometry_metadata = ("""
INSERT INTO USER_SDO_GEOM_MET... |
cbd7b0097028419e225c21f37ff6ec470497a421dd2bd1c9c94672ff5022038d | from cx_Oracle import CLOB
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
from django.contrib.gis.geos import GeometryCollection, Polygon
class OracleSpatialAdapter(WKTAdapter):
input_size = CLOB
def __init__(self, geom):
"""
Oracle requires that polygon rings are in prop... |
1785e173e3921ec57e2230763db714fc37159912135d89ce7b6c605ce8ff887a | import re
from django.contrib.gis.db.models import aggregates
class BaseSpatialFeatures:
gis_enabled = True
# Does the database contain a SpatialRefSys model to store SRID information?
has_spatialrefsys_table = True
# Does the backend support the django.contrib.gis.utils.add_srs_entry() utility?
... |
be40f078db04c6629690735269ef46e8ff9f4fe48c74880767ce62df58a15e0d | from django.contrib.gis import gdal
class SpatialRefSysMixin:
"""
The SpatialRefSysMixin is a class used by the database-dependent
SpatialRefSys objects to reduce redundant code.
"""
@property
def srs(self):
"""
Return a GDAL SpatialReference object.
"""
# TODO:... |
23af58cafd0420197419755f753a8c12a5c105c95a8f56532dc07640f5c66a2c | from django.contrib.gis.db.models import GeometryField
from django.contrib.gis.db.models.functions import Distance
from django.contrib.gis.measure import (
Area as AreaMeasure, Distance as DistanceMeasure,
)
from django.db.utils import NotSupportedError
from django.utils.functional import cached_property
class Ba... |
cc171c72b88144af49a308511202ca8ab9169651f38abd07c370640b7928019b | class WKTAdapter:
"""
An adaptor for Geometries sent to the MySQL and Oracle database backends.
"""
def __init__(self, geom):
self.wkt = geom.wkt
self.srid = geom.srid
def __eq__(self, other):
return (
isinstance(other, WKTAdapter) and
self.wkt == oth... |
cf2975df58baaf012a9f7a6b4f330c3a0cbb02e51f70208dc7894a8fd6265d0e | from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
from django.db.backends.mysql.features import (
DatabaseFeatures as MySQLDatabaseFeatures,
)
from django.utils.functional import cached_property
class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
has_spatialrefsys_ta... |
fde7c36cb3732fb05e3bb61627cb22ab5d690291809cb662a8643eae764e14b3 | from MySQLdb.constants import FIELD_TYPE
from django.contrib.gis.gdal import OGRGeomType
from django.db.backends.mysql.introspection import DatabaseIntrospection
class MySQLIntrospection(DatabaseIntrospection):
# Updating the data_types_reverse dictionary with the appropriate
# type for Geometry fields.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.