hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
3eb63d1e3b547cba16f629c5e2514922b9fdbf09adcb19cf28e3607ab00cd429 | import json
from django.contrib.postgres import lookups
from django.contrib.postgres.forms import SimpleArrayField
from django.contrib.postgres.validators import ArrayMaxLengthValidator
from django.core import checks, exceptions
from django.db.models import Field, IntegerField, Transform
from django.db.models.fields.m... |
05f43789f9bb3464e5287a98bdace0696a037fa183462a83c0071d3209d9d1ca | import json
from django.contrib.postgres import forms, lookups
from django.contrib.postgres.fields.array import ArrayField
from django.core import exceptions
from django.db.models import Field, TextField, Transform
from django.db.models.fields.mixins import CheckFieldDefaultMixin
from django.utils.translation import g... |
499202f85ebaf6c4103d55be9b84a88149d02ea5182bb2770a84a47c47aa0065 | import json
from psycopg2.extras import Json
from django.contrib.postgres import forms, lookups
from django.core import exceptions
from django.db.models import (
Field, TextField, Transform, lookups as builtin_lookups,
)
from django.db.models.fields.mixins import CheckFieldDefaultMixin
from django.utils.translati... |
4f174832bd45790d55877f01fceda44d366f91e919e709cec74039ead0ecf56d | from django.contrib.gis.db.backends.base.adapter import WKTAdapter
from django.contrib.gis.db.backends.base.operations import (
BaseSpatialOperations,
)
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.db.models import aggregates
from django.contrib.gis.geos.geometry import G... |
4e975cde2c2c342afd2606486198c56b61541bde63c28acf9e066725b57cc8d0 | import datetime
import importlib
import io
import os
import sys
from unittest import mock
from django.apps import apps
from django.core.management import CommandError, call_command
from django.db import (
ConnectionHandler, DatabaseError, connection, connections, models,
)
from django.db.backends.base.schema impor... |
5088e18520ce9264c1611c84782bdbcaa7be2074b85ecef436750f4e61b348bf | import compileall
import os
from django.db import connection, connections
from django.db.migrations.exceptions import (
AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError,
)
from django.db.migrations.loader import MigrationLoader
from django.db.migrations.recorder import MigrationRecorder
from django.... |
e6a9d7865de6a32729a867c016cb427761fa6f668829f553104164fc788c9136 | import functools
import re
from unittest import mock
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import AbstractBaseUser
from django.core.validators import RegexValidator, validate_slug
from django.db import connection, models
from django.db.migrations.autodetector imp... |
6d8bc755b5c05f70da6422c94ee2538da8dcf570ed30745b4be42cd97535d2c8 | import unittest
from io import StringIO
from unittest import mock
from unittest.suite import _DebugResult
from django.test import SimpleTestCase
class ErrorTestCase(SimpleTestCase):
def raising_test(self):
self._pre_setup.assert_called_once_with()
raise Exception('debug() bubbles up exceptions be... |
8def2cca3c940eac5ad4faefd163d4f8cb892be90196e2b8ed3dbc56be974a19 | import decimal
import enum
import json
import unittest
import uuid
from django import forms
from django.core import checks, exceptions, serializers, validators
from django.core.exceptions import FieldError
from django.core.management import call_command
from django.db import IntegrityError, connection, models
from dja... |
9349c2fb8bdc72f964b0f6ad587d1d0e1f9aa290fedd4e09f53aefd7196751df | import datetime
import operator
import uuid
from decimal import Decimal
from django.core import checks, exceptions, serializers
from django.core.serializers.json import DjangoJSONEncoder
from django.db import connection
from django.db.models import Count, F, OuterRef, Q, Subquery
from django.db.models.expressions impo... |
002b836f2afc3eb87e197436e35703fa984bea19b1310fadc9eafb07b1edb866 | import json
from django.core import checks, exceptions, serializers
from django.db import connection
from django.db.models.expressions import OuterRef, RawSQL, Subquery
from django.forms import Form
from django.test.utils import CaptureQueriesContext, isolate_apps
from . import PostgreSQLSimpleTestCase, PostgreSQLTes... |
ad9c5fd9bdc8ad697071cf46227ea15655b214faf00f2279f655ee321c22831c | import gzip
import random
import re
import struct
from io import BytesIO
from urllib.parse import quote
from django.conf import settings
from django.core import mail
from django.core.exceptions import PermissionDenied
from django.http import (
FileResponse, HttpRequest, HttpResponse, HttpResponseNotFound,
Http... |
4374094792ac3db0e6f78a5e8bcf00db1e0b0e51f33c62588d1b8f71fc011330 | """
Regression tests for the Test Client, especially the customized assertions.
"""
import itertools
import os
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.http import HttpResponse
from django.template import (
Context, RequestConte... |
0de74c265f97ff1ca2e84e488b2f558625d55adb1a683108ea575c5730a253f2 | from django.urls import include, path
from django.views.generic import RedirectView
from . import views
urlpatterns = [
path('', include('test_client.urls')),
path('no_template_view/', views.no_template_view),
path('staff_only/', views.staff_only_view),
path('get_view/', views.get_view),
path('re... |
b383a10246ff18b619bb6185c97184e79fa55cf79c4893fd831ef1b6d599498a | from urllib.parse import urlencode
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from django.shortcuts import render
from django.template.loader import render_to_string
from django.test import Client
f... |
f613e2804195418af41f5cc87af5eef68c62c75d3e9e8b145a1f538b73588d1c | # Unit tests for cache framework
# Uses whatever cache backend is set in the test settings file.
import copy
import io
import os
import pickle
import re
import shutil
import tempfile
import threading
import time
import unittest
from unittest import mock
from django.conf import settings
from django.core import manageme... |
9fa5752a01ed3a5a8c6d721d6c14bc80142ed02670bce1df046e06322f0c7755 | from unittest import mock
from django.test import SimpleTestCase
from django.utils.functional import cached_property, classproperty, lazy
class FunctionalTests(SimpleTestCase):
def test_lazy(self):
t = lazy(lambda: tuple(range(3)), list, tuple)
for a, b in zip(t(), range(3)):
self.ass... |
e40637bff581e57a2c906476a3c369e1bfa9e3da948dc87263facafa41ab8e4b | from django.http import HttpResponse
from django.template import engines
from django.template.response import TemplateResponse
from django.test import RequestFactory, SimpleTestCase
from django.utils.decorators import decorator_from_middleware
class ProcessViewMiddleware:
def process_view(self, request, view_func... |
759d3ae11a21177220906922f66a1cfc6ccbb0e6ed66d33274fc9ebdc729a2c6 | import datetime
import itertools
import unittest
from copy import copy
from unittest import mock
from django.core.management.color import no_style
from django.db import (
DatabaseError, IntegrityError, OperationalError, connection,
)
from django.db.models import Index, Model, Q
from django.db.models.constraints im... |
459e8a739ac2de525885c2771038134bcbac406285ff7ddf610dcde48332a10c | """
A series of tests to establish that the command-line management tools work as
advertised - especially with regards to the handling of the
DJANGO_SETTINGS_MODULE and default settings.py files.
"""
import os
import re
import shutil
import socket
import subprocess
import sys
import tempfile
import unittest
from io imp... |
5bde31ce02ff45ce9ad99e6c6ee4f5ee62df9c863e81ade07eae8c3a537f0492 | import datetime
from django import forms
from django.core.validators import ValidationError
from django.forms.models import ModelChoiceIterator
from django.forms.widgets import CheckboxSelectMultiple
from django.template import Context, Template
from django.test import TestCase
from .models import Article, Author, Bo... |
0bc957a602bb1062a82d73de216118b8ae1aaa58fb3d922a14ed44cf3575f64e | import copy
import unittest
from functools import wraps
from unittest import mock
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS, connection
from django.db.models.expressions import Func
def skipUnlessGISLookup(*gis_lookups):
"""
Skip a test unless a database supports all of gis_look... |
b93d73e4af73e2367aad86e0500628ac4c365bce93b93fbe16054354906f4379 | from unittest import skipIf
from django.core.exceptions import ValidationError
from django.db import connection, models
from django.test import SimpleTestCase, TestCase
from .models import Post
class TestCharField(TestCase):
def test_max_length_passed_to_formfield(self):
"""
CharField passes it... |
c424dff394b40bc6ac2183d49ef8e66341dfbd2c1754e5604270844da93cd38c | import collections.abc
from datetime import datetime
from math import ceil
from operator import attrgetter
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models import Max
from django.db.models.expressions import Exists, OuterRef
from django.db.models.functions import Sub... |
64d2ddd9ca4585b3933da82298c552cfe01e98eeff698721871c3aa0f70e550b | """
The lookup API
This demonstrates features of the database API.
"""
from django.db import models
from django.db.models.lookups import IsNull
class Alarm(models.Model):
desc = models.CharField(max_length=100)
time = models.TimeField()
def __str__(self):
return '%s (%s)' % (self.time, self.des... |
b832b3c82c28a7c054336c4945f087f1c4500a7fbcbade9b366c661731d9b476 | from unittest import mock
from django.db import connection, transaction
from django.db.models import Case, Count, F, FilteredRelation, Q, When
from django.test import TestCase
from django.test.testcases import skipUnlessDBFeature
from .models import Author, Book, Borrower, Editor, RentalSession, Reservation
class F... |
90284659051961a5e2e539a9adeb69962a4d958fdf757cd4dec74deba7665c3f | from django.db import migrations
def grow_tail(x, y):
pass
def feed(x, y):
"""Feed salamander."""
pass
class Migration(migrations.Migration):
dependencies = [
('migrations', '0004_fourth'),
]
operations = [
migrations.RunPython(migrations.RunPython.noop),
migration... |
a2e4d044ee2145198980a4f5fc7c3ac93522d3c71a6dbfd506656736705b49f9 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
"Author",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
... |
da48fd731329473c8782f7ff17ba5c9c1e3f26634a04fbe22291915deafdf220 | import os
import re
from io import StringIO
from django.contrib.gis.gdal import GDAL_VERSION, Driver, GDALException
from django.contrib.gis.utils.ogrinspect import ogrinspect
from django.core.management import call_command
from django.db import connection, connections
from django.test import SimpleTestCase, TestCase, ... |
dbd1c3f428456d4d318411cf5e65c83377546aa99bd0d4ca11933776e644550c | 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.... |
4dc4e89ad01f8a385b7b70ccb724872e2f7c334740dc615275551fc61b8c6bca | import tempfile
import unittest
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, Poin... |
596322a5586940fad56a89f9cb031a7d8b9d36993b9782b57f9810f91558ca37 | 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("""
======... |
0160e1e2f7421d4782061dbafd872b8e5d553630a5e94d4b780447de0f402f2e | """
Cross Site Request Forgery Middleware.
This module provides a middleware that implements protection
against request forgeries from other sites.
"""
import logging
import re
import string
from urllib.parse import urlparse
from django.conf import settings
from django.core.exceptions import DisallowedHost, Improperl... |
85e83a855c4cc4511f3db721ff6af535e244ccd5db3c6710e7d7f15ce1faf3d7 | """
The main QuerySet implementation. This provides the public API for the ORM.
"""
import copy
import operator
import warnings
from collections import namedtuple
from functools import lru_cache
from itertools import chain
from django.conf import settings
from django.core import exceptions
from django.db import (
... |
3eeaa2b8e46cf54d2508d3b1cc27ac4f0b9e43c223ee878cac893668c80bcd4a | """
Helpers to manipulate deferred DDL statements that might need to be adjusted or
discarded within when executing a migration.
"""
class Reference:
"""Base class that defines the reference interface."""
def references_table(self, table):
"""
Return whether or not this instance references th... |
ed6af820561cb9c2c3d76b2cf150ee93c07a5cf6acf1c3f263674f87a261505a | """
Accessors for related objects.
When a field defines a relation between two models, each model class provides
an attribute to access related instances of the other model class (unless the
reverse accessor has been disabled with related_name='+').
Accessors are implemented as descriptors in order to customize acces... |
97576633a7fafd8a0bf6a87baaca2252fcb6f5dbeeb1d50c1ba97e9781b108d4 | """
"Rel objects" for related fields.
"Rel objects" (for lack of a better name) carry information about the relation
modeled by a related field and provide some utility functions. They're stored
in the ``remote_field`` attribute of the field.
They also act as reverse fields for the purposes of the Meta API because
th... |
0c4d1319ea46a5972d1ef1dc39441d714093cf451be9f832367d428aa9aa145f | import collections
import re
from functools import partial
from itertools import chain
from django.core.exceptions import EmptyResultSet, FieldError
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import OrderBy, Random, RawSQL, Ref, Value
from django.db.models.functions import Cast... |
e195545d083cabcb4550c1b3a62ddb3adb6137625f439e5af19cf7f214818c3d | """
Query subclasses which provide extra functionality beyond simple data retrieval.
"""
from django.core.exceptions import FieldError
from django.db.models.query_utils import Q
from django.db.models.sql.constants import (
CURSOR, GET_ITERATOR_CHUNK_SIZE, NO_RESULTS,
)
from django.db.models.sql.query import Query
... |
6e6c9e43e3f6df83e89115f3d64df05f395604b29d36bee8bad7d0f07e203c09 | import operator
from django.db.backends.base.features import BaseDatabaseFeatures
from django.utils.functional import cached_property
class DatabaseFeatures(BaseDatabaseFeatures):
empty_fetchmany_value = ()
allows_group_by_pk = True
related_fields_match_type = True
# MySQL doesn't support sliced subq... |
fe545d0f8efa9db449aaad62739a790f119800d46220d75c73e75f7da9fc1899 | from django.db.models.sql import compiler
class SQLCompiler(compiler.SQLCompiler):
def as_subquery_condition(self, alias, columns, compiler):
qn = compiler.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
sql, params = self.as_sql()
return '(%s) IN (%s)' % (', '.join('%... |
035b1f88987dd13942380064ecad1cd6db7efc5cf462722ffdbd2ee286984bd2 | import uuid
from django.conf import settings
from django.db.backends.base.operations import BaseDatabaseOperations
from django.utils import timezone
from django.utils.duration import duration_microseconds
from django.utils.encoding import force_str
class DatabaseOperations(BaseDatabaseOperations):
compiler_modul... |
b520f2162de26bbb2de4c61bf8fe3c8b6efa3b352dad3d97f74aa623f8fbdc1d | import operator
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.utils import InterfaceError
from django.utils.functional import cached_property
class DatabaseFeatures(BaseDatabaseFeatures):
allows_group_by_selected_pks = True
can_return_columns_from_insert = True
can_retu... |
1bdcc0fe63a20403c4fbec8604f4ec5dc79af835b2ce54580e2b0e6ea6175bc6 | from django.conf import settings
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
from .utils import get_view_name
class XViewMiddleware(MiddlewareMixin):
"""
Add an X-View header to internal HEAD requests.
"""
def process_view(self, request, view_func, view_a... |
b8cfccde95e2c9f8f0590149458753d6db169b847cc2bab7e0e92cd4529c59c9 | from django.contrib import auth
from django.contrib.auth import load_backend
from django.contrib.auth.backends import RemoteUserBackend
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import MiddlewareMixin
from django.utils.functional import SimpleLazyObject
def get_user(request... |
195423afb5ea91ee8094516b981e57565612cc1e66cc89e56f2674e177485109 | import json
from django.contrib.messages.storage.base import BaseStorage
from django.contrib.messages.storage.cookie import (
MessageDecoder, MessageEncoder,
)
class SessionStorage(BaseStorage):
"""
Store messages in the session (that is, django.contrib.sessions).
"""
session_key = '_messages'
... |
30c9b230a3eeae4c938bf3683986ef118ca8e796138a47c7a7e3e922ac11561b | """
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... |
568854582f4c2b76231ba88ec7af82b6135de2548a8ebc3e5b94b33501a6fa24 | from django.contrib.auth.middleware import AuthenticationMiddleware
from django.contrib.auth.models import User
from django.http import HttpRequest
from django.test import TestCase
class TestAuthenticationMiddleware(TestCase):
def setUp(self):
self.user = User.objects.create_user('test_user', 'test@exampl... |
8125b63a248a22eca5a06a0dd25fe34bddf313315e9dd613953c8a885f6cb8d9 | import datetime
import pickle
from django.db import models
from django.test import TestCase
from django.utils.version import get_version
from .models import Container, Event, Group, Happening, M2MModel
class PickleabilityTestCase(TestCase):
@classmethod
def setUpTestData(cls):
Happening.objects.crea... |
7d70b03b14c07d3e7518f00a631a794f0a9901ed02b86d69a13e873f478ff4da | import datetime
import sys
import unittest
from django.contrib.admin import (
AllValuesFieldListFilter, BooleanFieldListFilter, ModelAdmin,
RelatedOnlyFieldListFilter, SimpleListFilter, site,
)
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.auth.admin import UserAdmin
fr... |
7636934a87f92378c4ca76eac2a1c14e89d2adbd1ab78a7cffd2dfc082a6ff07 | from django.contrib.auth.models import User
from django.test import override_settings
from .tests import AdminDocsTestCase, TestDataMixin
class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase):
def test_xview_func(self):
user = User.objects.get(username='super')
response = self.client.head(... |
45493a3dea2f7ba739519e1aaf4bc45f8ad50264d4e50961d808d598ec7ff957 | import asyncio
import sys
from unittest import skipIf
from asgiref.sync import async_to_sync
from asgiref.testing import ApplicationCommunicator
from django.core.asgi import get_asgi_application
from django.core.signals import request_started
from django.db import close_old_connections
from django.test import SimpleT... |
4032c204ea08b7ef964293584a9dc4c051ec722f63f91da196dc370b187045a4 | from django.contrib.messages import constants
from django.contrib.messages.storage.base import Message
from django.contrib.messages.storage.session import SessionStorage
from django.http import HttpRequest
from django.test import TestCase
from django.utils.safestring import SafeData, mark_safe
from .base import BaseTe... |
62a2b03b35cc71a0c8571a3186dedf8aaa145da0fb2c411c786e505609d1b3fb | import unittest
from django.db import NotSupportedError, connection, transaction
from django.db.models import Count
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.test.utils import CaptureQueriesContext
from .models import Tag
@skipUnlessDBFeature('supports_explaining_query_execu... |
9946be52aee6b8b0fba730060489527ebb9d9a5da3da10a017b3f421b02aac13 | import datetime
from unittest import skipIf, skipUnless
from django.db import connection
from django.db.models import Index
from django.db.models.deletion import CASCADE
from django.db.models.fields.related import ForeignKey
from django.db.models.query_utils import Q
from django.test import (
TestCase, Transaction... |
42aae285fa02ed7287b6e351d93edb1948bc7c417d876872a3d02ff73a926e86 | from math import ceil
from operator import attrgetter
from django.db import IntegrityError, NotSupportedError, connection
from django.db.models import FileField, Value
from django.db.models.functions import Lower
from django.test import (
TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature,
)
from .... |
8963b78621bc8bf7d9653fc3952bd2371f8686fc0461db8a660656113b7f0897 | from math import ceil
from django.db import IntegrityError, connection, models
from django.db.models.deletion import Collector
from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .models import (
MR, A, Avatar, Base, Child,... |
4961bfe67d708be5969367ad7c66f8d28fd0bd21cd01d4602bc579119643c374 | import pickle
from django import forms
from django.core.exceptions import ValidationError
from django.db import models
from django.test import SimpleTestCase, TestCase
from django.utils.functional import lazy
from .models import (
Bar, Choiceful, Foo, RenamedField, VerboseNameField, Whiz, WhizDelayed,
WhizIte... |
29d0e3f0cb0714340d47a48c9303c1a9a94640f997c74d4e765a4ad2bbc86687 | from unittest import mock
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.db import connection
from django.db.models import Prefetch, QuerySet
from django.db.models.query import get_prefetcher, prefetch_related_objects
from django.db.models.s... |
701b29e89014fb8599e8a17965456be5d29a25a55acd9732ff140cc041a59d9f | import sys
from unittest import skipIf
from asgiref.sync import async_to_sync
from django.core.exceptions import SynchronousOnlyOperation
from django.test import SimpleTestCase
from django.utils.asyncio import async_unsafe
from .models import SimpleModel
@skipIf(sys.platform == 'win32' and (3, 8, 0) < sys.version_... |
e198cee7b13f7992eb3ee9529b65f17bff5890c2e1fc6bf817db21592d3df886 | import json
import mimetypes
import os
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.handlers.... |
92eac3a1ecfd46b155ff07a19411828b048c4c629af886efb47c105ab069cd6a | """Compare two HTML documents."""
from html.parser import HTMLParser
from django.utils.regex_helper import _lazy_re_compile
# 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 = _lazy_re_compile(r'[\t\n\f\r ]+')
de... |
0fa2b968d61bede83a45644111aac6eeb63ad87010b3de21d63c8697d7af05c0 | import functools
import re
import sys
import types
from pathlib import Path
from django.conf import settings
from django.http import Http404, HttpResponse, HttpResponseNotFound
from django.template import Context, Engine, TemplateDoesNotExist
from django.template.defaultfilters import pprint
from django.urls import re... |
3ee718e829b949f7c11dfbb3327808fd1904d3a9ac41ec73a5d83ad4d4be5b1c | # 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... |
f05c4b669a303e360207546bffb8ec8629ae645a6c3a7d69c7a7df9b7dbcee8f | 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.regex_helper import _lazy_re_compile
from django.... |
4b46faec679cdaef615b698b358154641dfbc0d166a9c6659b52f64a10656aa1 | """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
from django.utils.regex_hel... |
82135b126799cfd31349ea0e2005c2270ffa0b5195a6fbfa9ee1453613c0a187 | 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):
... |
ac3c0ff846121ed0ffb4b2e2346dd10b1eeb3a2e6dfc51fb08e7e10cf3b5aca8 | """
Functions for reversing a regular expression (used in reverse URL resolving).
Used internally by Django and not intended for external use.
This is not, and is not intended to be, a complete reg-exp decompiler. It
should be good enough for a large class of URLS, however.
"""
import re
from django.utils.functional ... |
74a2d1a1b7e54d6b386253546de9e237f26c81b758331f57910cda030085eb3c | 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... |
1c9d87ef32d6919d0902a8982d8b5aadfed27d6e733b0e6a7eb2bb610644684f | """
PHP date() style date formatting
See http://www.php.net/date for format strings
Usage:
>>> import datetime
>>> d = datetime.datetime.now()
>>> df = DateFormat(d)
>>> print(df.format('jS F Y H:i'))
7th October 2003 11:39
>>>
"""
import calendar
import datetime
import time
from django.utils.dates import (
MONTH... |
554db82d52140dfc06b3ba5ce204b5d52147c38a68a0c7bb57058ed46dc1afc2 | """HTML utilities suitable for global use."""
import html
import json
import re
from html.parser import HTMLParser
from urllib.parse import (
parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit,
)
from django.utils.encoding import punycode
from django.utils.functional import Promise, keep_lazy, keep_lazy_t... |
122b668950101d859e2467882ac4ed4ab2684e2dc58fb91dba18f75cfa3eb7aa | import base64
import calendar
import datetime
import re
import unicodedata
import warnings
from binascii import Error as BinasciiError
from email.utils import formatdate
from urllib.parse import (
ParseResult, SplitResult, _coerce_args, _splitnetloc, _splitparams, quote,
quote_plus, scheme_chars, unquote, unquo... |
4bb44586d48387c75e7226905c20f50d77507fee448f68dae6f7d271d9c153f9 | """
This module contains helper functions for controlling caching. It does so by
managing the "Vary" header of responses. It includes functions to patch the
header of response objects directly and decorators that change functions to do
that header-patching themselves.
For information on the Vary header, see:
http... |
cfff24e847351f1e9e530dacb286a995a1e90ed782be4e71d562ea36968197c5 | """
This is the Django template system.
How it works:
The Lexer.tokenize() method converts a template string (i.e., a string
containing markup with custom template tags) to tokens, which can be either
plain text (TokenType.TEXT), variables (TokenType.VAR), or block statements
(TokenType.BLOCK).
The Parser() class ta... |
eea8b0961cd090ee54d79214b1b7ee7113cfe55d5cc5928074f6e3c672499a9f | """Default variable filters."""
import random as random_module
import re
import types
from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
from functools import wraps
from operator import itemgetter
from pprint import pformat
from urllib.parse import quote
from django.utils import formats
from django.... |
458265872172cb3ffb2a45c8e8d3f7e98c27819f6f5cddd231e57bd0a5de7966 | from django.utils.cache import patch_vary_headers
from django.utils.deprecation import MiddlewareMixin
from django.utils.regex_helper import _lazy_re_compile
from django.utils.text import compress_sequence, compress_string
re_accepts_gzip = _lazy_re_compile(r'\bgzip\b')
class GZipMiddleware(MiddlewareMixin):
"""... |
0249c25fa171554d6356e7f5573585bacda397f79d47bd3e2be2e48a39dc669e | """
This module converts requested URLs to callback view functions.
URLResolver is the main class here. Its resolve() method takes a URL (as
a string) and returns a ResolverMatch object which provides access to all
attributes of the resolved URL match.
"""
import functools
import inspect
import re
import string
from i... |
87a5af9f2f1f2f84484b6efac186dc2539ba16fb1a53a32ac1cba08fde12fee7 | """
HTML Widget classes
"""
import copy
import datetime
import warnings
from collections import defaultdict
from itertools import chain
from django.conf import settings
from django.forms.utils import to_current_timezone
from django.templatetags.static import static
from django.utils import datetime_safe, formats
from... |
dfe736b9fab103fba0da8770506b4e035335ebfc4b28a7b615729780b3557c9d | """
Field classes.
"""
import copy
import datetime
import math
import operator
import os
import re
import uuid
from decimal import Decimal, DecimalException
from io import BytesIO
from urllib.parse import urlsplit, urlunsplit
from django.core import validators
from django.core.exceptions import ValidationError
from d... |
5c3e287ead9e61ee7e4c8b4a064bbb0dd8ce761682c86f1c0164e3a3fb65ca7f | """
Functions for creating and restoring url-safe signed JSON objects.
The format used looks like this:
>>> signing.dumps("hello")
'ImhlbGxvIg:1QaUZC:YIye-ze3TTx7gtSv422nZA4sgmk'
There are two components here, separated by a ':'. The first component is a
URLsafe base64 encoded JSON of the object passed to dumps(). T... |
573e84012f323c847360eea927cae99dd5a87d1cd2017ea8bcf79ab8cc157794 | import ipaddress
import re
from pathlib import Path
from urllib.parse import urlsplit, urlunsplit
from django.core.exceptions import ValidationError
from django.utils.deconstruct import deconstructible
from django.utils.encoding import punycode
from django.utils.ipv6 import is_valid_ipv6_address
from django.utils.rege... |
71ef47ffa43e73bbde121857d0eb65792a511407748da6717273737ab5228ac9 | import datetime
import json
import mimetypes
import os
import re
import sys
import time
from email.header import Header
from http.client import responses
from urllib.parse import quote, urlparse
from django.conf import settings
from django.core import signals, signing
from django.core.exceptions import DisallowedRedir... |
e02bf531db996dd20e90207a3bf947ce2a42c6861d864c65e5ce2e1af1ffd098 | import cgi
import codecs
import copy
from io import BytesIO
from itertools import chain
from urllib.parse import quote, urlencode, urljoin, urlsplit
from django.conf import settings
from django.core import signing
from django.core.exceptions import (
DisallowedHost, ImproperlyConfigured, RequestDataTooBig,
)
from ... |
7fb40e4f190b219ef56a7b406fea07f94fb91468cf80944ea6649efe9637c18c | import logging
from functools import update_wrapper
from django.core.exceptions import ImproperlyConfigured
from django.http import (
HttpResponse, HttpResponseGone, HttpResponseNotAllowed,
HttpResponsePermanentRedirect, HttpResponseRedirect,
)
from django.template.response import TemplateResponse
from django.... |
dc2094c51f99128a3bbc58cbcdfe9a85eda24e788912dba0ef35ac36c62a55fa | """Translation helper functions."""
import functools
import gettext as gettext_module
import os
import re
import sys
import warnings
from asgiref.local import Local
from django.apps import apps
from django.conf import settings
from django.conf.locale import LANG_INFO
from django.core.exceptions import AppRegistryNotR... |
a263f5f526c7f50b15086c4078a41978b207976b88660fd2f3179b030da872a5 | """
Internationalization support.
"""
import warnings
from contextlib import ContextDecorator
from decimal import ROUND_UP, Decimal
from django.utils.autoreload import autoreload_started, file_changed
from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.functional import lazy
from django.uti... |
4963b11222a4f517c029568350048769df3e6f7101d1103a180dc7b22cb28bcd | import warnings
from io import StringIO
from django.template.base import TRANSLATOR_COMMENT_MARK, Lexer, TokenType
from django.utils.regex_helper import _lazy_re_compile
from . import TranslatorCommentWarning, trim_whitespace
dot_re = _lazy_re_compile(r'\S')
def blankout(src, char):
"""
Change every non-wh... |
6b267ea422e09017bccb5dd8d7e6985baf8464bd8192d4e35dd1cdf46b986d4c | import enum
from django.utils.functional import Promise
__all__ = ['Choices', 'IntegerChoices', 'TextChoices']
class ChoicesMeta(enum.EnumMeta):
"""A metaclass for creating a enum choices."""
def __new__(metacls, classname, bases, classdict):
labels = []
for key in classdict._member_names:
... |
20ef887aa13b37ba3bae30b4a9efaf0ac8567bbe2621f1c68608f900a1d74b9f | import copy
import datetime
import inspect
from decimal import Decimal
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import connection
from django.db.models import fields
from django.db.models.query_utils import Q
from django.db.utils import NotSupportedError
from django.utils.deconstruc... |
b605cdadad41cb6f5dbb270b2f60120bd8dadaf010f5c7409dd1a52dbeff93aa | import collections.abc
import copy
import datetime
import decimal
import operator
import uuid
import warnings
from base64 import b64decode, b64encode
from functools import partialmethod, total_ordering
from django import forms
from django.apps import apps
from django.conf import settings
from django.core import checks... |
196cba0582a8b672a9d860905b9614a74dd29ee8d8a8c1ffe78d7f5d33f7441a | """
Constants specific to the SQL storage portion of the ORM.
"""
from django.utils.regex_helper import _lazy_re_compile
# Size of each "chunk" for get_iterator calls.
# Larger values are slightly faster at the expense of more storage space.
GET_ITERATOR_CHUNK_SIZE = 100
# Namedtuples for sql.* internal use.
# How ... |
3cb746c9a7c0dd63def7330712bebf65b723bd722a5c1c9c04cc4dda03eb48c0 | import datetime
import uuid
from functools import lru_cache
from django.conf import settings
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.utils import strip_quotes, truncate_name
from django.db.models.expressions import Exists, ExpressionWrapper
from django.db.models.qu... |
a36d76eb1edc9abb6bac1407d641b89256e3e3aa5f545930444d97761f2c58ac | from django.db.models.sql import compiler
class SQLCompiler(compiler.SQLCompiler):
def as_subquery_condition(self, alias, columns, compiler):
qn = compiler.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
sql, params = self.as_sql()
return '(%s) IN (%s)' % (', '.join('%... |
da7809780f41f158b80d174770aaa93226ed3aab6a32aaab94f1b6e0520c16dd | """
MySQL database backend for Django.
Requires mysqlclient: https://pypi.org/project/mysqlclient/
"""
from django.core.exceptions import ImproperlyConfigured
from django.db import utils
from django.db.backends import utils as backend_utils
from django.db.backends.base.base import BaseDatabaseWrapper
from django.utils... |
bfafdeb814bfbc3c5004bd1921b2a30bdffdcb7ecd6df1366dacad75c6ed8195 | import re
from collections import namedtuple
import sqlparse
from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo as BaseFieldInfo, TableInfo,
)
from django.db.models.indexes import Index
from django.utils.regex_helper import _lazy_re_compile
FieldInfo = namedtuple('FieldInfo'... |
33829536ee2a52b1ac7d8403925804ea6c4d65bf183cde4cff67af5cb29483d8 | """
SQLite backend for the sqlite3 module in the standard library.
"""
import datetime
import decimal
import functools
import hashlib
import math
import operator
import re
import statistics
import warnings
from itertools import chain
from sqlite3 import dbapi2 as Database
import pytz
from django.core.exceptions impor... |
2637d6ccd8237368f76687c30b218e6d556eac1ce972fcda7a0ecf134ec3b374 | import os
from datetime import datetime
from urllib.parse import urljoin
from django.conf import settings
from django.core.exceptions import SuspiciousFileOperation
from django.core.files import File, locks
from django.core.files.move import file_move_safe
from django.core.signals import setting_changed
from django.ut... |
1899cc4f568fa098284cf8d8a2450cf8bf48869fa495c62375470f1299f91695 | from io import BytesIO
from django.conf import settings
from django.core import signals
from django.core.handlers import base
from django.http import HttpRequest, QueryDict, parse_cookie
from django.urls import set_script_prefix
from django.utils.encoding import repercent_broken_unicode
from django.utils.functional im... |
d9146fa794f1ba6c4baacaea2a2798ec780be77389e803eb65ac114244cab46e | import errno
import os
import re
import socket
import sys
from datetime import datetime
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.servers.basehttp import (
WSGIServer, get_internal_wsgi_application, run,
)
from django.utils import autoreload... |
d233549f7ef849705cd72585c7b4405a92c28e039df5f19bee7ca1e1502312f3 | import glob
import os
import re
import sys
from functools import total_ordering
from itertools import dropwhile
import django
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.files.temp import NamedTemporaryFile
from django.core.management.base import BaseComman... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.