hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
9ed2fdfd2cc1753708fac4926f6483428fa279f344bc0fcb03486e34140708bb | import json
import math
import re
from decimal import Decimal
from django.contrib.gis.db.models import functions
from django.contrib.gis.geos import (
GEOSGeometry, LineString, Point, Polygon, fromstr,
)
from django.contrib.gis.measure import Area
from django.db import NotSupportedError, connection
from django.db.... |
90f3bc11b11eb2cffab7ce7b2c73239c23883932719f0f1d3aecf0addfceb317 | from unittest import skipUnless
from django.contrib.gis.db.models import F, GeometryField, Value, functions
from django.contrib.gis.geos import Point, Polygon
from django.db import connection
from django.db.models import Count, Min
from django.test import TestCase, skipUnlessDBFeature
from ..utils import postgis
from... |
594e544346c28c13a938592237ef58d41ab3c49d01f238e39b5d6ce0d0b7a0d3 | import tempfile
from io import StringIO
from django.contrib.gis import gdal
from django.contrib.gis.db.models import Extent, MakeLine, Union, functions
from django.contrib.gis.geos import (
GeometryCollection, GEOSGeometry, LinearRing, LineString, MultiLineString,
MultiPoint, MultiPolygon, Point, Polygon, from... |
ca2d4a6806eeef2eee14c7d35a8f6ea2a947b8c945cffc5ec1e4e9d21bb90eea | from xml.dom import minidom
from django.conf import settings
from django.contrib.sites.models import Site
from django.test import TestCase, modify_settings, override_settings
from .models import City
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.sites'})
@override_settings(ROOT_URLCONF='gis_tests.geoap... |
50d3728426c72ef48ecf81626f27ee0d7d318a794006d69c129a70a889f4b9e0 | from django.contrib.gis.db import models
from ..utils import gisfield_may_be_null
class NamedModel(models.Model):
name = models.CharField(max_length=30)
class Meta:
abstract = True
def __str__(self):
return self.name
class Country(NamedModel):
mpoly = models.MultiPolygonField() #... |
dffd0929f6ba5cea04b96b1426f907d825380284072b21212215c5c897821823 | from django.contrib.gis.sitemaps import KMLSitemap, KMZSitemap
from .models import City, Country
sitemaps = {'kml': KMLSitemap([City, Country]),
'kmz': KMZSitemap([City, Country]),
}
|
329ebbb95addfb4bfd048b7e90db3755843bbe2667c48fdc4d66ce1004198bac | from django.contrib.gis import feeds
from .models import City
class TestGeoRSS1(feeds.Feed):
link = '/city/'
title = 'Test GeoDjango Cities'
def items(self):
return City.objects.all()
def item_link(self, item):
return '/city/%s/' % item.pk
def item_geometry(self, item):
... |
a81e2f4c57286155ce875f36a4eaff6149d7f9638c58eb7c7a63221b9819d8a0 | import json
from django.contrib.gis.geos import LinearRing, Point, Polygon
from django.core import serializers
from django.test import TestCase
from .models import City, MultiFields, PennsylvaniaCity
class GeoJSONSerializerTests(TestCase):
fixtures = ['initial']
def test_builtin_serializers(self):
... |
895c9df0630e5b49970b95a2abcc6c9cfce361f57d59e5b55e560b0941390a20 | from django.conf.urls import url
from django.contrib.gis import views as gis_views
from django.contrib.gis.sitemaps import views as gis_sitemap_views
from django.contrib.sitemaps import views as sitemap_views
from .feeds import feed_dict
from .sitemaps import sitemaps
urlpatterns = [
url(r'^feeds/(?P<url>.*)/$', ... |
8180207888a24934b7600023e129e3c6354524a29869bac9d20912003cf3244f | from datetime import datetime
from django.contrib.gis.db.models import Extent
from django.contrib.gis.shortcuts import render_to_kmz
from django.db.models import Count, Min
from django.test import TestCase, skipUnlessDBFeature
from ..utils import no_oracle
from .models import City, PennsylvaniaCity, State, Truth
cl... |
8d894bf4cc043c9b0c84800a7b6afc106573f29693662c8ede6fa732fc20242d | import zipfile
from io import BytesIO
from xml.dom import minidom
from django.conf import settings
from django.contrib.sites.models import Site
from django.test import TestCase, modify_settings, override_settings
from .models import City, Country
@modify_settings(INSTALLED_APPS={'append': ['django.contrib.sites', '... |
3137b0dde70eac4365601bb4912c6fed23af4d3e674ae3b94706fcb7ab00f27a | """
Tests for geography support in PostGIS
"""
import os
from unittest import skipIf, skipUnless
from django.contrib.gis.db import models
from django.contrib.gis.db.models.functions import Area, Distance
from django.contrib.gis.measure import D
from django.db import NotSupportedError, connection
from django.db.models.... |
bf12e6b539ca81fccd1af48882c43c6d7f1d70baf25d98a8865fbe9e40e1c95b | from django.contrib.gis.db import models
class NamedModel(models.Model):
name = models.CharField(max_length=30)
class Meta:
abstract = True
def __str__(self):
return self.name
class City(NamedModel):
point = models.PointField(geography=True)
class Meta:
app_label = 'ge... |
208f604f819c21b8fe13485f6b60ed1eac9a6ec018abc892a63481bc7e6f99eb | from django.core.management import call_command
from django.db import connection
from django.test import TransactionTestCase
class MigrateTests(TransactionTestCase):
"""
Tests running the migrate command in Geodjango.
"""
available_apps = ["gis_tests.gis_migrations"]
def get_table_description(sel... |
f187f335a5c8735862704a98993555abc06a2e80f499a65d835fd3e91f5ac9b3 | from unittest import skipIf
from django.contrib.gis.db.models import fields
from django.contrib.gis.geos import MultiPolygon, Polygon
from django.core.exceptions import ImproperlyConfigured
from django.db import connection, migrations, models
from django.db.migrations.migration import Migration
from django.db.migratio... |
c90458b88e9c2f6d6e22c2211801e39200e491acf9edd6862389cbe73ff9800f | # Copyright (c) 2008-2009 Aryeh Leib Taurog, http://www.aryehleib.com
# All rights reserved.
#
# Modified from original contribution by Aryeh Leib Taurog, which was
# released under the New BSD license.
import unittest
from django.contrib.gis.geos.mutable_list import ListMixin
class UserListA(ListMixin):
_mytyp... |
b4ab0417ea67b441bce0070d2cea384f7730ce66ab4ce12fc924595d5a26f137 | # Copyright (c) 2008-2009 Aryeh Leib Taurog, all rights reserved.
# Modified from original contribution by Aryeh Leib Taurog, which was
# released under the New BSD license.
import unittest
from django.contrib.gis.geos import (
LinearRing, LineString, MultiPoint, Point, Polygon, fromstr,
)
def api_get_distance(... |
e682a0bf31d117cc816da2bf96c75da3ffa3af09a5ee0564697d3836fc548f45 | import binascii
from django.contrib.gis.geos import (
GEOSGeometry, Point, Polygon, WKBReader, WKBWriter, WKTReader, WKTWriter,
)
from django.test import SimpleTestCase
class GEOSIOTest(SimpleTestCase):
def test01_wktreader(self):
# Creating a WKTReader instance
wkt_r = WKTReader()
w... |
c85b425678d92fc1a2fc11859bb32bbff5af5e6aeaa7881df0e27f49ef3870ad | from django.contrib.gis.geos import LineString
from django.test import SimpleTestCase
class GEOSCoordSeqTest(SimpleTestCase):
def test_getitem(self):
coord_seq = LineString([(x, x) for x in range(2)]).coord_seq
for i in (0, 1):
with self.subTest(i):
self.assertEqual(co... |
7f915fde6fba6b755e0b01eadaa92d3bdb3621aa6097467304781b950a755ad4 | import ctypes
import itertools
import json
import pickle
import random
from binascii import a2b_hex
from io import BytesIO
from unittest import mock
from django.contrib.gis import gdal
from django.contrib.gis.geos import (
GeometryCollection, GEOSException, GEOSGeometry, LinearRing, LineString,
MultiLineString... |
b5d52620bf052fba4c73b75be51111252611b45d0477a19c0216e92c1b066157 | from django.contrib.gis.db.models import Collect, Count, Extent, F, Union
from django.contrib.gis.geos import GEOSGeometry, MultiPoint, Point
from django.db import NotSupportedError, connection
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import override_settings
from django.utils import... |
eca7e0fe046364a72eed6ceafade608995e68814db2c285eb8dc4e30f235ff45 | from django.contrib.gis.db import models
class SimpleModel(models.Model):
class Meta:
abstract = True
class Location(SimpleModel):
point = models.PointField()
def __str__(self):
return self.point.wkt
class City(SimpleModel):
name = models.CharField(max_length=50)
state = model... |
98d0ed3a9231034beb9af118257c5d3fbc3a985ce84305fafb7e41d343b75934 | import os
import struct
import tempfile
from django.contrib.gis.gdal import GDAL_VERSION, GDALRaster
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.raster.band import GDALBand
from django.contrib.gis.shortcuts import numpy
from django.test import SimpleTestCase
from ..data.raster... |
f23ccd79f8a3160184ea5a9940bd86ccaf155e9d4131580700fd0f179dd73752 | import os
import re
from django.contrib.gis.gdal import (
GDAL_VERSION, DataSource, Envelope, GDALException, OGRGeometry,
)
from django.contrib.gis.gdal.field import OFTInteger, OFTReal, OFTString
from django.test import SimpleTestCase
from ..test_data import TEST_DATA, TestDS, get_ds_file
wgs_84_wkt = (
'GE... |
49c9a92118c056b62452b5825b37e818580fa82e7682564c67341455d71ffadd | import json
import pickle
from django.contrib.gis.gdal import (
CoordTransform, GDALException, OGRGeometry, OGRGeomType, SpatialReference,
)
from django.template import Context
from django.template.engine import Engine
from django.test import SimpleTestCase
from ..test_data import TestDataMixin
class OGRGeomTes... |
61518a35f5ab8ba0d3f8f9a0d5b03939e1e71e55de49e574c4b359bbe994a9f0 | import unittest
from django.contrib.gis.gdal import Envelope, GDALException
class TestPoint:
def __init__(self, x, y):
self.x = x
self.y = y
class EnvelopeTest(unittest.TestCase):
def setUp(self):
self.e = Envelope(0, 0, 5, 5)
def test01_init(self):
"Testing Envelope i... |
cedeea94d5aa962684e63cff45f7f8d262d6876cb39e9a9a5edeec85735bbf88 | import unittest
from django.contrib.gis.gdal import (
CoordTransform, GDALException, SpatialReference, SRSException,
)
class TestSRS:
def __init__(self, wkt, **kwargs):
self.wkt = wkt
for key, value in kwargs.items():
setattr(self, key, value)
WGS84_proj = '+proj=longlat +ellps=... |
43ddea600f8ca9cb8b6c84f94fcb8aebed4d2242086f84d27c79add7be1ea9cf | import unittest
from unittest import mock
from django.contrib.gis.gdal import Driver, GDALException
valid_drivers = (
# vector
'ESRI Shapefile', 'MapInfo File', 'TIGER', 'S57', 'DGN', 'Memory', 'CSV',
'GML', 'KML',
# raster
'GTiff', 'JPEG', 'MEM', 'PNG',
)
invalid_drivers = ('Foo baz', 'clucka', ... |
09c1a4db8cd94f806dd20c567c391c8538e03a609e4d45baf3cbb9fa7731200e | from django.contrib.gis import admin
from django.contrib.gis.geos import Point
from django.test import TestCase, override_settings
from .admin import UnmodifiableAdmin
from .models import City, site
@override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoadmin.urls')
class GeoAdminTest(TestCase):
def test_... |
c8b0524473ee30f6a1c18b5f32d959ead6a354d2cddf44d03c49eb2d1ecd73ab | from django.contrib.gis.db import models
from ..admin import admin
class City(models.Model):
name = models.CharField(max_length=30)
point = models.PointField()
class Meta:
app_label = 'geoadmin'
def __str__(self):
return self.name
site = admin.AdminSite(name='admin_gis')
site.regi... |
86321e50238fdb5021d4414a8c64b070f8b0f32dd9c57203618b5e0f1a26b038 | from django.contrib.gis import admin
class UnmodifiableAdmin(admin.OSMGeoAdmin):
modifiable = False
|
fb2537106a4b446ddda12fe69b37e14dfdb0580e5031d02e360ba145bd295e75 | from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
]
|
a94dfd798ce3e025819deb068623e8ce8218623d2be14b9b0009c8d3afb74a1c | """
Text-based test rasters
"""
JSON_RASTER = """{
"srid": 4326,
"origin": [0, 0],
"scale": [-1, 1],
"skew": [0, 0],
"width": 5,
"height": 5,
"nr_of_bands": 1,
"bands": [{"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 2... |
980dba6945a4c4016a79d95eb756ff6ecef0e614f840e7597b74dd304459c33a | from django.contrib.gis.db import models
from django.db import connection, migrations
ops = [
migrations.CreateModel(
name='Neighborhood',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(ma... |
7345280adf477f30739bf3e933c591c46c61e8464b4f165a226de02238922072 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("--list", action="store_true", dest="list", help="Print all options")
def handle(self, *args, **options):
pass
|
3f920835d9a60d7f7f570f2d69147921dee187fd975f0de516376c6139c8afe8 | from django.db import models
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
def __str__(self):
return self.headline
class Meta:
app_label = 'fixtures_model_package'
ordering = ('-pub_date'... |
ee1c5a624395a8072277153562a73231e399ffb768a4280f4d632953a9597b24 | from .article import (
Article, ArticleIdea, ArticleTag, ArticleTranslation, NewsArticle,
)
from .customers import Address, Contact, Customer
from .empty_join import SlugPage
from .person import Country, Friendship, Group, Membership, Person
__all__ = [
'Address', 'Article', 'ArticleIdea', 'ArticleTag', 'Artic... |
51769de3dbbd27dbd3d7a3af076c94901d048c6801be4e689e7b7aa4ef680a74 | from django.db import models
from django.db.models.fields.related import (
ForeignObjectRel, ReverseManyToOneDescriptor,
)
from django.db.models.lookups import StartsWith
from django.db.models.query_utils import PathInfo
class CustomForeignObjectRel(ForeignObjectRel):
"""
Define some extra Field methods s... |
766489150687564309b018875a4e9b9161d5971a6554f80670bf1d5c54f0a3e1 | import datetime
from django.db import models
class Country(models.Model):
# Table Column Fields
name = models.CharField(max_length=50)
def __str__(self):
return self.name
class Person(models.Model):
# Table Column Fields
name = models.CharField(max_length=128)
person_country_id = m... |
217d6f34b6bee194953e91c440d8f51e514530aace9aeb47de5deaea9aba3779 | from django.db import models
from django.db.models.fields.related import ForeignObject
class Address(models.Model):
company = models.CharField(max_length=1)
customer_id = models.IntegerField()
class Meta:
unique_together = [
('company', 'customer_id'),
]
class Customer(model... |
36c878bd621715958ac25c36f38da3032cb9c65b0dd2bffd3317ccb285f81700 | from django.db import models
from django.db.models.fields.related import ForwardManyToOneDescriptor
from django.utils.translation import get_language
class ArticleTranslationDescriptor(ForwardManyToOneDescriptor):
"""
The set of articletranslation should not set any local fields.
"""
def __set__(self,... |
c233f0778b522b481733c8ba4988f827b119e456d9814e2dc31b101eef9a80c7 | from django.db import models
class Author(models.Model):
first_name = models.CharField(max_length=128)
last_name = models.CharField(max_length=128)
class Editor(models.Model):
name = models.CharField(max_length=128)
bestselling_author = models.ForeignKey(Author, models.CASCADE)
class Book(models.M... |
fc0082ee0b89c36658cffe59d022f5ef27440ce48335652a592a0a2f3dfbca0e | from django.db import models
# Since the test database doesn't have tablespaces, it's impossible for Django
# to create the tables for models where db_tablespace is set. To avoid this
# problem, we mark the models as unmanaged, and temporarily revert them to
# managed during each test. We also set them to use the same... |
4bb5f6af279b8152a2d8f4c50f74be32643bf348c3af8717dd173e98ba7992ea | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sites', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='CustomArticle',
fields=[
('id', models.AutoField(verbose_name='ID', serialize... |
84e81d8780ba36cccc5f2dcf5153aee7e5315ed199c9b6d6e789fbc73ed02aa5 | # This package is used to test the --exclude option of
# the makemessages and compilemessages management commands.
# The locale directory for this app is generated automatically
# by the test cases.
from django.utils.translation import gettext as _
# Translators: This comment should be extracted
dummy1 = _("This is a... |
a6d7440fdc00ff5a54d1f4fb5380b401974cd3687da636df55fb8b869f8e736f | #!/usr/bin/env python
"""
Helper script to update sampleproject's translation catalogs.
When a bug has been identified related to i18n, this helps capture the issue
by using catalogs created from management commands.
Example:
The string "Two %% Three %%%" renders differently using trans and blocktrans.
This issue i... |
80b8ea9e5f4dd44baf6f68b4cb51c0bff9c5b00da37bf3f9aa297d17bea5f71d | #!/usr/bin/env python
import os
import sys
sys.path.append(os.path.abspath(os.path.join('..', '..', '..')))
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sampleproject.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv... |
c7e2a4505513577ea87cf6ce5a7d627d027b08d3b2fb76f41ba86f21bc2616e9 | from django.utils.translation import gettext as _, ngettext
# Translators: This comment should be extracted
dummy1 = _("This is a translatable string.")
# This comment should not be extracted
dummy2 = _("This is another translatable string.")
# This file has a literal with plural forms. When processed first, makemes... |
f3f438f643e88bb78c7ec9639c9864e5a6a18ce8d872f3cbd8a624c78f5bd93a | import os
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponsePermanentRedirect
from django.middleware.locale import LocaleMiddleware
from django.template import Context, Template
from django.test import SimpleTestCase, override_settings
from dja... |
991755ea6f56c9c0dbead0e1f70c7646a2ea80bff8503a7db9f239c1d1643f8a | # Sample project used by test_extraction.CustomLayoutExtractionTests
from django.utils.translation import gettext as _
string = _("This is a project-level string")
|
bddd4f426f64995d6e6f84c80fa37727423489e7f2c71eb867be29997b7d8231 | import os
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
from django.utils import translation
@override_settings(
USE_I18N=True,
LOCALE_PATHS=[
os.path.join(os.path.dirname(__file__), 'locale'),
],
LANGUAGE_CODE='en',
LANGUAG... |
ac6a5625dc9831aee0e890914a912e7f47ce6a290045601f128145f65edc99a4 | from django.conf.urls import url
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
url(r'^foo/$', view, name='not-prefixed-included-url'),
]
|
38ac260e15f92de1ff4b814515588ee71f395ba31e14786e7f1c24c1eaf799c6 | from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import gettext_lazy as _
urlpatterns = i18n_patterns(
url(_(r'^account/'), include('i18n.patterns.urls.wrong_namespace', namespace='account')),
)
|
cfba403a2cf19f986232d8f8304a581b911157f3e7eb39b678359c60340c96a1 | from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
url(r'^not-prefixed/$', view, name='not-prefixed'),... |
0592747dad4e472de9fa09bfe4aac4323060ae0721d14a7bebc61574a5781c88 | from django.conf.urls import url
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
url(r'^nl/foo/', view, name='not-translated'),
]
|
c5aaa7dc6eb5639db851e251fca3522a3490b32c7d5ddb05577262627243ddee | from django.conf.urls import url
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
app_name = 'account'
urlpatterns = i18n_patterns(
url(_(r'^register/$'), vie... |
b97e3d6f9fecd2dd4bb7a2d8a9814910c65b680051bf20db5a348631c87f16ac | from django.conf.urls import url
from django.urls import path
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
app_name = 'account'
urlpatterns = [
url(_(r'^register/$'), view, name='register'),
url(_(r... |
d6d6fb3329436823fe54e212448a95b58acf1fcc0a2d383edde6335eeb15fa70 | from django.conf.urls import url
from django.conf.urls.i18n import i18n_patterns
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = i18n_patterns(
url(r'^prefixed/$', view, name='prefixed'),
)
|
6ff5f8e304b458873b332bf93e372473700367f2197d24f325b5a505784d7435 | # A user-defined format
CUSTOM_DAY_FORMAT = 'd/m/Y CUSTOM'
|
f2cd74a1430fb8d8ff18fd786d45bce0c8e0f56873ad8197b872a29d78d9f29f | from django.utils.translation import gettext as _
string = _("This app has a locale directory")
|
b2e23f2843079446be1e06df0b6d278b24e7bce3628164478272878769497a7a | from django.utils.translation import gettext as _
string = _("This app has no locale directory")
|
b2e99fd7ae01768de0c2e601027732dad93c9b100ab95885662e47a6d99eb053 | from django.db import migrations, models
class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
"Signal",
[
("id", models.AutoField(primary_key=True)),
],
),
]
|
4fe518dbeaa6ffc56f2fa7189c294c5e8343476c22efd79837c5560f11f3bd5b | """
An interpreted text role to link docs to CVE issues. To use: :cve:`XXXXX`
"""
from docutils import nodes, utils
from docutils.parsers.rst import roles
def cve_role(name, rawtext, text, lineno, inliner, options=None, content=None):
if options is None:
options = {}
url_pattern = inliner.document.se... |
43494feb1dea648cdd5fcc028e815934eb9f57059cff00477dd2b216cfd4db05 | """
An interpreted text role to link docs to Trac tickets.
To use: :ticket:`XXXXX`
Based on code from psycopg2 by Daniele Varrazzo.
"""
from docutils import nodes, utils
from docutils.parsers.rst import roles
def ticket_role(name, rawtext, text, lineno, inliner, options=None, content=None):
if options is None:
... |
d6bf6762fd2423982d611c5b8e580cd1578bd8409c360b89e2b1a1b0c48a391f | """
Sphinx plugins for Django documentation.
"""
import json
import os
import re
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from docutils.statemachine import ViewList
from sphinx import addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.directives import ... |
6470cf337cee5569d78651832b937dce9906921d8d4e86e7593941ca127c76f9 | import os
import sys
from distutils.sysconfig import get_python_lib
from setuptools import find_packages, setup
CURRENT_PYTHON = sys.version_info[:2]
REQUIRED_PYTHON = (3, 6)
# This check and everything above must remain compatible with Python 2.7.
if CURRENT_PYTHON < REQUIRED_PYTHON:
sys.stderr.write("""
======... |
7cdee89436e7d86c0d89313bc9b2ce85bda1f370ed227c8c91bf3df754937d01 | #!/usr/bin/env python
#
# This Python file contains utility scripts to manage Django translations.
# It has to be run inside the django git root directory.
#
# The following commands are available:
#
# * update_catalogs: check for new strings in core and contrib catalogs, and
# output how much string... |
5dd492d49308ec2f7a82bd8817d936f2f22e04870ff2e4cf347f7aff93a5e286 | """
This module collects helper functions and classes that "span" multiple levels
of MVC. In other words, these functions/classes introduce controlled coupling
for convenience's sake.
"""
from django.http import (
Http404, HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect,
)
from django.template imp... |
8dd17cca5d42479781c23ef83ef187a8b89078ff43586b74cb15fe63cfc15b2b | from django.utils.version import get_version
VERSION = (3, 0, 0, 'alpha', 0)
__version__ = get_version(VERSION)
def setup(set_prefix=True):
"""
Configure the settings (this happens as a side effect of accessing the
first setting), configure logging and populate the app registry.
Set the thread-local... |
408bbdc0a396eac12cc3e1417e6b57fc7754313faefece47178dd4a43b48072c | #!/usr/bin/env python
import argparse
import atexit
import copy
import os
import shutil
import socket
import subprocess
import sys
import tempfile
import warnings
try:
import django
except ImportError as e:
raise RuntimeError(
'Django module not found, reference tests/README.rst for instructions.'
... |
8e70c8eba1523fa85c39f336f28693a757f22e1b8e67671cd8231ddd160af301 | # Django documentation build configuration file, created by
# sphinx-quickstart on Thu Mar 27 09:06:53 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't picklable (module imports are okay... |
b28b3509aaa2d1a51e75db42fe443abf143749abb68f4d987a3d4e1d5c4948e4 | import threading
import weakref
from django.utils.inspect import func_accepts_kwargs
def _make_id(target):
if hasattr(target, '__func__'):
return (id(target.__self__), id(target.__func__))
return id(target)
NONE_ID = _make_id(None)
# A marker for caching
NO_RECEIVERS = object()
class Signal:
... |
1b5e28e89308667ac44820d9d9a6fd057d61dc53ae38fa66d7ae2e7cecf2eee6 | import sys
import unittest
from contextlib import contextmanager
from django.test import LiveServerTestCase, tag
from django.utils.decorators import classproperty
from django.utils.module_loading import import_string
from django.utils.text import capfirst
class SeleniumTestCaseBase(type(LiveServerTestCase)):
# L... |
1d25e9ad981e5ba887fa39cd81e96056a49bdebd9a5cf25f08ccedbc2228616f | import ctypes
import itertools
import logging
import multiprocessing
import os
import pickle
import textwrap
import unittest
from importlib import import_module
from io import StringIO
from django.core.management import call_command
from django.db import connections
from django.test import SimpleTestCase, TestCase
fro... |
5b7aebd46a5a411129cba239e3ca87ea343c3ae9e7d4d9c0002a8c257791ee1f | import json
import mimetypes
import os
import re
import sys
from copy import copy
from functools import partial
from http import HTTPStatus
from importlib import import_module
from io import BytesIO
from urllib.parse import unquote_to_bytes, urljoin, urlparse, urlsplit
from django.conf import settings
from django.core... |
e8e22095c3b89682047196eb5cb86de377225bf776f3f853cf91122ccfdd9723 | import difflib
import json
import posixpath
import sys
import threading
import unittest
import warnings
from collections import Counter
from contextlib import contextmanager
from copy import copy
from difflib import get_close_matches
from functools import wraps
from unittest.util import safe_repr
from urllib.parse impo... |
3e73a48bc3983833f9c121e5e20a6de980ff8d86a0cf697c8b236642398b8a57 | """Compare two HTML documents."""
import re
from html.parser import HTMLParser
# ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020
# SPACE.
# https://infra.spec.whatwg.org/#ascii-whitespace
ASCII_WHITESPACE = re.compile(r'[\t\n\f\r ]+')
def normalize_whitespace(string):
return ASCII_WHI... |
4de3b1a8a3ea332f5dc26f9408a4d7f1e5ad3ab5d20bc193b7594fb628cdedbf | import logging
import re
import sys
import time
import warnings
from contextlib import contextmanager
from functools import wraps
from io import StringIO
from itertools import chain
from types import SimpleNamespace
from unittest import TestCase, skipIf, skipUnless
from xml.dom.minidom import Node, parseString
from dj... |
d1e5b3cbadd6446604bccdb1e631cdb263035efc5c1d8e311dbb1207fe4ea5ab | import functools
import sys
import threading
import warnings
from collections import Counter, defaultdict
from functools import partial
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from .config import AppConfig
class Apps:
"""
A registry that stores the configuration of insta... |
90930f6ee1a26bc0086771ca101b0b042d84974077366a91c5271e024e992eea | import os
from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import module_has_submodule
MODELS_MODULE_NAME = 'models'
class AppConfig:
"""Class representing a Django application and its configuration."""
def __init__(self, app_name,... |
61ccb3f41661140f91369b9fda02dfb957af4732588ad08c797336e35d6837a7 | """
Views and functions for serving static files. These are only to be used
during development, and SHOULD NOT be used in a production setting.
"""
import mimetypes
import posixpath
import re
from pathlib import Path
from django.http import (
FileResponse, Http404, HttpResponse, HttpResponseNotModified,
)
from dja... |
f395b590c69e5b645d3bfd95d0add618d231430f343cd87055ecb0424ebc4416 | import itertools
import json
import os
import re
from urllib.parse import unquote
from django.apps import apps
from django.conf import settings
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from django.template import Context, Engine
from django.urls import translate_url
from django.utils.fo... |
705c5fbe3c6ecaf57d7745f9150101e8f779da5091731939635c660bf36c331f | from urllib.parse import quote
from django.http import (
HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound,
HttpResponseServerError,
)
from django.template import Context, Engine, TemplateDoesNotExist, loader
from django.views.decorators.csrf import requires_csrf_token
ERROR_404_TEMPLATE_NAM... |
8354435f99ee9f770b230d42f3a0f0241d72b7e13013ab599c516b9897371f89 | import functools
import re
import sys
import types
from pathlib import Path
from django.conf import settings
from django.http import HttpResponse, HttpResponseNotFound
from django.template import Context, Engine, TemplateDoesNotExist
from django.template.defaultfilters import pprint
from django.urls import Resolver404... |
9662293ead6c67168203f66d5f5a74512945101cae642a20ad936697c84bd4db | """
Settings and configuration for Django.
Read values from the module specified by the DJANGO_SETTINGS_MODULE environment
variable, and then from django.conf.global_settings; see the global_settings.py
for a list of all possible variables.
"""
import importlib
import os
import time
import traceback
import warnings
f... |
23983060bbb5d33d72f580ba15ac168e5d553a49b716f5590b3da2c12dc31fea | """
Default Django settings. Override these with settings in the module pointed to
by the DJANGO_SETTINGS_MODULE environment variable.
"""
# This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings.
def gettext_noop(s):
return s
####... |
12780d2ad9360c5074ee5c1ded5285f6d432f6d21281961c1fb94adeedfc9c8a | "Functions that help with dynamically creating decorators for views."
from functools import partial, update_wrapper, wraps
class classonlymethod(classmethod):
def __get__(self, instance, cls=None):
if instance is not None:
raise AttributeError("This method is available only on the class, not ... |
f6cbe3b09f4d5603ae4a682879c9818f63a5024ea46d90653cb9cf4f18f1c9f7 | # These classes override date and datetime to ensure that strftime('%Y')
# returns four digits (with leading zeros) on years < 1000.
# https://bugs.python.org/issue13305
#
# Based on code submitted to comp.lang.python by Andrew Dalke
#
# >>> datetime_safe.date(10, 8, 2).strftime("%Y/%m/%d was a %A")
# '0010/08/02 was a... |
2c568b0bcb48d21483919ec9f06b3c71e389675cff4a484beb6578be2f50e234 | import functools
import itertools
import logging
import os
import pathlib
import signal
import subprocess
import sys
import threading
import time
import traceback
import weakref
from collections import defaultdict
from pathlib import Path
from types import ModuleType
from zipimport import zipimporter
from django.apps ... |
d87aa50f4588a9a2c39f97ab71d56a75879b5c47633a46ddbb65428a868c721e | import html.entities
import re
import unicodedata
import warnings
from gzip import GzipFile
from io import BytesIO
from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.functional import SimpleLazyObject, keep_lazy_text, lazy
from django.utils.translation import gettext as _, gettext_lazy, pg... |
06e74f6fc9ef5765ef461183d0452ee062675441e205685c4465ef436d549a7f | """Functions to parse datetime objects."""
# We're using regular expressions rather than time.strptime because:
# - They provide both validation and parsing.
# - They're more flexible for datetimes.
# - The date/datetime/time constructors produce friendlier error messages.
import datetime
import re
from django.utils... |
00156bb4c5f555bbf7cfc04cf3ea1cd818b51719b04e0bd2a9a7d93348315633 | """
Utilities for XML generation/parsing.
"""
import re
from xml.sax.saxutils import XMLGenerator
class UnserializableContentError(ValueError):
pass
class SimplerXMLGenerator(XMLGenerator):
def addQuickElement(self, name, contents=None, attrs=None):
"Convenience method for adding an element with no... |
0301789af270e025e11602f203b1c2812658ebcb21f1a419c4368bf4d7b22190 | class CyclicDependencyError(ValueError):
pass
def topological_sort_as_sets(dependency_graph):
"""
Variation of Kahn's algorithm (1962) that returns sets.
Take a dependency graph as a dictionary of node => dependencies.
Yield sets of items in topological order, where the first set contains
al... |
291576f9f948f8408000fd552bb99ab93b5c325c001a96ee49d92f22ec70c415 | from decimal import Decimal
from django.conf import settings
from django.utils.safestring import mark_safe
def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
force_grouping=False, use_l10n=None):
"""
Get a number (as a number or string), and return it as a string,
u... |
da2d59bce066531c6e7dfea743e435828ed56788d2941231ade224bab0fcf50d | """
Timezone-related classes and functions.
"""
import functools
import warnings
from contextlib import ContextDecorator
from datetime import datetime, timedelta, timezone, tzinfo
from threading import local
import pytz
from django.conf import settings
from django.utils.deprecation import RemovedInDjango31Warning
_... |
1ca8be0c5921e8f0a65b1c1084a46f30f0cfe40b9f0ff058dc3a593358af9cda | """
A class for storing a tree graph. Primarily used for filter constructs in the
ORM.
"""
import copy
from django.utils.hashable import make_hashable
class Node:
"""
A single internal node in the tree graph. A Node should be viewed as a
connection (the root) with the children being either leaf nodes or... |
69013e25931607ef326d8fe39299137ad21ca1f748313b680f19f3824d674aec | import inspect
import warnings
class RemovedInDjango31Warning(DeprecationWarning):
pass
class RemovedInDjango40Warning(PendingDeprecationWarning):
pass
RemovedInNextVersionWarning = RemovedInDjango31Warning
class warn_about_renamed_method:
def __init__(self, class_name, old_method_name, new_method_n... |
65be19f7d0da7912e4f914c68abe0b07e2467edef0d74224fd1c148c973eeec9 | import codecs
import datetime
import locale
import warnings
from decimal import Decimal
from urllib.parse import quote
from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.functional import Promise
class DjangoUnicodeDecodeError(UnicodeDecodeError):
def __init__(self, obj, *args):
... |
a35e19cc4c804fddfd4ebc6b9461390bc4f005949893e3e05797681063123edf | """
Django's standard crypto functions and utilities.
"""
import hashlib
import hmac
import secrets
from django.conf import settings
from django.utils.encoding import force_bytes
def salted_hmac(key_salt, value, secret=None):
"""
Return the HMAC-SHA1 of 'value', using a key generated from key_salt and a
... |
42591a8ddcd755fb5995ff55205faf94e2bd33f52912b2b60c7fba7024c998b4 | import calendar
import datetime
from django.utils.html import avoid_wrapping
from django.utils.timezone import is_aware, utc
from django.utils.translation import gettext, ngettext_lazy
TIME_STRINGS = {
'year': ngettext_lazy('%d year', '%d years'),
'month': ngettext_lazy('%d month', '%d months'),
'week': n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.