hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
a4b5de1425fb304b85d93d9a9d296a9f184e0326c905896edd6801e3119669a8 | """
Create SQL statements for QuerySets.
The code in here encapsulates all of the SQL construction so that QuerySets
themselves do not have to (and could be backed by things other than SQL
databases). The abstraction barrier only works one way: this module has to know
all about the internals of models in order to get ... |
915677abc51bff31256c15df0fb55a148a79694fef5dd16110eca4a216036d4c | import collections
import re
from functools import partial
from itertools import chain
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import DatabaseError, NotSupportedError
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import F, OrderBy, RawSQL, Ref,... |
c637e819144aa5af27743ff372387eea7ffe8160e1ba13b379310d84f49dd0ac | #!/usr/bin/env python
import argparse
import atexit
import copy
import gc
import os
import shutil
import socket
import subprocess
import sys
import tempfile
import warnings
from pathlib import Path
try:
import django
except ImportError as e:
raise RuntimeError(
'Django module not found, reference tests... |
10123dfc5f9fecbcc9a7bc6ccdccffe5713ec4f3dc500c2eaaf639d970a66c60 | # 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... |
4f7c15a1c66deab131f691d704cb4c4d99f55b7dbd0c4a97625ce02379107519 | import ctypes
import faulthandler
import hashlib
import io
import itertools
import logging
import multiprocessing
import os
import pickle
import random
import sys
import textwrap
import unittest
from collections import defaultdict
from contextlib import contextmanager
from importlib import import_module
from io import ... |
7f2d52bf3f0cbb0f555b89c0c88f2c2dd641519a426e14e5810903db04f18a9a | import datetime
import re
from django.forms.utils import flatatt, pretty_name
from django.forms.widgets import Textarea, TextInput
from django.utils.functional import cached_property
from django.utils.html import conditional_escape, format_html, html_safe
from django.utils.safestring import mark_safe
from django.utils... |
8dfa68473a3d40d059260b96db3730e87cb524d477fe7518c2c5f2ee324a124f | """
Form classes
"""
import copy
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
from django.forms.fields import Field, FileField
from django.forms.utils import ErrorDict, ErrorList
from django.forms.widgets import Media, MediaDefiningClass
from django.utils.datastructures import MultiValueDict
f... |
69336f4486916a3ce86ae3cb5619f575698d60f814d75ccc9d911b4e6de926fc | 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... |
0eee3b6437e16824467af73e4b775add8cb2adf1f3b788ae569a0b9e7adf04e7 | """
Create SQL statements for QuerySets.
The code in here encapsulates all of the SQL construction so that QuerySets
themselves do not have to (and could be backed by things other than SQL
databases). The abstraction barrier only works one way: this module has to know
all about the internals of models in order to get ... |
6dfa2796db79561ca2b979b21d0a3b3abcc5c3670b9ee2c685810968bf99c1ca | 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... |
c89ac179867bc8d2ab34a79cb331bea2253d6d2677b73ef386a0c4c3ac8c273d | """
Tests for django test runner
"""
import collections.abc
import unittest
from unittest import mock
from admin_scripts.tests import AdminScriptTestCase
from django import db
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from ... |
c3a9087bab59290e9162257ca0ec209c4a7778ea6baff06e19101d77fe7648de | import logging
import os
import unittest.loader
from argparse import ArgumentParser
from contextlib import contextmanager
from importlib import import_module
from unittest import TestSuite, TextTestRunner, defaultTestLoader, mock
from django.db import connections
from django.test import SimpleTestCase
from django.test... |
a7aea7a701b24545a576ee7b84cb88ea24b399a06b82fb44131a5bd8d806bb2c | from django.core.exceptions import ValidationError
from django.forms import Form
from django.forms.fields import BooleanField, IntegerField
from django.forms.utils import ErrorList
from django.forms.widgets import HiddenInput, NumberInput
from django.utils.functional import cached_property
from django.utils.html import... |
b3e1fda17d7fd6bd4aaeed5de899e1193eda57cb2a1dec5e1d06dc680a9dc4b3 | import datetime
from collections import Counter
from unittest import mock
from django.core.exceptions import ValidationError
from django.forms import (
BaseForm, CharField, DateField, FileField, Form, IntegerField,
SplitDateTimeField, formsets,
)
from django.forms.formsets import BaseFormSet, all_valid, formse... |
02a25c77bc58b6ec3063e690326555f050b11f2de9c2df3ac84b85117253d5a8 | import ctypes
import faulthandler
import hashlib
import io
import itertools
import logging
import multiprocessing
import os
import pickle
import random
import sys
import textwrap
import unittest
import warnings
from collections import defaultdict
from contextlib import contextmanager
from importlib import import_module... |
75c4db129cc3e5fb38af6fa2710f5b96e67f539a6455725e2cc2de0863cb2fa8 | 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 asgiref.sync import sync_to_async
from django.conf im... |
0bf6bf6f03f22e8307e2f7c9ab45476a6b72a01e4a1325d28a833d812f343070 | """
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
####... |
88cbbe1029d71e1f1e14a8ab7a9618c873bf129080e42a0a4a8fef35302a1422 | """
Cross Site Request Forgery Middleware.
This module provides a middleware that implements protection
against request forgeries from other sites.
"""
import logging
import string
from collections import defaultdict
from urllib.parse import urlparse
from django.conf import settings
from django.core.exceptions import... |
087baaca4e5ec231e25583716782f6be88b6e83aea73babb11db2b570dbb14ce | import copy
import inspect
import warnings
from functools import partialmethod
from itertools import chain
import django
from django.apps import apps
from django.conf import settings
from django.core import checks
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldDoesNotExist, FieldError, MultipleObjects... |
0ea934a746f14f96a6db593e3fd8838b99f525dc15698510008d1202d73b3c2c | 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... |
47b70092c9bda84a26b6bb69c49702363ddfb703ec9f280d4b24b0e6fe2f2633 | import functools
import inspect
from functools import partial
from django import forms
from django.apps import apps
from django.conf import SettingsReference, settings
from django.core import checks, exceptions
from django.db import connection, router
from django.db.backends import utils
from django.db.models import Q... |
80d6eec37430d8f2d586810f2c33246ac720c6636e3da3f4adc1b4e765b25a08 | """
"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... |
6fc6a0567cff9caf07dae78cca362aacb103ba67c7d15dc6ec1126495b71373b | """
Create SQL statements for QuerySets.
The code in here encapsulates all of the SQL construction so that QuerySets
themselves do not have to (and could be backed by things other than SQL
databases). The abstraction barrier only works one way: this module has to know
all about the internals of models in order to get ... |
66db97639b3b3f6f44f18010568ad4514facbf7952197f022b4f8b25c3cc193c | import collections
import json
import re
from functools import partial
from itertools import chain
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import DatabaseError, NotSupportedError
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import F, OrderBy, ... |
c395935b4fc25fbaf0fb0a8aa6d24965d93ebf00622fc278e0ee5d7afdb60ac9 | """
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
... |
a4271604456e6a4fee4961e1d40cb4553ab8e9c324095e861e9c67049166f52d | import functools
import itertools
import operator
from collections import defaultdict
from django.contrib.contenttypes.models import ContentType
from django.core import checks
from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
from django.db import DEFAULT_DB_ALIAS, models, router, transaction
fr... |
85fabf45812a109f452f3403df662c52fcac3a558ffa1d7146c0d3765b43e7e9 | import re
from django.conf import settings
from django.contrib.sessions.backends.cache import SessionStore
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpRequest, HttpResponse, UnreadablePostError
from django.middleware.csrf import (
CSRF_ALLOWED_CHARS, CSRF_SESSION_KEY, CSRF_T... |
2a73315bddb8648b0fbd51aa6002d9524082f63c7eabc0c214d4d26d8620db95 | from django.db.models import (
CharField, F, Func, IntegerField, OuterRef, Q, Subquery, Value,
)
from django.db.models.fields.json import KeyTextTransform, KeyTransform
from django.db.models.functions import Cast, Concat, Substr
from django.test.utils import Approximate, ignore_warnings
from django.utils.deprecatio... |
82c67567f7e85063c855914107355ee02d476afebe01feb761d7186c8d04ecee | import unittest
from django.core.checks import Error, Warning
from django.core.checks.model_checks import _check_lazy_references
from django.db import connection, connections, models
from django.db.models.functions import Abs, Lower, Round
from django.db.models.signals import post_init
from django.test import SimpleTe... |
c3eaa1d787734ed6b283e22411af1ab80c66fcb108ae1d405dc1284558a9705a | import decimal
from django.core.exceptions import ValidationError
from django.forms import DecimalField, NumberInput, Widget
from django.test import SimpleTestCase, override_settings
from django.utils import formats, translation
from . import FormFieldAssertionsMixin
class DecimalFieldTest(FormFieldAssertionsMixin,... |
6fd855ba656621f567868a4b0bd62c33ae2e7db2ba34c5f9e58e18088d5e876f | import os
import site
import sys
from distutils.sysconfig import get_python_lib
from setuptools import setup
# Allow editable install into user site directory.
# See https://github.com/pypa/pip/issues/7953.
site.ENABLE_USER_SITE = '--user' in sys.argv[1:]
# Warn if we are installing over top of an existing installat... |
a0808467dddfe277b918a4f0269f5e3f9feb50371a576b5f841d505f0123a200 | #!/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... |
ccc41eb250fafff426fb06a8eba457f459cb5024e428deb9f5677bdb2ef6e359 | """
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... |
ecbdcce88be899afaf0dc6ecdd2b7182e3282d65def66f473e1734f8689edab5 | from django.utils.version import get_version
VERSION = (4, 1, 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... |
93b4dc67f6afdbdbfc80fc588eded36f9e0cc029b2b56483bc5a5aa450f53c6f | #!/usr/bin/env python
import argparse
import atexit
import copy
import gc
import os
import shutil
import socket
import subprocess
import sys
import tempfile
import warnings
from pathlib import Path
try:
import django
except ImportError as e:
raise RuntimeError(
'Django module not found, reference tests... |
2cd316d57963c6d30bb5dddce4b8fd43da45abcd3e5936240fc6d4f4ee757316 | # 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... |
acb90f72a8c8bc133fbc8993e9bcedaff940e8c82b0d9cd15401d63c29b584a3 | import argparse
import ctypes
import faulthandler
import io
import itertools
import logging
import multiprocessing
import os
import pickle
import random
import sys
import textwrap
import unittest
import warnings
from collections import defaultdict
from contextlib import contextmanager
from importlib import import_modul... |
b39edb9bff3722e8b200f57f0f739dc7de341a4284405600013775a21f615bed | 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 asgiref.sync import sync_to_async
from django.conf im... |
e10529d956d79cf68bc1eb8e10545381ac3400fdfabdd1926c0d99e352074439 | import asyncio
import difflib
import json
import logging
import posixpath
import sys
import threading
import unittest
import warnings
from collections import Counter
from contextlib import contextmanager
from copy import copy, deepcopy
from difflib import get_close_matches
from functools import wraps
from unittest.suit... |
bd5f668d1c0abe428bbdb8e31ab652cf3e793fe58290d008e9bb806436b02e6b | """Compare two HTML documents."""
import html
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\... |
c1fa9aee51ed48134cbd10a740e0920409ef7481c249b4700846688906b17d80 | import asyncio
import collections
import logging
import os
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.d... |
c197899fe3d4947eb51b79ec2066a484ee1e1c2392a1c5df1346860943765dc8 | import os
import time
import warnings
from asgiref.local import Local
from django.apps import apps
from django.core.exceptions import ImproperlyConfigured
from django.core.signals import setting_changed
from django.db import connections, router
from django.db.utils import ConnectionRouter
from django.dispatch import ... |
071282c2d842a8c281cdfd232fbcfa3548848754574017955f0ffb0986389b6d | 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... |
b32963a79cc6612044ee051d2fc4d323074909296e858e109e6ddad6c58c6388 | import inspect
import os
from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property
from django.utils.module_loading import import_string, module_has_submodule
APPS_MODULE_NAME = 'apps'
MODELS_MODULE_NAME = 'models'
class AppConfig... |
475bc5ce4ec520fdbb70ebf8f4ff068bcfdf02684967575235e99a62e8a16163 | import functools
import re
import sys
import types
import warnings
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 djang... |
aedda4579d030a4c84d69d460acd83c439d6ec15ccc72df780a894e2bc7bdb55 | """
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... |
a77baff5a3c2818fe6e455fc87739acd0631e7fbc513edb6b9d51e86e137e7a0 | """
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
####... |
0cf17550969281bc2e2b31be3137dc46d3b25866e38ddec8c08c446c39f0723b | "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 ... |
a5538faff63576fc003a2054635154186e0cfc1b00f31c80348bb06dd168c0a5 | import functools
import itertools
import logging
import os
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
import django
from django.apps i... |
bbeca0dd06739a04fe2668f59b7a15a79fc4c31c99b159b505d26a55699b47fb | import re
import unicodedata
from gzip import GzipFile, compress as gzip_compress
from io import BytesIO
from django.core.exceptions import SuspiciousFileOperation
from django.utils.functional import SimpleLazyObject, keep_lazy_text, lazy
from django.utils.regex_helper import _lazy_re_compile
from django.utils.transla... |
215020043e0466abbf4704358d89015d6e467e411ff4ea5f593548406ba736d3 | """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... |
18f6b92d18ab37ee6465f96e93b5a106220ce6345b3cf061be5ae3772701021c | import datetime
import functools
import os
import subprocess
import sys
from django.utils.regex_helper import _lazy_re_compile
# Private, stable API for detecting the Python version. PYXY means "Python X.Y
# or later". So that third-party apps can use these values, each constant
# should remain as long as the oldest ... |
f853fc6d2ec2ca32c4a4c7c49d3df7ee8abca1dd7a450d7e36aaee7b2e674c28 | """
Timezone-related classes and functions.
"""
import functools
import sys
import warnings
try:
import zoneinfo
except ImportError:
from backports import zoneinfo
from contextlib import ContextDecorator
from datetime import datetime, timedelta, timezone, tzinfo
from asgiref.local import Local
from django.... |
d878ffb5403dbdd47b45ac8321ff5a578017fd627ef2ffdff86b7ae75bea6503 | import asyncio
import inspect
import warnings
from asgiref.sync import sync_to_async
class RemovedInNextVersionWarning(DeprecationWarning):
pass
class RemovedInDjango50Warning(PendingDeprecationWarning):
pass
class warn_about_renamed_method:
def __init__(self, class_name, old_method_name, new_method_... |
88dced8772059cb13850d7c1203286ae5a318461369c91c569482ed6517b791c | """
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
from django.utils.inspect import func_supports_parameter
class InvalidAlgorithm(ValueError):
"""Algorithm is not supported by hashlib.... |
eeef3cfaa015a869e439769cf15e7d79688ad95be1f5c2cc5d5cb461b3af8afa | import copy
from collections.abc import Mapping
class OrderedSet:
"""
A set which keeps the ordering of the inserted items.
"""
def __init__(self, iterable=None):
self.dict = dict.fromkeys(iterable or ())
def add(self, item):
self.dict[item] = None
def remove(self, item):
... |
0529450dc65bccbb62d2455780fcde2744a4da0bebc980b80df242ff466c3fa5 | """
PHP date() style date formatting
See https://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
from email.utils import format_datetime as format_date... |
123173d37fa7a08365ae65eaf8d49220e373031dce18fb7bea7a02c6d5d1d473 | import copy
import os
import sys
from importlib import import_module
from importlib.util import find_spec as importlib_find
def cached_import(module_path, class_name):
# Check whether module is loaded and fully initialized.
if not (
(module := sys.modules.get(module_path)) and
(spec := getattr... |
91d5bbd15bad4cf813e4b5ea29e5adf2c849ca83007181177088c666a80d008f | """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... |
6d4fc9d7e20f261aedca9d526b1643ded6e8a2ba90924d18c5adcd4c5c65386c | import logging
import logging.config # needed when logging_config doesn't start with logging.config
from copy import copy
from django.conf import settings
from django.core import mail
from django.core.mail import get_connection
from django.core.management.color import color_style
from django.utils.module_loading impo... |
abee4960759c0330f58096cc20b8b196c8768ba838d26d2dfcd1f0a04b72a626 | from importlib import import_module
from django.utils.version import get_docs_version
def deconstructible(*args, path=None):
"""
Class decorator that allows the decorated class to be serialized
by the migrations subsystem.
The `path` kwarg specifies the import path.
"""
def decorator(klass):... |
4fc5c2d0de5238aa60b490562eb25413e6a0100bb93d5eaf0417eb1df3102156 | import copy
import itertools
import operator
import warnings
from functools import total_ordering, wraps
class cached_property:
"""
Decorator that converts a method with a single self argument into a
property cached on the instance.
A cached property can be made out of an existing method:
(e.g. `... |
ca1ee2e04b4ca2c7e8384ca7fca4be6657d95dca1ef26e9f9e32a0daab2a37de | import os
from asyncio import get_running_loop
from functools import wraps
from django.core.exceptions import SynchronousOnlyOperation
def async_unsafe(message):
"""
Decorator to mark functions as async-unsafe. Someone trying to access
the function while in an async context will get an error message.
... |
52d8a21d6f63da6044fcf891550734189cc9134024b76c2217ff86a4fe0ab8d7 | import base64
import datetime
import re
import unicodedata
from binascii import Error as BinasciiError
from email.utils import formatdate
from urllib.parse import (
ParseResult, SplitResult, _coerce_args, _splitnetloc, _splitparams,
scheme_chars, urlencode as original_urlencode, uses_params,
)
from django.util... |
c2494dc5ce23c9ae7443d852f72402e3e822663c73fd519f9cf5289b8cd1330a | """
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... |
2f1ed51754f0e005002523b6be248e2264cba7d77234cff8d22cc2bde4dc68a3 | import datetime
import decimal
import functools
import re
import unicodedata
from importlib import import_module
from django.conf import settings
from django.utils import dateformat, numberformat
from django.utils.functional import lazy
from django.utils.translation import (
check_for_language, get_language, to_lo... |
4983a5e88652e5ef6279bd44fba8e40010ab93a62bacbea9caf738fd36d1f776 | """JsLex: a lexer for JavaScript"""
# Originally from https://bitbucket.org/ned/jslex
import re
class Tok:
"""
A specification for a token class.
"""
num = 0
def __init__(self, name, regex, next=None):
self.id = Tok.num
Tok.num += 1
self.name = name
self.regex = re... |
3c6b041d9d3bbbea6b48c3b96840e68cfbd5466bd4d865ac82a7e0025d2ee162 | from pathlib import Path
from django.dispatch import receiver
from django.template import engines
from django.template.backends.django import DjangoTemplates
from django.utils._os import to_path
from django.utils.autoreload import (
autoreload_started, file_changed, is_django_path,
)
def get_template_directories... |
d7d92283a57810a03c301ed5c5d7e63279957d452341cdf4963d389892abc4bd | import posixpath
from collections import defaultdict
from django.utils.safestring import mark_safe
from .base import (
Node, Template, TemplateSyntaxError, TextNode, Variable, token_kwargs,
)
from .library import Library
register = Library()
BLOCK_CONTEXT_KEY = 'block_context'
class BlockContext:
def __in... |
f3544776380ae38fd3d10eb794aebb48cc0a2e31504873112efcb8f54569cf5b | """
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... |
39c1a54b70b8512c34ddd1d8d80d69347e4ab5e01628f810918286da794270ae | import functools
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from .base import Template
from .context import Context, _builtin_context_processors
from .exceptions import TemplateDoesNotExist
from .lib... |
501e3d230766810a378e617f07b64870458694e6a53d8053fc766a777d3ac643 | import functools
from collections import Counter
from pathlib import Path
from django.apps import apps
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
class InvalidTempla... |
8039f51a6ef64f62fec5d9c1fc88aab203d4c7f4dbb49381c2976ed8cf71440e | """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 inspect import unwrap
from operator import itemgetter
from pprint import pformat
from urllib.parse import quote
from django.utils ... |
cb37d41de5b054f0cdb12e16c3b5fb948a045bb1a3a4ff42370c4bf212203676 | import functools
from importlib import import_module
from inspect import getfullargspec, unwrap
from django.utils.html import conditional_escape
from django.utils.itercompat import is_iterable
from .base import Node, Template, token_kwargs
from .exceptions import TemplateSyntaxError
class InvalidTemplateLibrary(Exc... |
ba4dd54fa2dac0cc5ad90794750cb7478527099d82cfddfd7bcd8cb1a8df6baa | from django.conf import settings
from django.conf.urls.i18n import is_language_prefix_patterns_used
from django.http import HttpResponseRedirect
from django.urls import get_script_prefix, is_valid_path
from django.utils import translation
from django.utils.cache import patch_vary_headers
from django.utils.deprecation i... |
82368b089977b13e078d02aea7f81dbf3218a208061ce6c839f5c3ed2f213677 | """
Cache middleware. If enabled, each Django-powered page will be cached based on
URL. The canonical way to enable cache middleware is to set
``UpdateCacheMiddleware`` as your first piece of middleware, and
``FetchFromCacheMiddleware`` as the last::
MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddl... |
243898c1533b12b15e5b4976b369a080a4475ee337cc551a2d53a2008b653664 | """
Cross Site Request Forgery Middleware.
This module provides a middleware that implements protection
against request forgeries from other sites.
"""
import logging
import string
from collections import defaultdict
from urllib.parse import urlparse
from django.conf import settings
from django.core.exceptions import... |
5adbb1f6da3c5383feb5b0528b00887bb2b753ac58278cc38a1501e46e44696b | from contextlib import ContextDecorator, contextmanager
from django.db import (
DEFAULT_DB_ALIAS, DatabaseError, Error, ProgrammingError, connections,
)
class TransactionManagementError(ProgrammingError):
"""Transaction management is used improperly."""
pass
def get_connection(using=None):
"""
... |
c5f7f0d2a0c8ed32baea4b756f36c22eb7e2bd5e193ec9590726110b15222d4d | import pkgutil
from importlib import import_module
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
# For backwards compatibility with Django < 3.2
from django.utils.connection import ConnectionDoesNotExist # NOQA: F401
from django.utils.connection import BaseConnectionHandler
... |
4aeb93f238d05055ee7ee27400ff8742735e5c44b0c9d9981cd62a9dd5a3c897 | """Functions for use in URLsconfs."""
from functools import partial
from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from .resolvers import (
LocalePrefixPattern, RegexPattern, RoutePattern, URLPattern, URLResolver,
)
def include(arg, namespace=None):
app_name = No... |
c2f25e65f89060ee357ff9bd9239f0a7bdd6b6e0641aa363096f55ca75f4e897 | """
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... |
d98a5fdb8160e8ee3be32b42b8292a37f3a6ad97f601db7c6ec7fc92f6637e8a | """
Helper functions for creating Form classes from Django models
and database field objects.
"""
from itertools import chain
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError,
)
from django.forms.fields import ChoiceField, Field
from django.forms.forms import... |
c6c52961d53505c25088e8f0e647629406b16351803af550e3ed9e3c87be03cb | from django.core.exceptions import ValidationError
from django.forms import Form
from django.forms.fields import BooleanField, IntegerField
from django.forms.renderers import get_default_renderer
from django.forms.utils import ErrorList, RenderableFormMixin
from django.forms.widgets import CheckboxInput, HiddenInput, N... |
0e57228eda98da56539fdef5846a1a136117ad4483b72aa19da711de988ebc6d | """
HTML Widget classes
"""
import copy
import datetime
import warnings
from collections import defaultdict
from itertools import chain
from django.forms.utils import to_current_timezone
from django.templatetags.static import static
from django.utils import formats
from django.utils.datastructures import OrderedSet
f... |
19014797e795b16db14975cca75f250acac536aa35e7f01ba10482a5d83b1360 | import re
from django.core.exceptions import ValidationError
from django.forms.utils import pretty_name
from django.forms.widgets import MultiWidget, Textarea, TextInput
from django.utils.functional import cached_property
from django.utils.html import format_html, html_safe
from django.utils.translation import gettext... |
44c5c426d78219756a43a5dba6bf08addbf7b767038a1de695c50bd0eee01995 | import json
from collections import UserList
from django.conf import settings
from django.core.exceptions import ValidationError
from django.forms.renderers import get_default_renderer
from django.utils import timezone
from django.utils.html import escape, format_html_join
from django.utils.safestring import mark_safe... |
bb3a55e4b7c17621d043e1d1d84a196f31327ba6a5237f56945a551ae596f8f2 | import functools
from pathlib import Path
from django.conf import settings
from django.template.backends.django import DjangoTemplates
from django.template.loader import get_template
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
@functools.lru_cache
def get... |
d105e85970d164a33f00e94bf5e9762b8ac521f168aa200707f36189a3d7b92d | """
Form classes
"""
import copy
import datetime
import warnings
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
from django.forms.fields import Field, FileField
from django.forms.utils import ErrorDict, ErrorList, RenderableFormMixin
from django.forms.widgets import Media, MediaDefiningClass
fro... |
7aa7aeff428ace7e358fb9bd217b88eadee9e5260aa9ce1b60451e863ce0f7fe | 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... |
b8b3d622cef125c044f1baf8a4f60dace7bfd8a5d8919a32c855f88d403c0690 | """
Multi-part parsing for file uploads.
Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to
file upload handlers for processing.
"""
import base64
import binascii
import cgi
import collections
import html
from urllib.parse import unquote
from django.conf import settings
from django.core.ex... |
309d5407d1b57489c5544a85bc84975bdf1bb733ffefb5ba40a47c900c94421e | import datetime
import io
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 Disal... |
a322dae2ffc4c01a4b8f7557aadcf4acbf901e70dbab4672a7a001de6be24391 | import cgi
import codecs
import copy
from io import BytesIO
from itertools import chain
from urllib.parse import parse_qsl, quote, urlencode, urljoin, urlsplit
from django.conf import settings
from django.core import signing
from django.core.exceptions import (
DisallowedHost, ImproperlyConfigured, RequestDataTooB... |
0ef20c8cabeb06440c0f30c77925587086bbb28bfc6b829e6db604f51d4ab262 | from datetime import datetime, tzinfo
try:
import zoneinfo
except ImportError:
from backports import zoneinfo
from django.conf import settings
from django.template import Library, Node, TemplateSyntaxError
from django.utils import timezone
register = Library()
# RemovedInDjango50Warning: shim to allow catc... |
c73dee320001ec0bcac77cdb926a98bfdbaa751250d45720783676b4d5faaa64 | from decimal import Decimal
from django.conf import settings
from django.template import Library, Node, TemplateSyntaxError, Variable
from django.template.base import TokenType, render_value_in_context
from django.template.defaulttags import token_kwargs
from django.utils import translation
from django.utils.safestrin... |
65385b6c834bba77f69e7babe172911e228197bcea313a045156b0e15f764cf7 | from functools import wraps
from django.middleware.cache import CacheMiddleware
from django.utils.cache import add_never_cache_headers, patch_cache_control
from django.utils.decorators import decorator_from_middleware_with_args
def cache_page(timeout, *, cache=None, key_prefix=None):
"""
Decorator for views ... |
d39444a006be1c73c98b165bf14eefc0d00e420d687b7ae2556ccb998828f384 | import warnings
from django.core.exceptions import ImproperlyConfigured
from django.forms import Form, models as model_forms
from django.http import HttpResponseRedirect
from django.views.generic.base import ContextMixin, TemplateResponseMixin, View
from django.views.generic.detail import (
BaseDetailView, SingleO... |
f906cddfd707e38b3425bce7bed3798ab2156a0a1dfb352466312592d90b4e2f | """
LANG_INFO is a dictionary structure to provide meta information about languages.
About name_local: capitalize it as if your language name was appearing
inside a sentence in your language.
The 'fallback' key can be used to specify a special fallback logic which doesn't
follow the traditional 'fr-ca' -> 'fr' fallbac... |
1456245d6adb7c57a0ebf9aa1a6fe2a008cf638fb3c4531016d5e8efe66ad209 | # This file is distributed under the same license as the Django package.
#
# The *_FORMAT strings use the Django date format syntax,
# see https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
# Formatting for date objects.
DATE_FORMAT = 'N j, Y'
# Formatting for time objects.
TIME_FORMAT = 'P'
# Formatti... |
1895d5ad8a8b2d7598c5cec0c8739e273106d4c473234675e8124e3b11ba7619 | # This file is distributed under the same license as the Django package.
#
# The *_FORMAT strings use the Django date format syntax,
# see https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'j M Y' # '25 Oct 2006'
TIME_FORMAT = 'P' # '2:30 p.m.'
DATE... |
18e0835b10d1d7f8d7731b0bcb03ad0d856a61d5b0c576f9216c6387f883339b | """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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.