Initial commit
This commit is contained in:
Binary file not shown.
132
venv/lib/python3.10/site-packages/_distutils_hack/__init__.py
Normal file
132
venv/lib/python3.10/site-packages/_distutils_hack/__init__.py
Normal file
@@ -0,0 +1,132 @@
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import importlib
|
||||
import warnings
|
||||
|
||||
|
||||
is_pypy = '__pypy__' in sys.builtin_module_names
|
||||
|
||||
|
||||
warnings.filterwarnings('ignore',
|
||||
r'.+ distutils\b.+ deprecated',
|
||||
DeprecationWarning)
|
||||
|
||||
|
||||
def warn_distutils_present():
|
||||
if 'distutils' not in sys.modules:
|
||||
return
|
||||
if is_pypy and sys.version_info < (3, 7):
|
||||
# PyPy for 3.6 unconditionally imports distutils, so bypass the warning
|
||||
# https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250
|
||||
return
|
||||
warnings.warn(
|
||||
"Distutils was imported before Setuptools, but importing Setuptools "
|
||||
"also replaces the `distutils` module in `sys.modules`. This may lead "
|
||||
"to undesirable behaviors or errors. To avoid these issues, avoid "
|
||||
"using distutils directly, ensure that setuptools is installed in the "
|
||||
"traditional way (e.g. not an editable install), and/or make sure "
|
||||
"that setuptools is always imported before distutils.")
|
||||
|
||||
|
||||
def clear_distutils():
|
||||
if 'distutils' not in sys.modules:
|
||||
return
|
||||
warnings.warn("Setuptools is replacing distutils.")
|
||||
mods = [name for name in sys.modules if re.match(r'distutils\b', name)]
|
||||
for name in mods:
|
||||
del sys.modules[name]
|
||||
|
||||
|
||||
def enabled():
|
||||
"""
|
||||
Allow selection of distutils by environment variable.
|
||||
"""
|
||||
which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib')
|
||||
return which == 'local'
|
||||
|
||||
|
||||
def ensure_local_distutils():
|
||||
clear_distutils()
|
||||
|
||||
# With the DistutilsMetaFinder in place,
|
||||
# perform an import to cause distutils to be
|
||||
# loaded from setuptools._distutils. Ref #2906.
|
||||
add_shim()
|
||||
importlib.import_module('distutils')
|
||||
remove_shim()
|
||||
|
||||
# check that submodules load as expected
|
||||
core = importlib.import_module('distutils.core')
|
||||
assert '_distutils' in core.__file__, core.__file__
|
||||
|
||||
|
||||
def do_override():
|
||||
"""
|
||||
Ensure that the local copy of distutils is preferred over stdlib.
|
||||
|
||||
See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401
|
||||
for more motivation.
|
||||
"""
|
||||
if enabled():
|
||||
warn_distutils_present()
|
||||
ensure_local_distutils()
|
||||
|
||||
|
||||
class DistutilsMetaFinder:
|
||||
def find_spec(self, fullname, path, target=None):
|
||||
if path is not None:
|
||||
return
|
||||
|
||||
method_name = 'spec_for_{fullname}'.format(**locals())
|
||||
method = getattr(self, method_name, lambda: None)
|
||||
return method()
|
||||
|
||||
def spec_for_distutils(self):
|
||||
import importlib.abc
|
||||
import importlib.util
|
||||
|
||||
class DistutilsLoader(importlib.abc.Loader):
|
||||
|
||||
def create_module(self, spec):
|
||||
return importlib.import_module('setuptools._distutils')
|
||||
|
||||
def exec_module(self, module):
|
||||
pass
|
||||
|
||||
return importlib.util.spec_from_loader('distutils', DistutilsLoader())
|
||||
|
||||
def spec_for_pip(self):
|
||||
"""
|
||||
Ensure stdlib distutils when running under pip.
|
||||
See pypa/pip#8761 for rationale.
|
||||
"""
|
||||
if self.pip_imported_during_build():
|
||||
return
|
||||
clear_distutils()
|
||||
self.spec_for_distutils = lambda: None
|
||||
|
||||
@staticmethod
|
||||
def pip_imported_during_build():
|
||||
"""
|
||||
Detect if pip is being imported in a build script. Ref #2355.
|
||||
"""
|
||||
import traceback
|
||||
return any(
|
||||
frame.f_globals['__file__'].endswith('setup.py')
|
||||
for frame, line in traceback.walk_stack(None)
|
||||
)
|
||||
|
||||
|
||||
DISTUTILS_FINDER = DistutilsMetaFinder()
|
||||
|
||||
|
||||
def add_shim():
|
||||
sys.meta_path.insert(0, DISTUTILS_FINDER)
|
||||
|
||||
|
||||
def remove_shim():
|
||||
try:
|
||||
sys.meta_path.remove(DISTUTILS_FINDER)
|
||||
except ValueError:
|
||||
pass
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
__import__('_distutils_hack').do_override()
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,247 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: asgiref
|
||||
Version: 3.11.1
|
||||
Summary: ASGI specs, helper code, and adapters
|
||||
Home-page: https://github.com/django/asgiref/
|
||||
Author: Django Software Foundation
|
||||
Author-email: foundation@djangoproject.com
|
||||
License: BSD-3-Clause
|
||||
Project-URL: Documentation, https://asgi.readthedocs.io/
|
||||
Project-URL: Further Documentation, https://docs.djangoproject.com/en/stable/topics/async/#async-adapter-functions
|
||||
Project-URL: Changelog, https://github.com/django/asgiref/blob/master/CHANGELOG.txt
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3 :: Only
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
Classifier: Programming Language :: Python :: 3.12
|
||||
Classifier: Programming Language :: Python :: 3.13
|
||||
Classifier: Topic :: Internet :: WWW/HTTP
|
||||
Requires-Python: >=3.9
|
||||
License-File: LICENSE
|
||||
Requires-Dist: typing_extensions>=4; python_version < "3.11"
|
||||
Provides-Extra: tests
|
||||
Requires-Dist: pytest; extra == "tests"
|
||||
Requires-Dist: pytest-asyncio; extra == "tests"
|
||||
Requires-Dist: mypy>=1.14.0; extra == "tests"
|
||||
Dynamic: license-file
|
||||
|
||||
asgiref
|
||||
=======
|
||||
|
||||
.. image:: https://github.com/django/asgiref/actions/workflows/tests.yml/badge.svg
|
||||
:target: https://github.com/django/asgiref/actions/workflows/tests.yml
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/asgiref.svg
|
||||
:target: https://pypi.python.org/pypi/asgiref
|
||||
|
||||
ASGI is a standard for Python asynchronous web apps and servers to communicate
|
||||
with each other, and positioned as an asynchronous successor to WSGI. You can
|
||||
read more at https://asgi.readthedocs.io/en/latest/
|
||||
|
||||
This package includes ASGI base libraries, such as:
|
||||
|
||||
* Sync-to-async and async-to-sync function wrappers, ``asgiref.sync``
|
||||
* Server base classes, ``asgiref.server``
|
||||
* A WSGI-to-ASGI adapter, in ``asgiref.wsgi``
|
||||
|
||||
|
||||
Function wrappers
|
||||
-----------------
|
||||
|
||||
These allow you to wrap or decorate async or sync functions to call them from
|
||||
the other style (so you can call async functions from a synchronous thread,
|
||||
or vice-versa).
|
||||
|
||||
In particular:
|
||||
|
||||
* AsyncToSync lets a synchronous subthread stop and wait while the async
|
||||
function is called on the main thread's event loop, and then control is
|
||||
returned to the thread when the async function is finished.
|
||||
|
||||
* SyncToAsync lets async code call a synchronous function, which is run in
|
||||
a threadpool and control returned to the async coroutine when the synchronous
|
||||
function completes.
|
||||
|
||||
The idea is to make it easier to call synchronous APIs from async code and
|
||||
asynchronous APIs from synchronous code so it's easier to transition code from
|
||||
one style to the other. In the case of Channels, we wrap the (synchronous)
|
||||
Django view system with SyncToAsync to allow it to run inside the (asynchronous)
|
||||
ASGI server.
|
||||
|
||||
Note that exactly what threads things run in is very specific, and aimed to
|
||||
keep maximum compatibility with old synchronous code. See
|
||||
"Synchronous code & Threads" below for a full explanation. By default,
|
||||
``sync_to_async`` will run all synchronous code in the program in the same
|
||||
thread for safety reasons; you can disable this for more performance with
|
||||
``@sync_to_async(thread_sensitive=False)``, but make sure that your code does
|
||||
not rely on anything bound to threads (like database connections) when you do.
|
||||
|
||||
|
||||
Threadlocal replacement
|
||||
-----------------------
|
||||
|
||||
This is a drop-in replacement for ``threading.local`` that works with both
|
||||
threads and asyncio Tasks. Even better, it will proxy values through from a
|
||||
task-local context to a thread-local context when you use ``sync_to_async``
|
||||
to run things in a threadpool, and vice-versa for ``async_to_sync``.
|
||||
|
||||
If you instead want true thread- and task-safety, you can set
|
||||
``thread_critical`` on the Local object to ensure this instead.
|
||||
|
||||
|
||||
Server base classes
|
||||
-------------------
|
||||
|
||||
Includes a ``StatelessServer`` class which provides all the hard work of
|
||||
writing a stateless server (as in, does not handle direct incoming sockets
|
||||
but instead consumes external streams or sockets to work out what is happening).
|
||||
|
||||
An example of such a server would be a chatbot server that connects out to
|
||||
a central chat server and provides a "connection scope" per user chatting to
|
||||
it. There's only one actual connection, but the server has to separate things
|
||||
into several scopes for easier writing of the code.
|
||||
|
||||
You can see an example of this being used in `frequensgi <https://github.com/andrewgodwin/frequensgi>`_.
|
||||
|
||||
|
||||
WSGI-to-ASGI adapter
|
||||
--------------------
|
||||
|
||||
Allows you to wrap a WSGI application so it appears as a valid ASGI application.
|
||||
|
||||
Simply wrap it around your WSGI application like so::
|
||||
|
||||
asgi_application = WsgiToAsgi(wsgi_application)
|
||||
|
||||
The WSGI application will be run in a synchronous threadpool, and the wrapped
|
||||
ASGI application will be one that accepts ``http`` class messages.
|
||||
|
||||
Please note that not all extended features of WSGI may be supported (such as
|
||||
file handles for incoming POST bodies).
|
||||
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
``asgiref`` requires Python 3.9 or higher.
|
||||
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Please refer to the
|
||||
`main Channels contributing docs <https://github.com/django/channels/blob/master/CONTRIBUTING.rst>`_.
|
||||
|
||||
|
||||
Testing
|
||||
'''''''
|
||||
|
||||
To run tests, make sure you have installed the ``tests`` extra with the package::
|
||||
|
||||
cd asgiref/
|
||||
pip install -e .[tests]
|
||||
pytest
|
||||
|
||||
|
||||
Building the documentation
|
||||
''''''''''''''''''''''''''
|
||||
|
||||
The documentation uses `Sphinx <http://www.sphinx-doc.org>`_::
|
||||
|
||||
cd asgiref/docs/
|
||||
pip install sphinx
|
||||
|
||||
To build the docs, you can use the default tools::
|
||||
|
||||
sphinx-build -b html . _build/html # or `make html`, if you've got make set up
|
||||
cd _build/html
|
||||
python -m http.server
|
||||
|
||||
...or you can use ``sphinx-autobuild`` to run a server and rebuild/reload
|
||||
your documentation changes automatically::
|
||||
|
||||
pip install sphinx-autobuild
|
||||
sphinx-autobuild . _build/html
|
||||
|
||||
|
||||
Releasing
|
||||
'''''''''
|
||||
|
||||
To release, first add details to CHANGELOG.txt and update the version number in ``asgiref/__init__.py``.
|
||||
|
||||
Then, build and push the packages::
|
||||
|
||||
python -m build
|
||||
twine upload dist/*
|
||||
rm -r asgiref.egg-info dist
|
||||
|
||||
|
||||
Implementation Details
|
||||
----------------------
|
||||
|
||||
Synchronous code & threads
|
||||
''''''''''''''''''''''''''
|
||||
|
||||
The ``asgiref.sync`` module provides two wrappers that let you go between
|
||||
asynchronous and synchronous code at will, while taking care of the rough edges
|
||||
for you.
|
||||
|
||||
Unfortunately, the rough edges are numerous, and the code has to work especially
|
||||
hard to keep things in the same thread as much as possible. Notably, the
|
||||
restrictions we are working with are:
|
||||
|
||||
* All synchronous code called through ``SyncToAsync`` and marked with
|
||||
``thread_sensitive`` should run in the same thread as each other (and if the
|
||||
outer layer of the program is synchronous, the main thread)
|
||||
|
||||
* If a thread already has a running async loop, ``AsyncToSync`` can't run things
|
||||
on that loop if it's blocked on synchronous code that is above you in the
|
||||
call stack.
|
||||
|
||||
The first compromise you get to might be that ``thread_sensitive`` code should
|
||||
just run in the same thread and not spawn in a sub-thread, fulfilling the first
|
||||
restriction, but that immediately runs you into the second restriction.
|
||||
|
||||
The only real solution is to essentially have a variant of ThreadPoolExecutor
|
||||
that executes any ``thread_sensitive`` code on the outermost synchronous
|
||||
thread - either the main thread, or a single spawned subthread.
|
||||
|
||||
This means you now have two basic states:
|
||||
|
||||
* If the outermost layer of your program is synchronous, then all async code
|
||||
run through ``AsyncToSync`` will run in a per-call event loop in arbitrary
|
||||
sub-threads, while all ``thread_sensitive`` code will run in the main thread.
|
||||
|
||||
* If the outermost layer of your program is asynchronous, then all async code
|
||||
runs on the main thread's event loop, and all ``thread_sensitive`` synchronous
|
||||
code will run in a single shared sub-thread.
|
||||
|
||||
Crucially, this means that in both cases there is a thread which is a shared
|
||||
resource that all ``thread_sensitive`` code must run on, and there is a chance
|
||||
that this thread is currently blocked on its own ``AsyncToSync`` call. Thus,
|
||||
``AsyncToSync`` needs to act as an executor for thread code while it's blocking.
|
||||
|
||||
The ``CurrentThreadExecutor`` class provides this functionality; rather than
|
||||
simply waiting on a Future, you can call its ``run_until_future`` method and
|
||||
it will run submitted code until that Future is done. This means that code
|
||||
inside the call can then run code on your thread.
|
||||
|
||||
|
||||
Maintenance and Security
|
||||
------------------------
|
||||
|
||||
To report security issues, please contact security@djangoproject.com. For GPG
|
||||
signatures and more security process information, see
|
||||
https://docs.djangoproject.com/en/dev/internals/security/.
|
||||
|
||||
To report bugs or request new features, please open a new GitHub issue.
|
||||
|
||||
This repository is part of the Channels project. For the shepherd and maintenance team, please see the
|
||||
`main Channels readme <https://github.com/django/channels/blob/master/README.rst>`_.
|
||||
@@ -0,0 +1,27 @@
|
||||
asgiref-3.11.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
asgiref-3.11.1.dist-info/METADATA,sha256=aLePcJP6N7HpneCbacTmO_4Gc4b0PRSo2fWPwsWLeYQ,9287
|
||||
asgiref-3.11.1.dist-info/RECORD,,
|
||||
asgiref-3.11.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
||||
asgiref-3.11.1.dist-info/licenses/LICENSE,sha256=uEZBXRtRTpwd_xSiLeuQbXlLxUbKYSn5UKGM0JHipmk,1552
|
||||
asgiref-3.11.1.dist-info/top_level.txt,sha256=bokQjCzwwERhdBiPdvYEZa4cHxT4NCeAffQNUqJ8ssg,8
|
||||
asgiref/__init__.py,sha256=UuKR3QjWk9sJtn2huDFsPdSgtx1CgiEl2B4BUtVRd58,23
|
||||
asgiref/__pycache__/__init__.cpython-310.pyc,,
|
||||
asgiref/__pycache__/compatibility.cpython-310.pyc,,
|
||||
asgiref/__pycache__/current_thread_executor.cpython-310.pyc,,
|
||||
asgiref/__pycache__/local.cpython-310.pyc,,
|
||||
asgiref/__pycache__/server.cpython-310.pyc,,
|
||||
asgiref/__pycache__/sync.cpython-310.pyc,,
|
||||
asgiref/__pycache__/testing.cpython-310.pyc,,
|
||||
asgiref/__pycache__/timeout.cpython-310.pyc,,
|
||||
asgiref/__pycache__/typing.cpython-310.pyc,,
|
||||
asgiref/__pycache__/wsgi.cpython-310.pyc,,
|
||||
asgiref/compatibility.py,sha256=DhY1SOpOvOw0Y1lSEjCqg-znRUQKecG3LTaV48MZi68,1606
|
||||
asgiref/current_thread_executor.py,sha256=42CU1VODLTk-_PYise-cP1XgyAvI5Djc8f97owFzdrs,4157
|
||||
asgiref/local.py,sha256=ZZeWWIXptVU4GbNApMMWQ-skuglvodcQA5WpzJDMxh4,4912
|
||||
asgiref/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
asgiref/server.py,sha256=3A68169Nuh2sTY_2O5JzRd_opKObWvvrEFcrXssq3kA,6311
|
||||
asgiref/sync.py,sha256=KHjSkYRZKIJ1cmBvxcloGrcnhvAuEfXCWCZAoxN8grg,22929
|
||||
asgiref/testing.py,sha256=U5wcs_-ZYTO5SIGfl80EqRAGv_T8BHrAhvAKRuuztT4,4421
|
||||
asgiref/timeout.py,sha256=LtGL-xQpG8JHprdsEUCMErJ0kNWj4qwWZhEHJ3iKu4s,3627
|
||||
asgiref/typing.py,sha256=Zi72AZlOyF1C7N14LLZnpAdfUH4ljoBqFdQo_bBKMq0,6290
|
||||
asgiref/wsgi.py,sha256=OSxanm5Qf-VfrOkAx62mYW0mOnh8pwaTz1099HbJzM0,7941
|
||||
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: setuptools (80.10.2)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
Copyright (c) Django Software Foundation and individual contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Django nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1 @@
|
||||
asgiref
|
||||
1
venv/lib/python3.10/site-packages/asgiref/__init__.py
Normal file
1
venv/lib/python3.10/site-packages/asgiref/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__version__ = "3.11.1"
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
48
venv/lib/python3.10/site-packages/asgiref/compatibility.py
Normal file
48
venv/lib/python3.10/site-packages/asgiref/compatibility.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import inspect
|
||||
|
||||
from .sync import iscoroutinefunction
|
||||
|
||||
|
||||
def is_double_callable(application):
|
||||
"""
|
||||
Tests to see if an application is a legacy-style (double-callable) application.
|
||||
"""
|
||||
# Look for a hint on the object first
|
||||
if getattr(application, "_asgi_single_callable", False):
|
||||
return False
|
||||
if getattr(application, "_asgi_double_callable", False):
|
||||
return True
|
||||
# Uninstanted classes are double-callable
|
||||
if inspect.isclass(application):
|
||||
return True
|
||||
# Instanted classes depend on their __call__
|
||||
if hasattr(application, "__call__"):
|
||||
# We only check to see if its __call__ is a coroutine function -
|
||||
# if it's not, it still might be a coroutine function itself.
|
||||
if iscoroutinefunction(application.__call__):
|
||||
return False
|
||||
# Non-classes we just check directly
|
||||
return not iscoroutinefunction(application)
|
||||
|
||||
|
||||
def double_to_single_callable(application):
|
||||
"""
|
||||
Transforms a double-callable ASGI application into a single-callable one.
|
||||
"""
|
||||
|
||||
async def new_application(scope, receive, send):
|
||||
instance = application(scope)
|
||||
return await instance(receive, send)
|
||||
|
||||
return new_application
|
||||
|
||||
|
||||
def guarantee_single_callable(application):
|
||||
"""
|
||||
Takes either a single- or double-callable application and always returns it
|
||||
in single-callable style. Use this to add backwards compatibility for ASGI
|
||||
2.0 applications to your server/test harness/etc.
|
||||
"""
|
||||
if is_double_callable(application):
|
||||
application = double_to_single_callable(application)
|
||||
return application
|
||||
@@ -0,0 +1,123 @@
|
||||
import sys
|
||||
import threading
|
||||
from collections import deque
|
||||
from concurrent.futures import Executor, Future
|
||||
from typing import Any, Callable, TypeVar
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import ParamSpec
|
||||
else:
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_P = ParamSpec("_P")
|
||||
_R = TypeVar("_R")
|
||||
|
||||
|
||||
class _WorkItem:
|
||||
"""
|
||||
Represents an item needing to be run in the executor.
|
||||
Copied from ThreadPoolExecutor (but it's private, so we're not going to rely on importing it)
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
future: "Future[_R]",
|
||||
fn: Callable[_P, _R],
|
||||
*args: _P.args,
|
||||
**kwargs: _P.kwargs,
|
||||
):
|
||||
self.future = future
|
||||
self.fn = fn
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
|
||||
def run(self) -> None:
|
||||
__traceback_hide__ = True # noqa: F841
|
||||
if not self.future.set_running_or_notify_cancel():
|
||||
return
|
||||
try:
|
||||
result = self.fn(*self.args, **self.kwargs)
|
||||
except BaseException as exc:
|
||||
self.future.set_exception(exc)
|
||||
# Break a reference cycle with the exception 'exc'
|
||||
self = None # type: ignore[assignment]
|
||||
else:
|
||||
self.future.set_result(result)
|
||||
|
||||
|
||||
class CurrentThreadExecutor(Executor):
|
||||
"""
|
||||
An Executor that actually runs code in the thread it is instantiated in.
|
||||
Passed to other threads running async code, so they can run sync code in
|
||||
the thread they came from.
|
||||
"""
|
||||
|
||||
def __init__(self, old_executor: "CurrentThreadExecutor | None") -> None:
|
||||
self._work_thread = threading.current_thread()
|
||||
self._work_ready = threading.Condition(threading.Lock())
|
||||
self._work_items = deque[_WorkItem]() # synchronized by _work_ready
|
||||
self._broken = False # synchronized by _work_ready
|
||||
self._old_executor = old_executor
|
||||
|
||||
def run_until_future(self, future: "Future[Any]") -> None:
|
||||
"""
|
||||
Runs the code in the work queue until a result is available from the future.
|
||||
Should be run from the thread the executor is initialised in.
|
||||
"""
|
||||
# Check we're in the right thread
|
||||
if threading.current_thread() != self._work_thread:
|
||||
raise RuntimeError(
|
||||
"You cannot run CurrentThreadExecutor from a different thread"
|
||||
)
|
||||
|
||||
def done(future: "Future[Any]") -> None:
|
||||
with self._work_ready:
|
||||
self._broken = True
|
||||
self._work_ready.notify()
|
||||
|
||||
future.add_done_callback(done)
|
||||
# Keep getting and running work items until the future we're waiting for
|
||||
# is done and the queue is empty.
|
||||
while True:
|
||||
with self._work_ready:
|
||||
while not self._work_items and not self._broken:
|
||||
self._work_ready.wait()
|
||||
if not self._work_items:
|
||||
break
|
||||
# Get a work item and run it
|
||||
work_item = self._work_items.popleft()
|
||||
work_item.run()
|
||||
del work_item
|
||||
|
||||
def submit(
|
||||
self,
|
||||
fn: Callable[_P, _R],
|
||||
/,
|
||||
*args: _P.args,
|
||||
**kwargs: _P.kwargs,
|
||||
) -> "Future[_R]":
|
||||
# Check they're not submitting from the same thread
|
||||
if threading.current_thread() == self._work_thread:
|
||||
raise RuntimeError(
|
||||
"You cannot submit onto CurrentThreadExecutor from its own thread"
|
||||
)
|
||||
f: "Future[_R]" = Future()
|
||||
work_item = _WorkItem(f, fn, *args, **kwargs)
|
||||
|
||||
# Walk up the CurrentThreadExecutor stack to find the closest one still
|
||||
# running
|
||||
executor = self
|
||||
while True:
|
||||
with executor._work_ready:
|
||||
if not executor._broken:
|
||||
# Add to work queue
|
||||
executor._work_items.append(work_item)
|
||||
executor._work_ready.notify()
|
||||
break
|
||||
if executor._old_executor is None:
|
||||
raise RuntimeError("CurrentThreadExecutor already quit or is broken")
|
||||
executor = executor._old_executor
|
||||
|
||||
# Return the future
|
||||
return f
|
||||
131
venv/lib/python3.10/site-packages/asgiref/local.py
Normal file
131
venv/lib/python3.10/site-packages/asgiref/local.py
Normal file
@@ -0,0 +1,131 @@
|
||||
import asyncio
|
||||
import contextlib
|
||||
import contextvars
|
||||
import threading
|
||||
from typing import Any, Dict, Union
|
||||
|
||||
|
||||
class _CVar:
|
||||
"""Storage utility for Local."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._data: "contextvars.ContextVar[Dict[str, Any]]" = contextvars.ContextVar(
|
||||
"asgiref.local"
|
||||
)
|
||||
|
||||
def __getattr__(self, key):
|
||||
storage_object = self._data.get({})
|
||||
try:
|
||||
return storage_object[key]
|
||||
except KeyError:
|
||||
raise AttributeError(f"{self!r} object has no attribute {key!r}")
|
||||
|
||||
def __setattr__(self, key: str, value: Any) -> None:
|
||||
if key == "_data":
|
||||
return super().__setattr__(key, value)
|
||||
|
||||
storage_object = self._data.get({}).copy()
|
||||
storage_object[key] = value
|
||||
self._data.set(storage_object)
|
||||
|
||||
def __delattr__(self, key: str) -> None:
|
||||
storage_object = self._data.get({}).copy()
|
||||
if key in storage_object:
|
||||
del storage_object[key]
|
||||
self._data.set(storage_object)
|
||||
else:
|
||||
raise AttributeError(f"{self!r} object has no attribute {key!r}")
|
||||
|
||||
|
||||
class Local:
|
||||
"""Local storage for async tasks.
|
||||
|
||||
This is a namespace object (similar to `threading.local`) where data is
|
||||
also local to the current async task (if there is one).
|
||||
|
||||
In async threads, local means in the same sense as the `contextvars`
|
||||
module - i.e. a value set in an async frame will be visible:
|
||||
|
||||
- to other async code `await`-ed from this frame.
|
||||
- to tasks spawned using `asyncio` utilities (`create_task`, `wait_for`,
|
||||
`gather` and probably others).
|
||||
- to code scheduled in a sync thread using `sync_to_async`
|
||||
|
||||
In "sync" threads (a thread with no async event loop running), the
|
||||
data is thread-local, but additionally shared with async code executed
|
||||
via the `async_to_sync` utility, which schedules async code in a new thread
|
||||
and copies context across to that thread.
|
||||
|
||||
If `thread_critical` is True, then the local will only be visible per-thread,
|
||||
behaving exactly like `threading.local` if the thread is sync, and as
|
||||
`contextvars` if the thread is async. This allows genuinely thread-sensitive
|
||||
code (such as DB handles) to be kept stricly to their initial thread and
|
||||
disable the sharing across `sync_to_async` and `async_to_sync` wrapped calls.
|
||||
|
||||
Unlike plain `contextvars` objects, this utility is threadsafe.
|
||||
"""
|
||||
|
||||
def __init__(self, thread_critical: bool = False) -> None:
|
||||
self._thread_critical = thread_critical
|
||||
self._thread_lock = threading.RLock()
|
||||
|
||||
self._storage: "Union[threading.local, _CVar]"
|
||||
|
||||
if thread_critical:
|
||||
# Thread-local storage
|
||||
self._storage = threading.local()
|
||||
else:
|
||||
# Contextvar storage
|
||||
self._storage = _CVar()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _lock_storage(self):
|
||||
# Thread safe access to storage
|
||||
if self._thread_critical:
|
||||
is_async = True
|
||||
try:
|
||||
# this is a test for are we in a async or sync
|
||||
# thread - will raise RuntimeError if there is
|
||||
# no current loop
|
||||
asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
is_async = False
|
||||
if not is_async:
|
||||
# We are in a sync thread, the storage is
|
||||
# just the plain thread local (i.e, "global within
|
||||
# this thread" - it doesn't matter where you are
|
||||
# in a call stack you see the same storage)
|
||||
yield self._storage
|
||||
else:
|
||||
# We are in an async thread - storage is still
|
||||
# local to this thread, but additionally should
|
||||
# behave like a context var (is only visible with
|
||||
# the same async call stack)
|
||||
|
||||
# Ensure context exists in the current thread
|
||||
if not hasattr(self._storage, "cvar"):
|
||||
self._storage.cvar = _CVar()
|
||||
|
||||
# self._storage is a thread local, so the members
|
||||
# can't be accessed in another thread (we don't
|
||||
# need any locks)
|
||||
yield self._storage.cvar
|
||||
else:
|
||||
# Lock for thread_critical=False as other threads
|
||||
# can access the exact same storage object
|
||||
with self._thread_lock:
|
||||
yield self._storage
|
||||
|
||||
def __getattr__(self, key):
|
||||
with self._lock_storage() as storage:
|
||||
return getattr(storage, key)
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
if key in ("_local", "_storage", "_thread_critical", "_thread_lock"):
|
||||
return super().__setattr__(key, value)
|
||||
with self._lock_storage() as storage:
|
||||
setattr(storage, key, value)
|
||||
|
||||
def __delattr__(self, key):
|
||||
with self._lock_storage() as storage:
|
||||
delattr(storage, key)
|
||||
0
venv/lib/python3.10/site-packages/asgiref/py.typed
Normal file
0
venv/lib/python3.10/site-packages/asgiref/py.typed
Normal file
173
venv/lib/python3.10/site-packages/asgiref/server.py
Normal file
173
venv/lib/python3.10/site-packages/asgiref/server.py
Normal file
@@ -0,0 +1,173 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from .compatibility import guarantee_single_callable
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StatelessServer:
|
||||
"""
|
||||
Base server class that handles basic concepts like application instance
|
||||
creation/pooling, exception handling, and similar, for stateless protocols
|
||||
(i.e. ones without actual incoming connections to the process)
|
||||
|
||||
Your code should override the handle() method, doing whatever it needs to,
|
||||
and calling get_or_create_application_instance with a unique `scope_id`
|
||||
and `scope` for the scope it wants to get.
|
||||
|
||||
If an application instance is found with the same `scope_id`, you are
|
||||
given its input queue, otherwise one is made for you with the scope provided
|
||||
and you are given that fresh new input queue. Either way, you should do
|
||||
something like:
|
||||
|
||||
input_queue = self.get_or_create_application_instance(
|
||||
"user-123456",
|
||||
{"type": "testprotocol", "user_id": "123456", "username": "andrew"},
|
||||
)
|
||||
input_queue.put_nowait(message)
|
||||
|
||||
If you try and create an application instance and there are already
|
||||
`max_application` instances, the oldest/least recently used one will be
|
||||
reclaimed and shut down to make space.
|
||||
|
||||
Application coroutines that error will be found periodically (every 100ms
|
||||
by default) and have their exceptions printed to the console. Override
|
||||
application_exception() if you want to do more when this happens.
|
||||
|
||||
If you override run(), make sure you handle things like launching the
|
||||
application checker.
|
||||
"""
|
||||
|
||||
application_checker_interval = 0.1
|
||||
|
||||
def __init__(self, application, max_applications=1000):
|
||||
# Parameters
|
||||
self.application = application
|
||||
self.max_applications = max_applications
|
||||
# Initialisation
|
||||
self.application_instances = {}
|
||||
|
||||
### Mainloop and handling
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Runs the asyncio event loop with our handler loop.
|
||||
"""
|
||||
event_loop = asyncio.get_event_loop()
|
||||
try:
|
||||
event_loop.run_until_complete(self.arun())
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Exiting due to Ctrl-C/interrupt")
|
||||
|
||||
async def arun(self):
|
||||
"""
|
||||
Runs the asyncio event loop with our handler loop.
|
||||
"""
|
||||
|
||||
class Done(Exception):
|
||||
pass
|
||||
|
||||
async def handle():
|
||||
await self.handle()
|
||||
raise Done
|
||||
|
||||
try:
|
||||
await asyncio.gather(self.application_checker(), handle())
|
||||
except Done:
|
||||
pass
|
||||
|
||||
async def handle(self):
|
||||
raise NotImplementedError("You must implement handle()")
|
||||
|
||||
async def application_send(self, scope, message):
|
||||
"""
|
||||
Receives outbound sends from applications and handles them.
|
||||
"""
|
||||
raise NotImplementedError("You must implement application_send()")
|
||||
|
||||
### Application instance management
|
||||
|
||||
def get_or_create_application_instance(self, scope_id, scope):
|
||||
"""
|
||||
Creates an application instance and returns its queue.
|
||||
"""
|
||||
if scope_id in self.application_instances:
|
||||
self.application_instances[scope_id]["last_used"] = time.time()
|
||||
return self.application_instances[scope_id]["input_queue"]
|
||||
# See if we need to delete an old one
|
||||
while len(self.application_instances) > self.max_applications:
|
||||
self.delete_oldest_application_instance()
|
||||
# Make an instance of the application
|
||||
input_queue = asyncio.Queue()
|
||||
application_instance = guarantee_single_callable(self.application)
|
||||
# Run it, and stash the future for later checking
|
||||
future = asyncio.ensure_future(
|
||||
application_instance(
|
||||
scope=scope,
|
||||
receive=input_queue.get,
|
||||
send=lambda message: self.application_send(scope, message),
|
||||
),
|
||||
)
|
||||
self.application_instances[scope_id] = {
|
||||
"input_queue": input_queue,
|
||||
"future": future,
|
||||
"scope": scope,
|
||||
"last_used": time.time(),
|
||||
}
|
||||
return input_queue
|
||||
|
||||
def delete_oldest_application_instance(self):
|
||||
"""
|
||||
Finds and deletes the oldest application instance
|
||||
"""
|
||||
oldest_time = min(
|
||||
details["last_used"] for details in self.application_instances.values()
|
||||
)
|
||||
for scope_id, details in self.application_instances.items():
|
||||
if details["last_used"] == oldest_time:
|
||||
self.delete_application_instance(scope_id)
|
||||
# Return to make sure we only delete one in case two have
|
||||
# the same oldest time
|
||||
return
|
||||
|
||||
def delete_application_instance(self, scope_id):
|
||||
"""
|
||||
Removes an application instance (makes sure its task is stopped,
|
||||
then removes it from the current set)
|
||||
"""
|
||||
details = self.application_instances[scope_id]
|
||||
del self.application_instances[scope_id]
|
||||
if not details["future"].done():
|
||||
details["future"].cancel()
|
||||
|
||||
async def application_checker(self):
|
||||
"""
|
||||
Goes through the set of current application instance Futures and cleans up
|
||||
any that are done/prints exceptions for any that errored.
|
||||
"""
|
||||
while True:
|
||||
await asyncio.sleep(self.application_checker_interval)
|
||||
for scope_id, details in list(self.application_instances.items()):
|
||||
if details["future"].done():
|
||||
exception = details["future"].exception()
|
||||
if exception:
|
||||
await self.application_exception(exception, details)
|
||||
try:
|
||||
del self.application_instances[scope_id]
|
||||
except KeyError:
|
||||
# Exception handling might have already got here before us. That's fine.
|
||||
pass
|
||||
|
||||
async def application_exception(self, exception, application_details):
|
||||
"""
|
||||
Called whenever an application coroutine has an exception.
|
||||
"""
|
||||
logging.error(
|
||||
"Exception inside application: %s\n%s%s",
|
||||
exception,
|
||||
"".join(traceback.format_tb(exception.__traceback__)),
|
||||
f" {exception}",
|
||||
)
|
||||
657
venv/lib/python3.10/site-packages/asgiref/sync.py
Normal file
657
venv/lib/python3.10/site-packages/asgiref/sync.py
Normal file
@@ -0,0 +1,657 @@
|
||||
import asyncio
|
||||
import asyncio.coroutines
|
||||
import contextvars
|
||||
import functools
|
||||
import inspect
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import warnings
|
||||
import weakref
|
||||
from concurrent.futures import Future, ThreadPoolExecutor
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Awaitable,
|
||||
Callable,
|
||||
Coroutine,
|
||||
Dict,
|
||||
Generic,
|
||||
List,
|
||||
Optional,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
|
||||
from .current_thread_executor import CurrentThreadExecutor
|
||||
from .local import Local
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import ParamSpec
|
||||
else:
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# This is not available to import at runtime
|
||||
from _typeshed import OptExcInfo
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
_P = ParamSpec("_P")
|
||||
_R = TypeVar("_R")
|
||||
|
||||
|
||||
def _restore_context(context: contextvars.Context) -> None:
|
||||
# Check for changes in contextvars, and set them to the current
|
||||
# context for downstream consumers
|
||||
for cvar in context:
|
||||
cvalue = context.get(cvar)
|
||||
try:
|
||||
if cvar.get() != cvalue:
|
||||
cvar.set(cvalue)
|
||||
except LookupError:
|
||||
cvar.set(cvalue)
|
||||
|
||||
|
||||
# Python 3.12 deprecates asyncio.iscoroutinefunction() as an alias for
|
||||
# inspect.iscoroutinefunction(), whilst also removing the _is_coroutine marker.
|
||||
# The latter is replaced with the inspect.markcoroutinefunction decorator.
|
||||
# Until 3.12 is the minimum supported Python version, provide a shim.
|
||||
|
||||
if hasattr(inspect, "markcoroutinefunction"):
|
||||
iscoroutinefunction = inspect.iscoroutinefunction
|
||||
markcoroutinefunction: Callable[[_F], _F] = inspect.markcoroutinefunction
|
||||
else:
|
||||
iscoroutinefunction = asyncio.iscoroutinefunction # type: ignore[assignment]
|
||||
|
||||
def markcoroutinefunction(func: _F) -> _F:
|
||||
func._is_coroutine = asyncio.coroutines._is_coroutine # type: ignore
|
||||
return func
|
||||
|
||||
|
||||
class AsyncSingleThreadContext:
|
||||
"""Context manager to run async code inside the same thread.
|
||||
|
||||
Normally, AsyncToSync functions run either inside a separate ThreadPoolExecutor or
|
||||
the main event loop if it exists. This context manager ensures that all AsyncToSync
|
||||
functions execute within the same thread.
|
||||
|
||||
This context manager is re-entrant, so only the outer-most call to
|
||||
AsyncSingleThreadContext will set the context.
|
||||
|
||||
Usage:
|
||||
|
||||
>>> import asyncio
|
||||
>>> with AsyncSingleThreadContext():
|
||||
... async_to_sync(asyncio.sleep(1))()
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.token = None
|
||||
|
||||
def __enter__(self):
|
||||
try:
|
||||
AsyncToSync.async_single_thread_context.get()
|
||||
except LookupError:
|
||||
self.token = AsyncToSync.async_single_thread_context.set(self)
|
||||
|
||||
return self
|
||||
|
||||
def __exit__(self, exc, value, tb):
|
||||
if not self.token:
|
||||
return
|
||||
|
||||
executor = AsyncToSync.context_to_thread_executor.pop(self, None)
|
||||
if executor:
|
||||
executor.shutdown()
|
||||
|
||||
AsyncToSync.async_single_thread_context.reset(self.token)
|
||||
|
||||
|
||||
class ThreadSensitiveContext:
|
||||
"""Async context manager to manage context for thread sensitive mode
|
||||
|
||||
This context manager controls which thread pool executor is used when in
|
||||
thread sensitive mode. By default, a single thread pool executor is shared
|
||||
within a process.
|
||||
|
||||
The ThreadSensitiveContext() context manager may be used to specify a
|
||||
thread pool per context.
|
||||
|
||||
This context manager is re-entrant, so only the outer-most call to
|
||||
ThreadSensitiveContext will set the context.
|
||||
|
||||
Usage:
|
||||
|
||||
>>> import time
|
||||
>>> async with ThreadSensitiveContext():
|
||||
... await sync_to_async(time.sleep, 1)()
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.token = None
|
||||
|
||||
async def __aenter__(self):
|
||||
try:
|
||||
SyncToAsync.thread_sensitive_context.get()
|
||||
except LookupError:
|
||||
self.token = SyncToAsync.thread_sensitive_context.set(self)
|
||||
|
||||
return self
|
||||
|
||||
async def __aexit__(self, exc, value, tb):
|
||||
if not self.token:
|
||||
return
|
||||
|
||||
executor = SyncToAsync.context_to_thread_executor.pop(self, None)
|
||||
if executor:
|
||||
executor.shutdown()
|
||||
SyncToAsync.thread_sensitive_context.reset(self.token)
|
||||
|
||||
|
||||
class AsyncToSync(Generic[_P, _R]):
|
||||
"""
|
||||
Utility class which turns an awaitable that only works on the thread with
|
||||
the event loop into a synchronous callable that works in a subthread.
|
||||
|
||||
If the call stack contains an async loop, the code runs there.
|
||||
Otherwise, the code runs in a new loop in a new thread.
|
||||
|
||||
Either way, this thread then pauses and waits to run any thread_sensitive
|
||||
code called from further down the call stack using SyncToAsync, before
|
||||
finally exiting once the async task returns.
|
||||
"""
|
||||
|
||||
# Keeps a reference to the CurrentThreadExecutor in local context, so that
|
||||
# any sync_to_async inside the wrapped code can find it.
|
||||
executors: "Local" = Local()
|
||||
|
||||
# When we can't find a CurrentThreadExecutor from the context, such as
|
||||
# inside create_task, we'll look it up here from the running event loop.
|
||||
loop_thread_executors: "Dict[asyncio.AbstractEventLoop, CurrentThreadExecutor]" = {}
|
||||
|
||||
async_single_thread_context: "contextvars.ContextVar[AsyncSingleThreadContext]" = (
|
||||
contextvars.ContextVar("async_single_thread_context")
|
||||
)
|
||||
|
||||
context_to_thread_executor: "weakref.WeakKeyDictionary[AsyncSingleThreadContext, ThreadPoolExecutor]" = (
|
||||
weakref.WeakKeyDictionary()
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
awaitable: Union[
|
||||
Callable[_P, Coroutine[Any, Any, _R]],
|
||||
Callable[_P, Awaitable[_R]],
|
||||
],
|
||||
force_new_loop: bool = False,
|
||||
):
|
||||
if not callable(awaitable) or (
|
||||
not iscoroutinefunction(awaitable)
|
||||
and not iscoroutinefunction(getattr(awaitable, "__call__", awaitable))
|
||||
):
|
||||
# Python does not have very reliable detection of async functions
|
||||
# (lots of false negatives) so this is just a warning.
|
||||
warnings.warn(
|
||||
"async_to_sync was passed a non-async-marked callable", stacklevel=2
|
||||
)
|
||||
self.awaitable = awaitable
|
||||
try:
|
||||
self.__self__ = self.awaitable.__self__ # type: ignore[union-attr]
|
||||
except AttributeError:
|
||||
pass
|
||||
self.force_new_loop = force_new_loop
|
||||
self.main_event_loop = None
|
||||
try:
|
||||
self.main_event_loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
# There's no event loop in this thread.
|
||||
pass
|
||||
|
||||
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
|
||||
__traceback_hide__ = True # noqa: F841
|
||||
|
||||
if not self.force_new_loop and not self.main_event_loop:
|
||||
# There's no event loop in this thread. Look for the threadlocal if
|
||||
# we're inside SyncToAsync
|
||||
main_event_loop_pid = getattr(
|
||||
SyncToAsync.threadlocal, "main_event_loop_pid", None
|
||||
)
|
||||
# We make sure the parent loop is from the same process - if
|
||||
# they've forked, this is not going to be valid any more (#194)
|
||||
if main_event_loop_pid and main_event_loop_pid == os.getpid():
|
||||
self.main_event_loop = getattr(
|
||||
SyncToAsync.threadlocal, "main_event_loop", None
|
||||
)
|
||||
|
||||
# You can't call AsyncToSync from a thread with a running event loop
|
||||
try:
|
||||
asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"You cannot use AsyncToSync in the same thread as an async event loop - "
|
||||
"just await the async function directly."
|
||||
)
|
||||
|
||||
# Make a future for the return information
|
||||
call_result: "Future[_R]" = Future()
|
||||
|
||||
# Make a CurrentThreadExecutor we'll use to idle in this thread - we
|
||||
# need one for every sync frame, even if there's one above us in the
|
||||
# same thread.
|
||||
old_executor = getattr(self.executors, "current", None)
|
||||
current_executor = CurrentThreadExecutor(old_executor)
|
||||
self.executors.current = current_executor
|
||||
|
||||
# Wrapping context in list so it can be reassigned from within
|
||||
# `main_wrap`.
|
||||
context = [contextvars.copy_context()]
|
||||
|
||||
# Get task context so that parent task knows which task to propagate
|
||||
# an asyncio.CancelledError to.
|
||||
task_context = getattr(SyncToAsync.threadlocal, "task_context", None)
|
||||
|
||||
# Use call_soon_threadsafe to schedule a synchronous callback on the
|
||||
# main event loop's thread if it's there, otherwise make a new loop
|
||||
# in this thread.
|
||||
try:
|
||||
awaitable = self.main_wrap(
|
||||
call_result,
|
||||
sys.exc_info(),
|
||||
task_context,
|
||||
context,
|
||||
# prepare an awaitable which can be passed as is to self.main_wrap,
|
||||
# so that `args` and `kwargs` don't need to be
|
||||
# destructured when passed to self.main_wrap
|
||||
# (which is required by `ParamSpec`)
|
||||
# as that may cause overlapping arguments
|
||||
self.awaitable(*args, **kwargs),
|
||||
)
|
||||
|
||||
async def new_loop_wrap() -> None:
|
||||
loop = asyncio.get_running_loop()
|
||||
self.loop_thread_executors[loop] = current_executor
|
||||
try:
|
||||
await awaitable
|
||||
finally:
|
||||
del self.loop_thread_executors[loop]
|
||||
|
||||
if self.main_event_loop is not None:
|
||||
try:
|
||||
self.main_event_loop.call_soon_threadsafe(
|
||||
self.main_event_loop.create_task, awaitable
|
||||
)
|
||||
except RuntimeError:
|
||||
running_in_main_event_loop = False
|
||||
else:
|
||||
running_in_main_event_loop = True
|
||||
# Run the CurrentThreadExecutor until the future is done.
|
||||
current_executor.run_until_future(call_result)
|
||||
else:
|
||||
running_in_main_event_loop = False
|
||||
|
||||
if not running_in_main_event_loop:
|
||||
loop_executor = None
|
||||
|
||||
if self.async_single_thread_context.get(None):
|
||||
single_thread_context = self.async_single_thread_context.get()
|
||||
|
||||
if single_thread_context in self.context_to_thread_executor:
|
||||
loop_executor = self.context_to_thread_executor[
|
||||
single_thread_context
|
||||
]
|
||||
else:
|
||||
loop_executor = ThreadPoolExecutor(max_workers=1)
|
||||
self.context_to_thread_executor[
|
||||
single_thread_context
|
||||
] = loop_executor
|
||||
else:
|
||||
# Make our own event loop - in a new thread - and run inside that.
|
||||
loop_executor = ThreadPoolExecutor(max_workers=1)
|
||||
|
||||
loop_future = loop_executor.submit(asyncio.run, new_loop_wrap())
|
||||
# Run the CurrentThreadExecutor until the future is done.
|
||||
current_executor.run_until_future(loop_future)
|
||||
# Wait for future and/or allow for exception propagation
|
||||
loop_future.result()
|
||||
finally:
|
||||
_restore_context(context[0])
|
||||
# Restore old current thread executor state
|
||||
self.executors.current = old_executor
|
||||
|
||||
# Wait for results from the future.
|
||||
return call_result.result()
|
||||
|
||||
def __get__(self, parent: Any, objtype: Any) -> Callable[_P, _R]:
|
||||
"""
|
||||
Include self for methods
|
||||
"""
|
||||
func = functools.partial(self.__call__, parent)
|
||||
return functools.update_wrapper(func, self.awaitable)
|
||||
|
||||
async def main_wrap(
|
||||
self,
|
||||
call_result: "Future[_R]",
|
||||
exc_info: "OptExcInfo",
|
||||
task_context: "Optional[List[asyncio.Task[Any]]]",
|
||||
context: List[contextvars.Context],
|
||||
awaitable: Union[Coroutine[Any, Any, _R], Awaitable[_R]],
|
||||
) -> None:
|
||||
"""
|
||||
Wraps the awaitable with something that puts the result into the
|
||||
result/exception future.
|
||||
"""
|
||||
|
||||
__traceback_hide__ = True # noqa: F841
|
||||
|
||||
if context is not None:
|
||||
_restore_context(context[0])
|
||||
|
||||
current_task = asyncio.current_task()
|
||||
if current_task is not None and task_context is not None:
|
||||
task_context.append(current_task)
|
||||
|
||||
try:
|
||||
# If we have an exception, run the function inside the except block
|
||||
# after raising it so exc_info is correctly populated.
|
||||
if exc_info[1]:
|
||||
try:
|
||||
raise exc_info[1]
|
||||
except BaseException:
|
||||
result = await awaitable
|
||||
else:
|
||||
result = await awaitable
|
||||
except BaseException as e:
|
||||
call_result.set_exception(e)
|
||||
else:
|
||||
call_result.set_result(result)
|
||||
finally:
|
||||
if current_task is not None and task_context is not None:
|
||||
task_context.remove(current_task)
|
||||
context[0] = contextvars.copy_context()
|
||||
|
||||
|
||||
class SyncToAsync(Generic[_P, _R]):
|
||||
"""
|
||||
Utility class which turns a synchronous callable into an awaitable that
|
||||
runs in a threadpool. It also sets a threadlocal inside the thread so
|
||||
calls to AsyncToSync can escape it.
|
||||
|
||||
If thread_sensitive is passed, the code will run in the same thread as any
|
||||
outer code. This is needed for underlying Python code that is not
|
||||
threadsafe (for example, code which handles SQLite database connections).
|
||||
|
||||
If the outermost program is async (i.e. SyncToAsync is outermost), then
|
||||
this will be a dedicated single sub-thread that all sync code runs in,
|
||||
one after the other. If the outermost program is sync (i.e. AsyncToSync is
|
||||
outermost), this will just be the main thread. This is achieved by idling
|
||||
with a CurrentThreadExecutor while AsyncToSync is blocking its sync parent,
|
||||
rather than just blocking.
|
||||
|
||||
If executor is passed in, that will be used instead of the loop's default executor.
|
||||
In order to pass in an executor, thread_sensitive must be set to False, otherwise
|
||||
a TypeError will be raised.
|
||||
"""
|
||||
|
||||
# Storage for main event loop references
|
||||
threadlocal = threading.local()
|
||||
|
||||
# Single-thread executor for thread-sensitive code
|
||||
single_thread_executor = ThreadPoolExecutor(max_workers=1)
|
||||
|
||||
# Maintain a contextvar for the current execution context. Optionally used
|
||||
# for thread sensitive mode.
|
||||
thread_sensitive_context: "contextvars.ContextVar[ThreadSensitiveContext]" = (
|
||||
contextvars.ContextVar("thread_sensitive_context")
|
||||
)
|
||||
|
||||
# Contextvar that is used to detect if the single thread executor
|
||||
# would be awaited on while already being used in the same context
|
||||
deadlock_context: "contextvars.ContextVar[bool]" = contextvars.ContextVar(
|
||||
"deadlock_context"
|
||||
)
|
||||
|
||||
# Maintaining a weak reference to the context ensures that thread pools are
|
||||
# erased once the context goes out of scope. This terminates the thread pool.
|
||||
context_to_thread_executor: "weakref.WeakKeyDictionary[ThreadSensitiveContext, ThreadPoolExecutor]" = (
|
||||
weakref.WeakKeyDictionary()
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
func: Callable[_P, _R],
|
||||
thread_sensitive: bool = True,
|
||||
executor: Optional["ThreadPoolExecutor"] = None,
|
||||
context: Optional[contextvars.Context] = None,
|
||||
) -> None:
|
||||
if (
|
||||
not callable(func)
|
||||
or iscoroutinefunction(func)
|
||||
or iscoroutinefunction(getattr(func, "__call__", func))
|
||||
):
|
||||
raise TypeError("sync_to_async can only be applied to sync functions.")
|
||||
|
||||
functools.update_wrapper(self, func)
|
||||
self.func = func
|
||||
self.context = context
|
||||
|
||||
self._thread_sensitive = thread_sensitive
|
||||
markcoroutinefunction(self)
|
||||
if thread_sensitive and executor is not None:
|
||||
raise TypeError("executor must not be set when thread_sensitive is True")
|
||||
self._executor = executor
|
||||
try:
|
||||
self.__self__ = func.__self__ # type: ignore
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
async def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
|
||||
__traceback_hide__ = True # noqa: F841
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
# Work out what thread to run the code in
|
||||
if self._thread_sensitive:
|
||||
current_thread_executor = getattr(AsyncToSync.executors, "current", None)
|
||||
if current_thread_executor:
|
||||
# If we have a parent sync thread above somewhere, use that
|
||||
executor = current_thread_executor
|
||||
elif self.thread_sensitive_context.get(None):
|
||||
# If we have a way of retrieving the current context, attempt
|
||||
# to use a per-context thread pool executor
|
||||
thread_sensitive_context = self.thread_sensitive_context.get()
|
||||
|
||||
if thread_sensitive_context in self.context_to_thread_executor:
|
||||
# Re-use thread executor in current context
|
||||
executor = self.context_to_thread_executor[thread_sensitive_context]
|
||||
else:
|
||||
# Create new thread executor in current context
|
||||
executor = ThreadPoolExecutor(max_workers=1)
|
||||
self.context_to_thread_executor[thread_sensitive_context] = executor
|
||||
elif loop in AsyncToSync.loop_thread_executors:
|
||||
# Re-use thread executor for running loop
|
||||
executor = AsyncToSync.loop_thread_executors[loop]
|
||||
elif self.deadlock_context.get(False):
|
||||
raise RuntimeError(
|
||||
"Single thread executor already being used, would deadlock"
|
||||
)
|
||||
else:
|
||||
# Otherwise, we run it in a fixed single thread
|
||||
executor = self.single_thread_executor
|
||||
self.deadlock_context.set(True)
|
||||
else:
|
||||
# Use the passed in executor, or the loop's default if it is None
|
||||
executor = self._executor
|
||||
|
||||
context = contextvars.copy_context() if self.context is None else self.context
|
||||
child = functools.partial(self.func, *args, **kwargs)
|
||||
func = context.run
|
||||
task_context: List[asyncio.Task[Any]] = []
|
||||
|
||||
# Run the code in the right thread
|
||||
exec_coro = loop.run_in_executor(
|
||||
executor,
|
||||
functools.partial(
|
||||
self.thread_handler,
|
||||
loop,
|
||||
sys.exc_info(),
|
||||
task_context,
|
||||
func,
|
||||
child,
|
||||
),
|
||||
)
|
||||
ret: _R
|
||||
try:
|
||||
ret = await asyncio.shield(exec_coro)
|
||||
except asyncio.CancelledError:
|
||||
cancel_parent = True
|
||||
try:
|
||||
task = task_context[0]
|
||||
task.cancel()
|
||||
try:
|
||||
await task
|
||||
cancel_parent = False
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
except IndexError:
|
||||
pass
|
||||
if exec_coro.done():
|
||||
raise
|
||||
if cancel_parent:
|
||||
exec_coro.cancel()
|
||||
ret = await exec_coro
|
||||
finally:
|
||||
if self.context is None:
|
||||
_restore_context(context)
|
||||
self.deadlock_context.set(False)
|
||||
|
||||
return ret
|
||||
|
||||
def __get__(
|
||||
self, parent: Any, objtype: Any
|
||||
) -> Callable[_P, Coroutine[Any, Any, _R]]:
|
||||
"""
|
||||
Include self for methods
|
||||
"""
|
||||
func = functools.partial(self.__call__, parent)
|
||||
return functools.update_wrapper(func, self.func)
|
||||
|
||||
def thread_handler(self, loop, exc_info, task_context, func, *args, **kwargs):
|
||||
"""
|
||||
Wraps the sync application with exception handling.
|
||||
"""
|
||||
|
||||
__traceback_hide__ = True # noqa: F841
|
||||
|
||||
# Set the threadlocal for AsyncToSync
|
||||
self.threadlocal.main_event_loop = loop
|
||||
self.threadlocal.main_event_loop_pid = os.getpid()
|
||||
self.threadlocal.task_context = task_context
|
||||
|
||||
# Run the function
|
||||
# If we have an exception, run the function inside the except block
|
||||
# after raising it so exc_info is correctly populated.
|
||||
if exc_info[1]:
|
||||
try:
|
||||
raise exc_info[1]
|
||||
except BaseException:
|
||||
return func(*args, **kwargs)
|
||||
else:
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
||||
@overload
|
||||
def async_to_sync(
|
||||
*,
|
||||
force_new_loop: bool = False,
|
||||
) -> Callable[
|
||||
[Union[Callable[_P, Coroutine[Any, Any, _R]], Callable[_P, Awaitable[_R]]]],
|
||||
Callable[_P, _R],
|
||||
]:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def async_to_sync(
|
||||
awaitable: Union[
|
||||
Callable[_P, Coroutine[Any, Any, _R]],
|
||||
Callable[_P, Awaitable[_R]],
|
||||
],
|
||||
*,
|
||||
force_new_loop: bool = False,
|
||||
) -> Callable[_P, _R]:
|
||||
...
|
||||
|
||||
|
||||
def async_to_sync(
|
||||
awaitable: Optional[
|
||||
Union[
|
||||
Callable[_P, Coroutine[Any, Any, _R]],
|
||||
Callable[_P, Awaitable[_R]],
|
||||
]
|
||||
] = None,
|
||||
*,
|
||||
force_new_loop: bool = False,
|
||||
) -> Union[
|
||||
Callable[
|
||||
[Union[Callable[_P, Coroutine[Any, Any, _R]], Callable[_P, Awaitable[_R]]]],
|
||||
Callable[_P, _R],
|
||||
],
|
||||
Callable[_P, _R],
|
||||
]:
|
||||
if awaitable is None:
|
||||
return lambda f: AsyncToSync(
|
||||
f,
|
||||
force_new_loop=force_new_loop,
|
||||
)
|
||||
return AsyncToSync(
|
||||
awaitable,
|
||||
force_new_loop=force_new_loop,
|
||||
)
|
||||
|
||||
|
||||
@overload
|
||||
def sync_to_async(
|
||||
*,
|
||||
thread_sensitive: bool = True,
|
||||
executor: Optional["ThreadPoolExecutor"] = None,
|
||||
context: Optional[contextvars.Context] = None,
|
||||
) -> Callable[[Callable[_P, _R]], Callable[_P, Coroutine[Any, Any, _R]]]:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def sync_to_async(
|
||||
func: Callable[_P, _R],
|
||||
*,
|
||||
thread_sensitive: bool = True,
|
||||
executor: Optional["ThreadPoolExecutor"] = None,
|
||||
context: Optional[contextvars.Context] = None,
|
||||
) -> Callable[_P, Coroutine[Any, Any, _R]]:
|
||||
...
|
||||
|
||||
|
||||
def sync_to_async(
|
||||
func: Optional[Callable[_P, _R]] = None,
|
||||
*,
|
||||
thread_sensitive: bool = True,
|
||||
executor: Optional["ThreadPoolExecutor"] = None,
|
||||
context: Optional[contextvars.Context] = None,
|
||||
) -> Union[
|
||||
Callable[[Callable[_P, _R]], Callable[_P, Coroutine[Any, Any, _R]]],
|
||||
Callable[_P, Coroutine[Any, Any, _R]],
|
||||
]:
|
||||
if func is None:
|
||||
return lambda f: SyncToAsync(
|
||||
f,
|
||||
thread_sensitive=thread_sensitive,
|
||||
executor=executor,
|
||||
context=context,
|
||||
)
|
||||
return SyncToAsync(
|
||||
func,
|
||||
thread_sensitive=thread_sensitive,
|
||||
executor=executor,
|
||||
context=context,
|
||||
)
|
||||
137
venv/lib/python3.10/site-packages/asgiref/testing.py
Normal file
137
venv/lib/python3.10/site-packages/asgiref/testing.py
Normal file
@@ -0,0 +1,137 @@
|
||||
import asyncio
|
||||
import contextvars
|
||||
import time
|
||||
|
||||
from .compatibility import guarantee_single_callable
|
||||
from .timeout import timeout as async_timeout
|
||||
|
||||
|
||||
class ApplicationCommunicator:
|
||||
"""
|
||||
Runs an ASGI application in a test mode, allowing sending of
|
||||
messages to it and retrieval of messages it sends.
|
||||
"""
|
||||
|
||||
def __init__(self, application, scope):
|
||||
self._future = None
|
||||
self.application = guarantee_single_callable(application)
|
||||
self.scope = scope
|
||||
self._input_queue = None
|
||||
self._output_queue = None
|
||||
|
||||
# For Python 3.9 we need to lazily bind the queues, on 3.10+ they bind the
|
||||
# event loop lazily.
|
||||
@property
|
||||
def input_queue(self):
|
||||
if self._input_queue is None:
|
||||
self._input_queue = asyncio.Queue()
|
||||
return self._input_queue
|
||||
|
||||
@property
|
||||
def output_queue(self):
|
||||
if self._output_queue is None:
|
||||
self._output_queue = asyncio.Queue()
|
||||
return self._output_queue
|
||||
|
||||
@property
|
||||
def future(self):
|
||||
if self._future is None:
|
||||
# Clear context - this ensures that context vars set in the testing scope
|
||||
# are not "leaked" into the application which would normally begin with
|
||||
# an empty context. In Python >= 3.11 this could also be written as:
|
||||
# asyncio.create_task(..., context=contextvars.Context())
|
||||
self._future = contextvars.Context().run(
|
||||
asyncio.create_task,
|
||||
self.application(
|
||||
self.scope, self.input_queue.get, self.output_queue.put
|
||||
),
|
||||
)
|
||||
return self._future
|
||||
|
||||
async def wait(self, timeout=1):
|
||||
"""
|
||||
Waits for the application to stop itself and returns any exceptions.
|
||||
"""
|
||||
try:
|
||||
async with async_timeout(timeout):
|
||||
try:
|
||||
await self.future
|
||||
self.future.result()
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
finally:
|
||||
if not self.future.done():
|
||||
self.future.cancel()
|
||||
try:
|
||||
await self.future
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
|
||||
def stop(self, exceptions=True):
|
||||
future = self._future
|
||||
if future is None:
|
||||
return
|
||||
|
||||
if not future.done():
|
||||
future.cancel()
|
||||
elif exceptions:
|
||||
# Give a chance to raise any exceptions
|
||||
future.result()
|
||||
|
||||
def __del__(self):
|
||||
# Clean up on deletion
|
||||
try:
|
||||
self.stop(exceptions=False)
|
||||
except RuntimeError:
|
||||
# Event loop already stopped
|
||||
pass
|
||||
|
||||
async def send_input(self, message):
|
||||
"""
|
||||
Sends a single message to the application
|
||||
"""
|
||||
# Make sure there's not an exception to raise from the task
|
||||
if self.future.done():
|
||||
self.future.result()
|
||||
|
||||
# Give it the message
|
||||
await self.input_queue.put(message)
|
||||
|
||||
async def receive_output(self, timeout=1):
|
||||
"""
|
||||
Receives a single message from the application, with optional timeout.
|
||||
"""
|
||||
# Make sure there's not an exception to raise from the task
|
||||
if self.future.done():
|
||||
self.future.result()
|
||||
# Wait and receive the message
|
||||
try:
|
||||
async with async_timeout(timeout):
|
||||
return await self.output_queue.get()
|
||||
except asyncio.TimeoutError as e:
|
||||
# See if we have another error to raise inside
|
||||
if self.future.done():
|
||||
self.future.result()
|
||||
else:
|
||||
self.future.cancel()
|
||||
try:
|
||||
await self.future
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
raise e
|
||||
|
||||
async def receive_nothing(self, timeout=0.1, interval=0.01):
|
||||
"""
|
||||
Checks that there is no message to receive in the given time.
|
||||
"""
|
||||
# Make sure there's not an exception to raise from the task
|
||||
if self.future.done():
|
||||
self.future.result()
|
||||
|
||||
# `interval` has precedence over `timeout`
|
||||
start = time.monotonic()
|
||||
while time.monotonic() - start < timeout:
|
||||
if not self.output_queue.empty():
|
||||
return False
|
||||
await asyncio.sleep(interval)
|
||||
return self.output_queue.empty()
|
||||
118
venv/lib/python3.10/site-packages/asgiref/timeout.py
Normal file
118
venv/lib/python3.10/site-packages/asgiref/timeout.py
Normal file
@@ -0,0 +1,118 @@
|
||||
# This code is originally sourced from the aio-libs project "async_timeout",
|
||||
# under the Apache 2.0 license. You may see the original project at
|
||||
# https://github.com/aio-libs/async-timeout
|
||||
|
||||
# It is vendored here to reduce chain-dependencies on this library, and
|
||||
# modified slightly to remove some features we don't use.
|
||||
|
||||
|
||||
import asyncio
|
||||
import warnings
|
||||
from types import TracebackType
|
||||
from typing import Any # noqa
|
||||
from typing import Optional, Type
|
||||
|
||||
|
||||
class timeout:
|
||||
"""timeout context manager.
|
||||
|
||||
Useful in cases when you want to apply timeout logic around block
|
||||
of code or in cases when asyncio.wait_for is not suitable. For example:
|
||||
|
||||
>>> with timeout(0.001):
|
||||
... async with aiohttp.get('https://github.com') as r:
|
||||
... await r.text()
|
||||
|
||||
|
||||
timeout - value in seconds or None to disable timeout logic
|
||||
loop - asyncio compatible event loop
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
timeout: Optional[float],
|
||||
*,
|
||||
loop: Optional[asyncio.AbstractEventLoop] = None,
|
||||
) -> None:
|
||||
self._timeout = timeout
|
||||
if loop is None:
|
||||
loop = asyncio.get_running_loop()
|
||||
else:
|
||||
warnings.warn(
|
||||
"""The loop argument to timeout() is deprecated.""", DeprecationWarning
|
||||
)
|
||||
self._loop = loop
|
||||
self._task = None # type: Optional[asyncio.Task[Any]]
|
||||
self._cancelled = False
|
||||
self._cancel_handler = None # type: Optional[asyncio.Handle]
|
||||
self._cancel_at = None # type: Optional[float]
|
||||
|
||||
def __enter__(self) -> "timeout":
|
||||
return self._do_enter()
|
||||
|
||||
def __exit__(
|
||||
self,
|
||||
exc_type: Type[BaseException],
|
||||
exc_val: BaseException,
|
||||
exc_tb: TracebackType,
|
||||
) -> Optional[bool]:
|
||||
self._do_exit(exc_type)
|
||||
return None
|
||||
|
||||
async def __aenter__(self) -> "timeout":
|
||||
return self._do_enter()
|
||||
|
||||
async def __aexit__(
|
||||
self,
|
||||
exc_type: Type[BaseException],
|
||||
exc_val: BaseException,
|
||||
exc_tb: TracebackType,
|
||||
) -> None:
|
||||
self._do_exit(exc_type)
|
||||
|
||||
@property
|
||||
def expired(self) -> bool:
|
||||
return self._cancelled
|
||||
|
||||
@property
|
||||
def remaining(self) -> Optional[float]:
|
||||
if self._cancel_at is not None:
|
||||
return max(self._cancel_at - self._loop.time(), 0.0)
|
||||
else:
|
||||
return None
|
||||
|
||||
def _do_enter(self) -> "timeout":
|
||||
# Support Tornado 5- without timeout
|
||||
# Details: https://github.com/python/asyncio/issues/392
|
||||
if self._timeout is None:
|
||||
return self
|
||||
|
||||
self._task = asyncio.current_task(self._loop)
|
||||
if self._task is None:
|
||||
raise RuntimeError(
|
||||
"Timeout context manager should be used " "inside a task"
|
||||
)
|
||||
|
||||
if self._timeout <= 0:
|
||||
self._loop.call_soon(self._cancel_task)
|
||||
return self
|
||||
|
||||
self._cancel_at = self._loop.time() + self._timeout
|
||||
self._cancel_handler = self._loop.call_at(self._cancel_at, self._cancel_task)
|
||||
return self
|
||||
|
||||
def _do_exit(self, exc_type: Type[BaseException]) -> None:
|
||||
if exc_type is asyncio.CancelledError and self._cancelled:
|
||||
self._cancel_handler = None
|
||||
self._task = None
|
||||
raise asyncio.TimeoutError
|
||||
if self._timeout is not None and self._cancel_handler is not None:
|
||||
self._cancel_handler.cancel()
|
||||
self._cancel_handler = None
|
||||
self._task = None
|
||||
return None
|
||||
|
||||
def _cancel_task(self) -> None:
|
||||
if self._task is not None:
|
||||
self._task.cancel()
|
||||
self._cancelled = True
|
||||
279
venv/lib/python3.10/site-packages/asgiref/typing.py
Normal file
279
venv/lib/python3.10/site-packages/asgiref/typing.py
Normal file
@@ -0,0 +1,279 @@
|
||||
import sys
|
||||
from typing import (
|
||||
Any,
|
||||
Awaitable,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterable,
|
||||
Literal,
|
||||
Optional,
|
||||
Protocol,
|
||||
Tuple,
|
||||
Type,
|
||||
TypedDict,
|
||||
Union,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import NotRequired
|
||||
else:
|
||||
from typing_extensions import NotRequired
|
||||
|
||||
__all__ = (
|
||||
"ASGIVersions",
|
||||
"HTTPScope",
|
||||
"WebSocketScope",
|
||||
"LifespanScope",
|
||||
"WWWScope",
|
||||
"Scope",
|
||||
"HTTPRequestEvent",
|
||||
"HTTPResponseStartEvent",
|
||||
"HTTPResponseBodyEvent",
|
||||
"HTTPResponseTrailersEvent",
|
||||
"HTTPResponsePathsendEvent",
|
||||
"HTTPServerPushEvent",
|
||||
"HTTPDisconnectEvent",
|
||||
"WebSocketConnectEvent",
|
||||
"WebSocketAcceptEvent",
|
||||
"WebSocketReceiveEvent",
|
||||
"WebSocketSendEvent",
|
||||
"WebSocketResponseStartEvent",
|
||||
"WebSocketResponseBodyEvent",
|
||||
"WebSocketDisconnectEvent",
|
||||
"WebSocketCloseEvent",
|
||||
"LifespanStartupEvent",
|
||||
"LifespanShutdownEvent",
|
||||
"LifespanStartupCompleteEvent",
|
||||
"LifespanStartupFailedEvent",
|
||||
"LifespanShutdownCompleteEvent",
|
||||
"LifespanShutdownFailedEvent",
|
||||
"ASGIReceiveEvent",
|
||||
"ASGISendEvent",
|
||||
"ASGIReceiveCallable",
|
||||
"ASGISendCallable",
|
||||
"ASGI2Protocol",
|
||||
"ASGI2Application",
|
||||
"ASGI3Application",
|
||||
"ASGIApplication",
|
||||
)
|
||||
|
||||
|
||||
class ASGIVersions(TypedDict):
|
||||
spec_version: str
|
||||
version: Union[Literal["2.0"], Literal["3.0"]]
|
||||
|
||||
|
||||
class HTTPScope(TypedDict):
|
||||
type: Literal["http"]
|
||||
asgi: ASGIVersions
|
||||
http_version: str
|
||||
method: str
|
||||
scheme: str
|
||||
path: str
|
||||
raw_path: bytes
|
||||
query_string: bytes
|
||||
root_path: str
|
||||
headers: Iterable[Tuple[bytes, bytes]]
|
||||
client: Optional[Tuple[str, int]]
|
||||
server: Optional[Tuple[str, Optional[int]]]
|
||||
state: NotRequired[Dict[str, Any]]
|
||||
extensions: Optional[Dict[str, Dict[object, object]]]
|
||||
|
||||
|
||||
class WebSocketScope(TypedDict):
|
||||
type: Literal["websocket"]
|
||||
asgi: ASGIVersions
|
||||
http_version: str
|
||||
scheme: str
|
||||
path: str
|
||||
raw_path: bytes
|
||||
query_string: bytes
|
||||
root_path: str
|
||||
headers: Iterable[Tuple[bytes, bytes]]
|
||||
client: Optional[Tuple[str, int]]
|
||||
server: Optional[Tuple[str, Optional[int]]]
|
||||
subprotocols: Iterable[str]
|
||||
state: NotRequired[Dict[str, Any]]
|
||||
extensions: Optional[Dict[str, Dict[object, object]]]
|
||||
|
||||
|
||||
class LifespanScope(TypedDict):
|
||||
type: Literal["lifespan"]
|
||||
asgi: ASGIVersions
|
||||
state: NotRequired[Dict[str, Any]]
|
||||
|
||||
|
||||
WWWScope = Union[HTTPScope, WebSocketScope]
|
||||
Scope = Union[HTTPScope, WebSocketScope, LifespanScope]
|
||||
|
||||
|
||||
class HTTPRequestEvent(TypedDict):
|
||||
type: Literal["http.request"]
|
||||
body: bytes
|
||||
more_body: bool
|
||||
|
||||
|
||||
class HTTPResponseDebugEvent(TypedDict):
|
||||
type: Literal["http.response.debug"]
|
||||
info: Dict[str, object]
|
||||
|
||||
|
||||
class HTTPResponseStartEvent(TypedDict):
|
||||
type: Literal["http.response.start"]
|
||||
status: int
|
||||
headers: Iterable[Tuple[bytes, bytes]]
|
||||
trailers: bool
|
||||
|
||||
|
||||
class HTTPResponseBodyEvent(TypedDict):
|
||||
type: Literal["http.response.body"]
|
||||
body: bytes
|
||||
more_body: bool
|
||||
|
||||
|
||||
class HTTPResponseTrailersEvent(TypedDict):
|
||||
type: Literal["http.response.trailers"]
|
||||
headers: Iterable[Tuple[bytes, bytes]]
|
||||
more_trailers: bool
|
||||
|
||||
|
||||
class HTTPResponsePathsendEvent(TypedDict):
|
||||
type: Literal["http.response.pathsend"]
|
||||
path: str
|
||||
|
||||
|
||||
class HTTPServerPushEvent(TypedDict):
|
||||
type: Literal["http.response.push"]
|
||||
path: str
|
||||
headers: Iterable[Tuple[bytes, bytes]]
|
||||
|
||||
|
||||
class HTTPDisconnectEvent(TypedDict):
|
||||
type: Literal["http.disconnect"]
|
||||
|
||||
|
||||
class WebSocketConnectEvent(TypedDict):
|
||||
type: Literal["websocket.connect"]
|
||||
|
||||
|
||||
class WebSocketAcceptEvent(TypedDict):
|
||||
type: Literal["websocket.accept"]
|
||||
subprotocol: Optional[str]
|
||||
headers: Iterable[Tuple[bytes, bytes]]
|
||||
|
||||
|
||||
class WebSocketReceiveEvent(TypedDict):
|
||||
type: Literal["websocket.receive"]
|
||||
bytes: Optional[bytes]
|
||||
text: Optional[str]
|
||||
|
||||
|
||||
class WebSocketSendEvent(TypedDict):
|
||||
type: Literal["websocket.send"]
|
||||
bytes: Optional[bytes]
|
||||
text: Optional[str]
|
||||
|
||||
|
||||
class WebSocketResponseStartEvent(TypedDict):
|
||||
type: Literal["websocket.http.response.start"]
|
||||
status: int
|
||||
headers: Iterable[Tuple[bytes, bytes]]
|
||||
|
||||
|
||||
class WebSocketResponseBodyEvent(TypedDict):
|
||||
type: Literal["websocket.http.response.body"]
|
||||
body: bytes
|
||||
more_body: bool
|
||||
|
||||
|
||||
class WebSocketDisconnectEvent(TypedDict):
|
||||
type: Literal["websocket.disconnect"]
|
||||
code: int
|
||||
reason: Optional[str]
|
||||
|
||||
|
||||
class WebSocketCloseEvent(TypedDict):
|
||||
type: Literal["websocket.close"]
|
||||
code: int
|
||||
reason: Optional[str]
|
||||
|
||||
|
||||
class LifespanStartupEvent(TypedDict):
|
||||
type: Literal["lifespan.startup"]
|
||||
|
||||
|
||||
class LifespanShutdownEvent(TypedDict):
|
||||
type: Literal["lifespan.shutdown"]
|
||||
|
||||
|
||||
class LifespanStartupCompleteEvent(TypedDict):
|
||||
type: Literal["lifespan.startup.complete"]
|
||||
|
||||
|
||||
class LifespanStartupFailedEvent(TypedDict):
|
||||
type: Literal["lifespan.startup.failed"]
|
||||
message: str
|
||||
|
||||
|
||||
class LifespanShutdownCompleteEvent(TypedDict):
|
||||
type: Literal["lifespan.shutdown.complete"]
|
||||
|
||||
|
||||
class LifespanShutdownFailedEvent(TypedDict):
|
||||
type: Literal["lifespan.shutdown.failed"]
|
||||
message: str
|
||||
|
||||
|
||||
ASGIReceiveEvent = Union[
|
||||
HTTPRequestEvent,
|
||||
HTTPDisconnectEvent,
|
||||
WebSocketConnectEvent,
|
||||
WebSocketReceiveEvent,
|
||||
WebSocketDisconnectEvent,
|
||||
LifespanStartupEvent,
|
||||
LifespanShutdownEvent,
|
||||
]
|
||||
|
||||
|
||||
ASGISendEvent = Union[
|
||||
HTTPResponseStartEvent,
|
||||
HTTPResponseBodyEvent,
|
||||
HTTPResponseTrailersEvent,
|
||||
HTTPServerPushEvent,
|
||||
HTTPDisconnectEvent,
|
||||
WebSocketAcceptEvent,
|
||||
WebSocketSendEvent,
|
||||
WebSocketResponseStartEvent,
|
||||
WebSocketResponseBodyEvent,
|
||||
WebSocketCloseEvent,
|
||||
LifespanStartupCompleteEvent,
|
||||
LifespanStartupFailedEvent,
|
||||
LifespanShutdownCompleteEvent,
|
||||
LifespanShutdownFailedEvent,
|
||||
]
|
||||
|
||||
|
||||
ASGIReceiveCallable = Callable[[], Awaitable[ASGIReceiveEvent]]
|
||||
ASGISendCallable = Callable[[ASGISendEvent], Awaitable[None]]
|
||||
|
||||
|
||||
class ASGI2Protocol(Protocol):
|
||||
def __init__(self, scope: Scope) -> None:
|
||||
...
|
||||
|
||||
async def __call__(
|
||||
self, receive: ASGIReceiveCallable, send: ASGISendCallable
|
||||
) -> None:
|
||||
...
|
||||
|
||||
|
||||
ASGI2Application = Type[ASGI2Protocol]
|
||||
ASGI3Application = Callable[
|
||||
[
|
||||
Scope,
|
||||
ASGIReceiveCallable,
|
||||
ASGISendCallable,
|
||||
],
|
||||
Awaitable[None],
|
||||
]
|
||||
ASGIApplication = Union[ASGI2Application, ASGI3Application]
|
||||
197
venv/lib/python3.10/site-packages/asgiref/wsgi.py
Normal file
197
venv/lib/python3.10/site-packages/asgiref/wsgi.py
Normal file
@@ -0,0 +1,197 @@
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from tempfile import SpooledTemporaryFile
|
||||
|
||||
from asgiref.sync import AsyncToSync, sync_to_async
|
||||
|
||||
|
||||
class WsgiToAsgi:
|
||||
"""
|
||||
Wraps a WSGI application to make it into an ASGI application.
|
||||
"""
|
||||
|
||||
def __init__(self, wsgi_application, duplicate_header_limit=100):
|
||||
self.wsgi_application = wsgi_application
|
||||
self.duplicate_header_limit = duplicate_header_limit
|
||||
|
||||
async def __call__(self, scope, receive, send):
|
||||
"""
|
||||
ASGI application instantiation point.
|
||||
We return a new WsgiToAsgiInstance here with the WSGI app
|
||||
and the scope, ready to respond when it is __call__ed.
|
||||
"""
|
||||
await WsgiToAsgiInstance(self.wsgi_application, self.duplicate_header_limit)(
|
||||
scope, receive, send
|
||||
)
|
||||
|
||||
|
||||
class WsgiToAsgiInstance:
|
||||
"""
|
||||
Per-socket instance of a wrapped WSGI application
|
||||
"""
|
||||
|
||||
def __init__(self, wsgi_application, duplicate_header_limit=100):
|
||||
self.wsgi_application = wsgi_application
|
||||
self.duplicate_header_limit = duplicate_header_limit
|
||||
self.response_started = False
|
||||
self.response_content_length = None
|
||||
|
||||
async def __call__(self, scope, receive, send):
|
||||
if scope["type"] != "http":
|
||||
raise ValueError("WSGI wrapper received a non-HTTP scope")
|
||||
self.scope = scope
|
||||
with SpooledTemporaryFile(max_size=65536) as body:
|
||||
# Alright, wait for the http.request messages
|
||||
while True:
|
||||
message = await receive()
|
||||
if message["type"] != "http.request":
|
||||
raise ValueError("WSGI wrapper received a non-HTTP-request message")
|
||||
body.write(message.get("body", b""))
|
||||
if not message.get("more_body"):
|
||||
break
|
||||
body.seek(0)
|
||||
# Wrap send so it can be called from the subthread
|
||||
self.sync_send = AsyncToSync(send)
|
||||
# Call the WSGI app
|
||||
await self.run_wsgi_app(body)
|
||||
|
||||
def build_environ(self, scope, body):
|
||||
"""
|
||||
Builds a scope and request body into a WSGI environ object.
|
||||
"""
|
||||
script_name = scope.get("root_path", "").encode("utf8").decode("latin1")
|
||||
path_info = scope["path"].encode("utf8").decode("latin1")
|
||||
if path_info.startswith(script_name):
|
||||
path_info = path_info[len(script_name) :]
|
||||
environ = {
|
||||
"REQUEST_METHOD": scope["method"],
|
||||
"SCRIPT_NAME": script_name,
|
||||
"PATH_INFO": path_info,
|
||||
"QUERY_STRING": scope["query_string"].decode("ascii"),
|
||||
"SERVER_PROTOCOL": "HTTP/%s" % scope["http_version"],
|
||||
"wsgi.version": (1, 0),
|
||||
"wsgi.url_scheme": scope.get("scheme", "http"),
|
||||
"wsgi.input": body,
|
||||
"wsgi.errors": sys.stderr,
|
||||
"wsgi.multithread": True,
|
||||
"wsgi.multiprocess": True,
|
||||
"wsgi.run_once": False,
|
||||
}
|
||||
# Get server name and port - required in WSGI, not in ASGI
|
||||
if "server" in scope:
|
||||
environ["SERVER_NAME"] = scope["server"][0]
|
||||
environ["SERVER_PORT"] = str(scope["server"][1])
|
||||
else:
|
||||
environ["SERVER_NAME"] = "localhost"
|
||||
environ["SERVER_PORT"] = "80"
|
||||
|
||||
if scope.get("client") is not None:
|
||||
environ["REMOTE_ADDR"] = scope["client"][0]
|
||||
|
||||
# Go through headers and make them into environ entries
|
||||
_headers = defaultdict(list)
|
||||
for name, value in self.scope.get("headers", []):
|
||||
name = name.decode("latin1")
|
||||
if name == "content-length":
|
||||
corrected_name = "CONTENT_LENGTH"
|
||||
elif name == "content-type":
|
||||
corrected_name = "CONTENT_TYPE"
|
||||
else:
|
||||
corrected_name = "HTTP_%s" % name.upper().replace("-", "_")
|
||||
# HTTPbis say only ASCII chars are allowed in headers, but we latin1 just in case
|
||||
value = value.decode("latin1")
|
||||
if (
|
||||
self.duplicate_header_limit
|
||||
and len(_headers[corrected_name]) >= self.duplicate_header_limit
|
||||
):
|
||||
raise ValueError(
|
||||
f"Too many duplicate headers: {corrected_name} exceeds limit of"
|
||||
f"{self.duplicate_header_limit}"
|
||||
)
|
||||
_headers[corrected_name].append(value)
|
||||
for name, values in _headers.items():
|
||||
environ[name] = ",".join(values)
|
||||
return environ
|
||||
|
||||
def start_response(self, status, response_headers, exc_info=None):
|
||||
"""
|
||||
WSGI start_response callable.
|
||||
"""
|
||||
# Don't allow re-calling once response has begun
|
||||
if self.response_started:
|
||||
raise exc_info[1].with_traceback(exc_info[2])
|
||||
# Don't allow re-calling without exc_info
|
||||
if hasattr(self, "response_start") and exc_info is None:
|
||||
raise ValueError(
|
||||
"You cannot call start_response a second time without exc_info"
|
||||
)
|
||||
# Extract status code
|
||||
status_code, _ = status.split(" ", 1)
|
||||
status_code = int(status_code)
|
||||
# Extract headers
|
||||
headers = [
|
||||
(name.lower().encode("ascii"), value.encode("ascii"))
|
||||
for name, value in response_headers
|
||||
]
|
||||
# Extract content-length
|
||||
self.response_content_length = None
|
||||
for name, value in response_headers:
|
||||
if name.lower() == "content-length":
|
||||
self.response_content_length = int(value)
|
||||
# Build and send response start message.
|
||||
self.response_start = {
|
||||
"type": "http.response.start",
|
||||
"status": status_code,
|
||||
"headers": headers,
|
||||
}
|
||||
|
||||
@sync_to_async
|
||||
def run_wsgi_app(self, body):
|
||||
"""
|
||||
Called in a subthread to run the WSGI app. We encapsulate like
|
||||
this so that the start_response callable is called in the same thread.
|
||||
"""
|
||||
# Translate the scope and incoming request body into a WSGI environ
|
||||
try:
|
||||
environ = self.build_environ(self.scope, body)
|
||||
except ValueError:
|
||||
# Return 400 Bad Request if header limit exceeded
|
||||
self.sync_send(
|
||||
{
|
||||
"type": "http.response.start",
|
||||
"status": 400,
|
||||
"headers": [(b"content-type", b"text/plain")],
|
||||
}
|
||||
)
|
||||
self.sync_send(
|
||||
{
|
||||
"type": "http.response.body",
|
||||
"body": b"Bad Request: Too many duplicate headers",
|
||||
}
|
||||
)
|
||||
return
|
||||
# Run the WSGI app
|
||||
bytes_sent = 0
|
||||
for output in self.wsgi_application(environ, self.start_response):
|
||||
# If this is the first response, include the response headers
|
||||
if not self.response_started:
|
||||
self.response_started = True
|
||||
self.sync_send(self.response_start)
|
||||
# If the application supplies a Content-Length header
|
||||
if self.response_content_length is not None:
|
||||
# The server should not transmit more bytes to the client than the header allows
|
||||
bytes_allowed = self.response_content_length - bytes_sent
|
||||
if len(output) > bytes_allowed:
|
||||
output = output[:bytes_allowed]
|
||||
self.sync_send(
|
||||
{"type": "http.response.body", "body": output, "more_body": True}
|
||||
)
|
||||
bytes_sent += len(output)
|
||||
# The server should stop iterating over the response when enough data has been sent
|
||||
if bytes_sent == self.response_content_length:
|
||||
break
|
||||
# Close connection
|
||||
if not self.response_started:
|
||||
self.response_started = True
|
||||
self.sync_send(self.response_start)
|
||||
self.sync_send({"type": "http.response.body"})
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,343 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: bcrypt
|
||||
Version: 5.0.0
|
||||
Summary: Modern password hashing for your software and your servers
|
||||
Author-email: The Python Cryptographic Authority developers <cryptography-dev@python.org>
|
||||
License: Apache-2.0
|
||||
Project-URL: homepage, https://github.com/pyca/bcrypt/
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: License :: OSI Approved :: Apache Software License
|
||||
Classifier: Programming Language :: Python :: Implementation :: CPython
|
||||
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3 :: Only
|
||||
Classifier: Programming Language :: Python :: 3.8
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
Classifier: Programming Language :: Python :: 3.12
|
||||
Classifier: Programming Language :: Python :: 3.13
|
||||
Classifier: Programming Language :: Python :: 3.14
|
||||
Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
|
||||
Requires-Python: >=3.8
|
||||
Description-Content-Type: text/x-rst
|
||||
License-File: LICENSE
|
||||
Provides-Extra: tests
|
||||
Requires-Dist: pytest!=3.3.0,>=3.2.1; extra == "tests"
|
||||
Provides-Extra: typecheck
|
||||
Requires-Dist: mypy; extra == "typecheck"
|
||||
Dynamic: license-file
|
||||
|
||||
bcrypt
|
||||
======
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/bcrypt.svg
|
||||
:target: https://pypi.org/project/bcrypt/
|
||||
:alt: Latest Version
|
||||
|
||||
.. image:: https://github.com/pyca/bcrypt/workflows/CI/badge.svg?branch=main
|
||||
:target: https://github.com/pyca/bcrypt/actions?query=workflow%3ACI+branch%3Amain
|
||||
|
||||
Acceptable password hashing for your software and your servers (but you should
|
||||
really use argon2id or scrypt)
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
To install bcrypt, simply:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ pip install bcrypt
|
||||
|
||||
Note that bcrypt should build very easily on Linux provided you have a C
|
||||
compiler and a Rust compiler (the minimum supported Rust version is 1.56.0).
|
||||
|
||||
For Debian and Ubuntu, the following command will ensure that the required dependencies are installed:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ sudo apt-get install build-essential cargo
|
||||
|
||||
For Fedora and RHEL-derivatives, the following command will ensure that the required dependencies are installed:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ sudo yum install gcc cargo
|
||||
|
||||
For Alpine, the following command will ensure that the required dependencies are installed:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ apk add --update musl-dev gcc cargo
|
||||
|
||||
|
||||
Alternatives
|
||||
============
|
||||
|
||||
While bcrypt remains an acceptable choice for password storage, depending on your specific use case you may also want to consider using scrypt (either via `standard library`_ or `cryptography`_) or argon2id via `argon2_cffi`_.
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
||||
* Bumped MSRV to 1.74.
|
||||
* Added support for Python 3.14 and free-threaded Python 3.14.
|
||||
* Added support for Windows on ARM.
|
||||
* Passing ``hashpw`` a password longer than 72 bytes now raises a
|
||||
``ValueError``. Previously the password was silently truncated, following the
|
||||
behavior of the original OpenBSD ``bcrypt`` implementation.
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* Dropped support for Python 3.7.
|
||||
* We now support free-threaded Python 3.13.
|
||||
* We now support PyPy 3.11.
|
||||
* We now publish wheels for free-threaded Python 3.13, for PyPy 3.11 on
|
||||
``manylinux``, and for ARMv7l on ``manylinux``.
|
||||
|
||||
4.2.1
|
||||
-----
|
||||
|
||||
* Bump Rust dependency versions - this should resolve crashes on Python 3.13
|
||||
free-threaded builds.
|
||||
* We no longer build ``manylinux`` wheels for PyPy 3.9.
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* Bump Rust dependency versions
|
||||
* Removed the ``BCRYPT_ALLOW_RUST_163`` environment variable.
|
||||
|
||||
4.1.3
|
||||
-----
|
||||
|
||||
* Bump Rust dependency versions
|
||||
|
||||
4.1.2
|
||||
-----
|
||||
|
||||
* Publish both ``py37`` and ``py39`` wheels. This should resolve some errors
|
||||
relating to initializing a module multiple times per process.
|
||||
|
||||
4.1.1
|
||||
-----
|
||||
|
||||
* Fixed the type signature on the ``kdf`` method.
|
||||
* Fixed packaging bug on Windows.
|
||||
* Fixed incompatibility with passlib package detection assumptions.
|
||||
|
||||
4.1.0
|
||||
-----
|
||||
|
||||
* Dropped support for Python 3.6.
|
||||
* Bumped MSRV to 1.64. (Note: Rust 1.63 can be used by setting the ``BCRYPT_ALLOW_RUST_163`` environment variable)
|
||||
|
||||
4.0.1
|
||||
-----
|
||||
|
||||
* We now build PyPy ``manylinux`` wheels.
|
||||
* Fixed a bug where passing an invalid ``salt`` to ``checkpw`` could result in
|
||||
a ``pyo3_runtime.PanicException``. It now correctly raises a ``ValueError``.
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* ``bcrypt`` is now implemented in Rust. Users building from source will need
|
||||
to have a Rust compiler available. Nothing will change for users downloading
|
||||
wheels.
|
||||
* We no longer ship ``manylinux2010`` wheels. Users should upgrade to the latest
|
||||
``pip`` to ensure this doesn’t cause issues downloading wheels on their
|
||||
platform. We now ship ``manylinux_2_28`` wheels for users on new enough platforms.
|
||||
* ``NUL`` bytes are now allowed in inputs.
|
||||
|
||||
|
||||
3.2.2
|
||||
-----
|
||||
|
||||
* Fixed packaging of ``py.typed`` files in wheels so that ``mypy`` works.
|
||||
|
||||
3.2.1
|
||||
-----
|
||||
|
||||
* Added support for compilation on z/OS
|
||||
* The next release of ``bcrypt`` with be 4.0 and it will require Rust at
|
||||
compile time, for users building from source. There will be no additional
|
||||
requirement for users who are installing from wheels. Users on most
|
||||
platforms will be able to obtain a wheel by making sure they have an up to
|
||||
date ``pip``. The minimum supported Rust version will be 1.56.0.
|
||||
* This will be the final release for which we ship ``manylinux2010`` wheels.
|
||||
Going forward the minimum supported manylinux ABI for our wheels will be
|
||||
``manylinux2014``. The vast majority of users will continue to receive
|
||||
``manylinux`` wheels provided they have an up to date ``pip``.
|
||||
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
* Added typehints for library functions.
|
||||
* Dropped support for Python versions less than 3.6 (2.7, 3.4, 3.5).
|
||||
* Shipped ``abi3`` Windows wheels (requires pip >= 20).
|
||||
|
||||
3.1.7
|
||||
-----
|
||||
|
||||
* Set a ``setuptools`` lower bound for PEP517 wheel building.
|
||||
* We no longer distribute 32-bit ``manylinux1`` wheels. Continuing to produce
|
||||
them was a maintenance burden.
|
||||
|
||||
3.1.6
|
||||
-----
|
||||
|
||||
* Added support for compilation on Haiku.
|
||||
|
||||
3.1.5
|
||||
-----
|
||||
|
||||
* Added support for compilation on AIX.
|
||||
* Dropped Python 2.6 and 3.3 support.
|
||||
* Switched to using ``abi3`` wheels for Python 3. If you are not getting a
|
||||
wheel on a compatible platform please upgrade your ``pip`` version.
|
||||
|
||||
3.1.4
|
||||
-----
|
||||
|
||||
* Fixed compilation with mingw and on illumos.
|
||||
|
||||
3.1.3
|
||||
-----
|
||||
* Fixed a compilation issue on Solaris.
|
||||
* Added a warning when using too few rounds with ``kdf``.
|
||||
|
||||
3.1.2
|
||||
-----
|
||||
* Fixed a compile issue affecting big endian platforms.
|
||||
* Fixed invalid escape sequence warnings on Python 3.6.
|
||||
* Fixed building in non-UTF8 environments on Python 2.
|
||||
|
||||
3.1.1
|
||||
-----
|
||||
* Resolved a ``UserWarning`` when used with ``cffi`` 1.8.3.
|
||||
|
||||
3.1.0
|
||||
-----
|
||||
* Added support for ``checkpw``, a convenience method for verifying a password.
|
||||
* Ensure that you get a ``$2y$`` hash when you input a ``$2y$`` salt.
|
||||
* Fixed a regression where ``$2a`` hashes were vulnerable to a wraparound bug.
|
||||
* Fixed compilation under Alpine Linux.
|
||||
|
||||
3.0.0
|
||||
-----
|
||||
* Switched the C backend to code obtained from the OpenBSD project rather than
|
||||
openwall.
|
||||
* Added support for ``bcrypt_pbkdf`` via the ``kdf`` function.
|
||||
|
||||
2.0.0
|
||||
-----
|
||||
* Added support for an adjustible prefix when calling ``gensalt``.
|
||||
* Switched to CFFI 1.0+
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Password Hashing
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Hashing and then later checking that a password matches the previous hashed
|
||||
password is very simple:
|
||||
|
||||
.. code:: pycon
|
||||
|
||||
>>> import bcrypt
|
||||
>>> password = b"super secret password"
|
||||
>>> # Hash a password for the first time, with a randomly-generated salt
|
||||
>>> hashed = bcrypt.hashpw(password, bcrypt.gensalt())
|
||||
>>> # Check that an unhashed password matches one that has previously been
|
||||
>>> # hashed
|
||||
>>> if bcrypt.checkpw(password, hashed):
|
||||
... print("It Matches!")
|
||||
... else:
|
||||
... print("It Does not Match :(")
|
||||
|
||||
KDF
|
||||
~~~
|
||||
|
||||
As of 3.0.0 ``bcrypt`` now offers a ``kdf`` function which does ``bcrypt_pbkdf``.
|
||||
This KDF is used in OpenSSH's newer encrypted private key format.
|
||||
|
||||
.. code:: pycon
|
||||
|
||||
>>> import bcrypt
|
||||
>>> key = bcrypt.kdf(
|
||||
... password=b'password',
|
||||
... salt=b'salt',
|
||||
... desired_key_bytes=32,
|
||||
... rounds=100)
|
||||
|
||||
|
||||
Adjustable Work Factor
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
One of bcrypt's features is an adjustable logarithmic work factor. To adjust
|
||||
the work factor merely pass the desired number of rounds to
|
||||
``bcrypt.gensalt(rounds=12)`` which defaults to 12):
|
||||
|
||||
.. code:: pycon
|
||||
|
||||
>>> import bcrypt
|
||||
>>> password = b"super secret password"
|
||||
>>> # Hash a password for the first time, with a certain number of rounds
|
||||
>>> hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
|
||||
>>> # Check that a unhashed password matches one that has previously been
|
||||
>>> # hashed
|
||||
>>> if bcrypt.checkpw(password, hashed):
|
||||
... print("It Matches!")
|
||||
... else:
|
||||
... print("It Does not Match :(")
|
||||
|
||||
|
||||
Adjustable Prefix
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Another one of bcrypt's features is an adjustable prefix to let you define what
|
||||
libraries you'll remain compatible with. To adjust this, pass either ``2a`` or
|
||||
``2b`` (the default) to ``bcrypt.gensalt(prefix=b"2b")`` as a bytes object.
|
||||
|
||||
As of 3.0.0 the ``$2y$`` prefix is still supported in ``hashpw`` but deprecated.
|
||||
|
||||
Maximum Password Length
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The bcrypt algorithm only handles passwords up to 72 characters, any characters
|
||||
beyond that are ignored. To work around this, a common approach is to hash a
|
||||
password with a cryptographic hash (such as ``sha256``) and then base64
|
||||
encode it to prevent NULL byte problems before hashing the result with
|
||||
``bcrypt``:
|
||||
|
||||
.. code:: pycon
|
||||
|
||||
>>> password = b"an incredibly long password" * 10
|
||||
>>> hashed = bcrypt.hashpw(
|
||||
... base64.b64encode(hashlib.sha256(password).digest()),
|
||||
... bcrypt.gensalt()
|
||||
... )
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
This library should be compatible with py-bcrypt and it will run on Python
|
||||
3.8+ (including free-threaded builds), and PyPy 3.
|
||||
|
||||
Security
|
||||
--------
|
||||
|
||||
``bcrypt`` follows the `same security policy as cryptography`_, if you
|
||||
identify a vulnerability, we ask you to contact us privately.
|
||||
|
||||
.. _`same security policy as cryptography`: https://cryptography.io/en/latest/security.html
|
||||
.. _`standard library`: https://docs.python.org/3/library/hashlib.html#hashlib.scrypt
|
||||
.. _`argon2_cffi`: https://argon2-cffi.readthedocs.io
|
||||
.. _`cryptography`: https://cryptography.io/en/latest/hazmat/primitives/key-derivation-functions/#cryptography.hazmat.primitives.kdf.scrypt.Scrypt
|
||||
@@ -0,0 +1,12 @@
|
||||
bcrypt-5.0.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
bcrypt-5.0.0.dist-info/METADATA,sha256=yV1BfLlI6udlVy23eNbzDa62DSEbUrlWvlLBCI6UAdI,10524
|
||||
bcrypt-5.0.0.dist-info/RECORD,,
|
||||
bcrypt-5.0.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
bcrypt-5.0.0.dist-info/WHEEL,sha256=WieEZvWpc0Erab6-NfTu9412g-GcE58js6gvBn3Q7B4,111
|
||||
bcrypt-5.0.0.dist-info/licenses/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
|
||||
bcrypt-5.0.0.dist-info/top_level.txt,sha256=BkR_qBzDbSuycMzHWE1vzXrfYecAzUVmQs6G2CukqNI,7
|
||||
bcrypt/__init__.py,sha256=cv-NupIX6P7o6A4PK_F0ur6IZoDr3GnvyzFO9k16wKQ,1000
|
||||
bcrypt/__init__.pyi,sha256=ITUCB9mPVU8sKUbJQMDUH5YfQXZb1O55F9qvKZR_o8I,333
|
||||
bcrypt/__pycache__/__init__.cpython-310.pyc,,
|
||||
bcrypt/_bcrypt.abi3.so,sha256=oFwJu4Gq44FqJDttx_oWpypfuUQ30BkCWzD2FhojdYw,631768
|
||||
bcrypt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: setuptools (80.9.0)
|
||||
Root-Is-Purelib: false
|
||||
Tag: cp39-abi3-manylinux_2_34_x86_64
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1 @@
|
||||
bcrypt
|
||||
43
venv/lib/python3.10/site-packages/bcrypt/__init__.py
Normal file
43
venv/lib/python3.10/site-packages/bcrypt/__init__.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ._bcrypt import (
|
||||
__author__,
|
||||
__copyright__,
|
||||
__email__,
|
||||
__license__,
|
||||
__summary__,
|
||||
__title__,
|
||||
__uri__,
|
||||
checkpw,
|
||||
gensalt,
|
||||
hashpw,
|
||||
kdf,
|
||||
)
|
||||
from ._bcrypt import (
|
||||
__version_ex__ as __version__,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"__author__",
|
||||
"__copyright__",
|
||||
"__email__",
|
||||
"__license__",
|
||||
"__summary__",
|
||||
"__title__",
|
||||
"__uri__",
|
||||
"__version__",
|
||||
"checkpw",
|
||||
"gensalt",
|
||||
"hashpw",
|
||||
"kdf",
|
||||
]
|
||||
10
venv/lib/python3.10/site-packages/bcrypt/__init__.pyi
Normal file
10
venv/lib/python3.10/site-packages/bcrypt/__init__.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
def gensalt(rounds: int = 12, prefix: bytes = b"2b") -> bytes: ...
|
||||
def hashpw(password: bytes, salt: bytes) -> bytes: ...
|
||||
def checkpw(password: bytes, hashed_password: bytes) -> bool: ...
|
||||
def kdf(
|
||||
password: bytes,
|
||||
salt: bytes,
|
||||
desired_key_bytes: int,
|
||||
rounds: int,
|
||||
ignore_few_rounds: bool = False,
|
||||
) -> bytes: ...
|
||||
Binary file not shown.
BIN
venv/lib/python3.10/site-packages/bcrypt/_bcrypt.abi3.so
Executable file
BIN
venv/lib/python3.10/site-packages/bcrypt/_bcrypt.abi3.so
Executable file
Binary file not shown.
0
venv/lib/python3.10/site-packages/bcrypt/py.typed
Normal file
0
venv/lib/python3.10/site-packages/bcrypt/py.typed
Normal file
@@ -0,0 +1 @@
|
||||
import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'stdlib') == 'local'; enabled and __import__('_distutils_hack').add_shim();
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,99 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: Django
|
||||
Version: 5.2.16
|
||||
Summary: A high-level Python web framework that encourages rapid development and clean, pragmatic design.
|
||||
Author-email: Django Software Foundation <foundation@djangoproject.com>
|
||||
License-Expression: BSD-3-Clause
|
||||
Project-URL: Homepage, https://www.djangoproject.com/
|
||||
Project-URL: Documentation, https://docs.djangoproject.com/
|
||||
Project-URL: Release notes, https://docs.djangoproject.com/en/stable/releases/
|
||||
Project-URL: Funding, https://www.djangoproject.com/fundraising/
|
||||
Project-URL: Source, https://github.com/django/django
|
||||
Project-URL: Tracker, https://code.djangoproject.com/
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Framework :: Django
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3 :: Only
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
Classifier: Programming Language :: Python :: 3.12
|
||||
Classifier: Programming Language :: Python :: 3.13
|
||||
Classifier: Programming Language :: Python :: 3.14
|
||||
Classifier: Topic :: Internet :: WWW/HTTP
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
|
||||
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Requires-Python: >=3.10
|
||||
Description-Content-Type: text/x-rst
|
||||
License-File: LICENSE
|
||||
License-File: LICENSE.python
|
||||
License-File: AUTHORS
|
||||
Requires-Dist: asgiref>=3.8.1
|
||||
Requires-Dist: sqlparse>=0.3.1
|
||||
Requires-Dist: tzdata; sys_platform == "win32"
|
||||
Provides-Extra: argon2
|
||||
Requires-Dist: argon2-cffi>=19.1.0; extra == "argon2"
|
||||
Provides-Extra: bcrypt
|
||||
Requires-Dist: bcrypt; extra == "bcrypt"
|
||||
Dynamic: license-file
|
||||
|
||||
======
|
||||
Django
|
||||
======
|
||||
|
||||
Django is a high-level Python web framework that encourages rapid development
|
||||
and clean, pragmatic design. Thanks for checking it out.
|
||||
|
||||
All documentation is in the "``docs``" directory and online at
|
||||
https://docs.djangoproject.com/en/stable/. If you're just getting started,
|
||||
here's how we recommend you read the docs:
|
||||
|
||||
* First, read ``docs/intro/install.txt`` for instructions on installing Django.
|
||||
|
||||
* Next, work through the tutorials in order (``docs/intro/tutorial01.txt``,
|
||||
``docs/intro/tutorial02.txt``, etc.).
|
||||
|
||||
* If you want to set up an actual deployment server, read
|
||||
``docs/howto/deployment/index.txt`` for instructions.
|
||||
|
||||
* You'll probably want to read through the topical guides (in ``docs/topics``)
|
||||
next; from there you can jump to the HOWTOs (in ``docs/howto``) for specific
|
||||
problems, and check out the reference (``docs/ref``) for gory details.
|
||||
|
||||
* See ``docs/README`` for instructions on building an HTML version of the docs.
|
||||
|
||||
Docs are updated rigorously. If you find any problems in the docs, or think
|
||||
they should be clarified in any way, please take 30 seconds to fill out a
|
||||
ticket here: https://code.djangoproject.com/newticket
|
||||
|
||||
To get more help:
|
||||
|
||||
* Join the ``#django`` channel on ``irc.libera.chat``. Lots of helpful people
|
||||
hang out there. `Webchat is available <https://web.libera.chat/#django>`_.
|
||||
|
||||
* Join the `Django Discord community <https://chat.djangoproject.com>`_.
|
||||
|
||||
* Join the community on the `Django Forum <https://forum.djangoproject.com/>`_.
|
||||
|
||||
To contribute to Django:
|
||||
|
||||
* Check out https://docs.djangoproject.com/en/dev/internals/contributing/ for
|
||||
information about getting involved.
|
||||
|
||||
To run Django's test suite:
|
||||
|
||||
* Follow the instructions in the "Unit tests" section of
|
||||
``docs/internals/contributing/writing-code/unit-tests.txt``, published online at
|
||||
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests
|
||||
|
||||
Supporting the Development of Django
|
||||
====================================
|
||||
|
||||
Django's development depends on your contributions.
|
||||
|
||||
If you depend on Django, remember to support the Django Software Foundation: https://www.djangoproject.com/fundraising/
|
||||
4554
venv/lib/python3.10/site-packages/django-5.2.16.dist-info/RECORD
Normal file
4554
venv/lib/python3.10/site-packages/django-5.2.16.dist-info/RECORD
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: setuptools (83.0.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[console_scripts]
|
||||
django-admin = django.core.management:execute_from_command_line
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
Copyright (c) Django Software Foundation and individual contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Django nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,288 @@
|
||||
Django is licensed under the three-clause BSD license; see the file
|
||||
LICENSE for details.
|
||||
|
||||
Django includes code from the Python standard library, which is licensed under
|
||||
the Python license, a permissive open source license. The copyright and license
|
||||
is included below for compliance with Python's terms.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2001-present Python Software Foundation; All Rights Reserved
|
||||
|
||||
A. HISTORY OF THE SOFTWARE
|
||||
==========================
|
||||
|
||||
Python was created in the early 1990s by Guido van Rossum at Stichting
|
||||
Mathematisch Centrum (CWI, see https://www.cwi.nl) in the Netherlands
|
||||
as a successor of a language called ABC. Guido remains Python's
|
||||
principal author, although it includes many contributions from others.
|
||||
|
||||
In 1995, Guido continued his work on Python at the Corporation for
|
||||
National Research Initiatives (CNRI, see https://www.cnri.reston.va.us)
|
||||
in Reston, Virginia where he released several versions of the
|
||||
software.
|
||||
|
||||
In May 2000, Guido and the Python core development team moved to
|
||||
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
|
||||
year, the PythonLabs team moved to Digital Creations, which became
|
||||
Zope Corporation. In 2001, the Python Software Foundation (PSF, see
|
||||
https://www.python.org/psf/) was formed, a non-profit organization
|
||||
created specifically to own Python-related Intellectual Property.
|
||||
Zope Corporation was a sponsoring member of the PSF.
|
||||
|
||||
All Python releases are Open Source (see https://opensource.org for
|
||||
the Open Source Definition). Historically, most, but not all, Python
|
||||
releases have also been GPL-compatible; the table below summarizes
|
||||
the various releases.
|
||||
|
||||
Release Derived Year Owner GPL-
|
||||
from compatible? (1)
|
||||
|
||||
0.9.0 thru 1.2 1991-1995 CWI yes
|
||||
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
|
||||
1.6 1.5.2 2000 CNRI no
|
||||
2.0 1.6 2000 BeOpen.com no
|
||||
1.6.1 1.6 2001 CNRI yes (2)
|
||||
2.1 2.0+1.6.1 2001 PSF no
|
||||
2.0.1 2.0+1.6.1 2001 PSF yes
|
||||
2.1.1 2.1+2.0.1 2001 PSF yes
|
||||
2.1.2 2.1.1 2002 PSF yes
|
||||
2.1.3 2.1.2 2002 PSF yes
|
||||
2.2 and above 2.1.1 2001-now PSF yes
|
||||
|
||||
Footnotes:
|
||||
|
||||
(1) GPL-compatible doesn't mean that we're distributing Python under
|
||||
the GPL. All Python licenses, unlike the GPL, let you distribute
|
||||
a modified version without making your changes open source. The
|
||||
GPL-compatible licenses make it possible to combine Python with
|
||||
other software that is released under the GPL; the others don't.
|
||||
|
||||
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
|
||||
because its license has a choice of law clause. According to
|
||||
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
|
||||
is "not incompatible" with the GPL.
|
||||
|
||||
Thanks to the many outside volunteers who have worked under Guido's
|
||||
direction to make these releases possible.
|
||||
|
||||
|
||||
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
|
||||
===============================================================
|
||||
|
||||
Python software and documentation are licensed under the
|
||||
Python Software Foundation License Version 2.
|
||||
|
||||
Starting with Python 3.8.6, examples, recipes, and other code in
|
||||
the documentation are dual licensed under the PSF License Version 2
|
||||
and the Zero-Clause BSD license.
|
||||
|
||||
Some software incorporated into Python is under different licenses.
|
||||
The licenses are listed with code falling under that license.
|
||||
|
||||
|
||||
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
--------------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
otherwise using this software ("Python") in source or binary form and
|
||||
its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
distribute, and otherwise use Python alone or in any derivative version,
|
||||
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
i.e., "Copyright (c) 2001 Python Software Foundation; All Rights Reserved"
|
||||
are retained in Python alone or in any derivative version prepared by Licensee.
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python.
|
||||
|
||||
4. PSF is making Python available to Licensee on an "AS IS"
|
||||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. Nothing in this License Agreement shall be deemed to create any
|
||||
relationship of agency, partnership, or joint venture between PSF and
|
||||
Licensee. This License Agreement does not grant permission to use PSF
|
||||
trademarks or trade name in a trademark sense to endorse or promote
|
||||
products or services of Licensee, or any third party.
|
||||
|
||||
8. By copying, installing or otherwise using Python, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
|
||||
|
||||
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
|
||||
-------------------------------------------
|
||||
|
||||
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
|
||||
|
||||
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
|
||||
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
|
||||
Individual or Organization ("Licensee") accessing and otherwise using
|
||||
this software in source or binary form and its associated
|
||||
documentation ("the Software").
|
||||
|
||||
2. Subject to the terms and conditions of this BeOpen Python License
|
||||
Agreement, BeOpen hereby grants Licensee a non-exclusive,
|
||||
royalty-free, world-wide license to reproduce, analyze, test, perform
|
||||
and/or display publicly, prepare derivative works, distribute, and
|
||||
otherwise use the Software alone or in any derivative version,
|
||||
provided, however, that the BeOpen Python License is retained in the
|
||||
Software, alone or in any derivative version prepared by Licensee.
|
||||
|
||||
3. BeOpen is making the Software available to Licensee on an "AS IS"
|
||||
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
|
||||
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
|
||||
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
|
||||
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
5. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
6. This License Agreement shall be governed by and interpreted in all
|
||||
respects by the law of the State of California, excluding conflict of
|
||||
law provisions. Nothing in this License Agreement shall be deemed to
|
||||
create any relationship of agency, partnership, or joint venture
|
||||
between BeOpen and Licensee. This License Agreement does not grant
|
||||
permission to use BeOpen trademarks or trade names in a trademark
|
||||
sense to endorse or promote products or services of Licensee, or any
|
||||
third party. As an exception, the "BeOpen Python" logos available at
|
||||
http://www.pythonlabs.com/logos.html may be used according to the
|
||||
permissions granted on that web page.
|
||||
|
||||
7. By copying, installing or otherwise using the software, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
|
||||
|
||||
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
|
||||
---------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Corporation for National
|
||||
Research Initiatives, having an office at 1895 Preston White Drive,
|
||||
Reston, VA 20191 ("CNRI"), and the Individual or Organization
|
||||
("Licensee") accessing and otherwise using Python 1.6.1 software in
|
||||
source or binary form and its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, CNRI
|
||||
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
||||
license to reproduce, analyze, test, perform and/or display publicly,
|
||||
prepare derivative works, distribute, and otherwise use Python 1.6.1
|
||||
alone or in any derivative version, provided, however, that CNRI's
|
||||
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
|
||||
1995-2001 Corporation for National Research Initiatives; All Rights
|
||||
Reserved" are retained in Python 1.6.1 alone or in any derivative
|
||||
version prepared by Licensee. Alternately, in lieu of CNRI's License
|
||||
Agreement, Licensee may substitute the following text (omitting the
|
||||
quotes): "Python 1.6.1 is made available subject to the terms and
|
||||
conditions in CNRI's License Agreement. This Agreement together with
|
||||
Python 1.6.1 may be located on the internet using the following
|
||||
unique, persistent identifier (known as a handle): 1895.22/1013. This
|
||||
Agreement may also be obtained from a proxy server on the internet
|
||||
using the following URL: http://hdl.handle.net/1895.22/1013".
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python 1.6.1 or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python 1.6.1.
|
||||
|
||||
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
|
||||
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. This License Agreement shall be governed by the federal
|
||||
intellectual property law of the United States, including without
|
||||
limitation the federal copyright law, and, to the extent such
|
||||
U.S. federal law does not apply, by the law of the Commonwealth of
|
||||
Virginia, excluding Virginia's conflict of law provisions.
|
||||
Notwithstanding the foregoing, with regard to derivative works based
|
||||
on Python 1.6.1 that incorporate non-separable material that was
|
||||
previously distributed under the GNU General Public License (GPL), the
|
||||
law of the Commonwealth of Virginia shall govern this License
|
||||
Agreement only as to issues arising under or with respect to
|
||||
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
|
||||
License Agreement shall be deemed to create any relationship of
|
||||
agency, partnership, or joint venture between CNRI and Licensee. This
|
||||
License Agreement does not grant permission to use CNRI trademarks or
|
||||
trade name in a trademark sense to endorse or promote products or
|
||||
services of Licensee, or any third party.
|
||||
|
||||
8. By clicking on the "ACCEPT" button where indicated, or by copying,
|
||||
installing or otherwise using Python 1.6.1, Licensee agrees to be
|
||||
bound by the terms and conditions of this License Agreement.
|
||||
|
||||
ACCEPT
|
||||
|
||||
|
||||
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
|
||||
--------------------------------------------------
|
||||
|
||||
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
|
||||
The Netherlands. All rights reserved.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Stichting Mathematisch
|
||||
Centrum or CWI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
django
|
||||
24
venv/lib/python3.10/site-packages/django/__init__.py
Normal file
24
venv/lib/python3.10/site-packages/django/__init__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from django.utils.version import get_version
|
||||
|
||||
VERSION = (5, 2, 16, "final", 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 urlresolvers script prefix if `set_prefix` is True.
|
||||
"""
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.urls import set_script_prefix
|
||||
from django.utils.log import configure_logging
|
||||
|
||||
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
|
||||
if set_prefix:
|
||||
set_script_prefix(
|
||||
"/" if settings.FORCE_SCRIPT_NAME is None else settings.FORCE_SCRIPT_NAME
|
||||
)
|
||||
apps.populate(settings.INSTALLED_APPS)
|
||||
10
venv/lib/python3.10/site-packages/django/__main__.py
Normal file
10
venv/lib/python3.10/site-packages/django/__main__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
"""
|
||||
Invokes django-admin when the django module is run as a script.
|
||||
|
||||
Example: python -m django check
|
||||
"""
|
||||
|
||||
from django.core import management
|
||||
|
||||
if __name__ == "__main__":
|
||||
management.execute_from_command_line()
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
from .config import AppConfig
|
||||
from .registry import apps
|
||||
|
||||
__all__ = ["AppConfig", "apps"]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
274
venv/lib/python3.10/site-packages/django/apps/config.py
Normal file
274
venv/lib/python3.10/site-packages/django/apps/config.py
Normal file
@@ -0,0 +1,274 @@
|
||||
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:
|
||||
"""Class representing a Django application and its configuration."""
|
||||
|
||||
def __init__(self, app_name, app_module):
|
||||
# Full Python path to the application e.g. 'django.contrib.admin'.
|
||||
self.name = app_name
|
||||
|
||||
# Root module for the application e.g. <module 'django.contrib.admin'
|
||||
# from 'django/contrib/admin/__init__.py'>.
|
||||
self.module = app_module
|
||||
|
||||
# Reference to the Apps registry that holds this AppConfig. Set by the
|
||||
# registry when it registers the AppConfig instance.
|
||||
self.apps = None
|
||||
|
||||
# The following attributes could be defined at the class level in a
|
||||
# subclass, hence the test-and-set pattern.
|
||||
|
||||
# Last component of the Python path to the application e.g. 'admin'.
|
||||
# This value must be unique across a Django project.
|
||||
if not hasattr(self, "label"):
|
||||
self.label = app_name.rpartition(".")[2]
|
||||
if not self.label.isidentifier():
|
||||
raise ImproperlyConfigured(
|
||||
"The app label '%s' is not a valid Python identifier." % self.label
|
||||
)
|
||||
|
||||
# Human-readable name for the application e.g. "Admin".
|
||||
if not hasattr(self, "verbose_name"):
|
||||
self.verbose_name = self.label.title()
|
||||
|
||||
# Filesystem path to the application directory e.g.
|
||||
# '/path/to/django/contrib/admin'.
|
||||
if not hasattr(self, "path"):
|
||||
self.path = self._path_from_module(app_module)
|
||||
|
||||
# Module containing models e.g. <module 'django.contrib.admin.models'
|
||||
# from 'django/contrib/admin/models.py'>. Set by import_models().
|
||||
# None if the application doesn't have a models module.
|
||||
self.models_module = None
|
||||
|
||||
# Mapping of lowercase model names to model classes. Initially set to
|
||||
# None to prevent accidental access before import_models() runs.
|
||||
self.models = None
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s: %s>" % (self.__class__.__name__, self.label)
|
||||
|
||||
@cached_property
|
||||
def default_auto_field(self):
|
||||
from django.conf import settings
|
||||
|
||||
return settings.DEFAULT_AUTO_FIELD
|
||||
|
||||
@property
|
||||
def _is_default_auto_field_overridden(self):
|
||||
return self.__class__.default_auto_field is not AppConfig.default_auto_field
|
||||
|
||||
def _path_from_module(self, module):
|
||||
"""Attempt to determine app's filesystem path from its module."""
|
||||
# See #21874 for extended discussion of the behavior of this method in
|
||||
# various cases.
|
||||
# Convert to list because __path__ may not support indexing.
|
||||
paths = list(getattr(module, "__path__", []))
|
||||
if len(paths) != 1:
|
||||
filename = getattr(module, "__file__", None)
|
||||
if filename is not None:
|
||||
paths = [os.path.dirname(filename)]
|
||||
else:
|
||||
# For unknown reasons, sometimes the list returned by __path__
|
||||
# contains duplicates that must be removed (#25246).
|
||||
paths = list(set(paths))
|
||||
if len(paths) > 1:
|
||||
raise ImproperlyConfigured(
|
||||
"The app module %r has multiple filesystem locations (%r); "
|
||||
"you must configure this app with an AppConfig subclass "
|
||||
"with a 'path' class attribute." % (module, paths)
|
||||
)
|
||||
elif not paths:
|
||||
raise ImproperlyConfigured(
|
||||
"The app module %r has no filesystem location, "
|
||||
"you must configure this app with an AppConfig subclass "
|
||||
"with a 'path' class attribute." % module
|
||||
)
|
||||
return paths[0]
|
||||
|
||||
@classmethod
|
||||
def create(cls, entry):
|
||||
"""
|
||||
Factory that creates an app config from an entry in INSTALLED_APPS.
|
||||
"""
|
||||
# create() eventually returns app_config_class(app_name, app_module).
|
||||
app_config_class = None
|
||||
app_name = None
|
||||
app_module = None
|
||||
|
||||
# If import_module succeeds, entry points to the app module.
|
||||
try:
|
||||
app_module = import_module(entry)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
# If app_module has an apps submodule that defines a single
|
||||
# AppConfig subclass, use it automatically.
|
||||
# To prevent this, an AppConfig subclass can declare a class
|
||||
# variable default = False.
|
||||
# If the apps module defines more than one AppConfig subclass,
|
||||
# the default one can declare default = True.
|
||||
if module_has_submodule(app_module, APPS_MODULE_NAME):
|
||||
mod_path = "%s.%s" % (entry, APPS_MODULE_NAME)
|
||||
mod = import_module(mod_path)
|
||||
# Check if there's exactly one AppConfig candidate,
|
||||
# excluding those that explicitly define default = False.
|
||||
app_configs = [
|
||||
(name, candidate)
|
||||
for name, candidate in inspect.getmembers(mod, inspect.isclass)
|
||||
if (
|
||||
issubclass(candidate, cls)
|
||||
and candidate is not cls
|
||||
and getattr(candidate, "default", True)
|
||||
)
|
||||
]
|
||||
if len(app_configs) == 1:
|
||||
app_config_class = app_configs[0][1]
|
||||
else:
|
||||
# Check if there's exactly one AppConfig subclass,
|
||||
# among those that explicitly define default = True.
|
||||
app_configs = [
|
||||
(name, candidate)
|
||||
for name, candidate in app_configs
|
||||
if getattr(candidate, "default", False)
|
||||
]
|
||||
if len(app_configs) > 1:
|
||||
candidates = [repr(name) for name, _ in app_configs]
|
||||
raise RuntimeError(
|
||||
"%r declares more than one default AppConfig: "
|
||||
"%s." % (mod_path, ", ".join(candidates))
|
||||
)
|
||||
elif len(app_configs) == 1:
|
||||
app_config_class = app_configs[0][1]
|
||||
|
||||
# Use the default app config class if we didn't find anything.
|
||||
if app_config_class is None:
|
||||
app_config_class = cls
|
||||
app_name = entry
|
||||
|
||||
# If import_string succeeds, entry is an app config class.
|
||||
if app_config_class is None:
|
||||
try:
|
||||
app_config_class = import_string(entry)
|
||||
except Exception:
|
||||
pass
|
||||
# If both import_module and import_string failed, it means that entry
|
||||
# doesn't have a valid value.
|
||||
if app_module is None and app_config_class is None:
|
||||
# If the last component of entry starts with an uppercase letter,
|
||||
# then it was likely intended to be an app config class; if not,
|
||||
# an app module. Provide a nice error message in both cases.
|
||||
mod_path, _, cls_name = entry.rpartition(".")
|
||||
if mod_path and cls_name[0].isupper():
|
||||
# We could simply re-trigger the string import exception, but
|
||||
# we're going the extra mile and providing a better error
|
||||
# message for typos in INSTALLED_APPS.
|
||||
# This may raise ImportError, which is the best exception
|
||||
# possible if the module at mod_path cannot be imported.
|
||||
mod = import_module(mod_path)
|
||||
candidates = [
|
||||
repr(name)
|
||||
for name, candidate in inspect.getmembers(mod, inspect.isclass)
|
||||
if issubclass(candidate, cls) and candidate is not cls
|
||||
]
|
||||
msg = "Module '%s' does not contain a '%s' class." % (
|
||||
mod_path,
|
||||
cls_name,
|
||||
)
|
||||
if candidates:
|
||||
msg += " Choices are: %s." % ", ".join(candidates)
|
||||
raise ImportError(msg)
|
||||
else:
|
||||
# Re-trigger the module import exception.
|
||||
import_module(entry)
|
||||
|
||||
# Check for obvious errors. (This check prevents duck typing, but
|
||||
# it could be removed if it became a problem in practice.)
|
||||
if not issubclass(app_config_class, AppConfig):
|
||||
raise ImproperlyConfigured("'%s' isn't a subclass of AppConfig." % entry)
|
||||
|
||||
# Obtain app name here rather than in AppClass.__init__ to keep
|
||||
# all error checking for entries in INSTALLED_APPS in one place.
|
||||
if app_name is None:
|
||||
try:
|
||||
app_name = app_config_class.name
|
||||
except AttributeError:
|
||||
raise ImproperlyConfigured("'%s' must supply a name attribute." % entry)
|
||||
|
||||
# Ensure app_name points to a valid module.
|
||||
try:
|
||||
app_module = import_module(app_name)
|
||||
except ImportError:
|
||||
raise ImproperlyConfigured(
|
||||
"Cannot import '%s'. Check that '%s.%s.name' is correct."
|
||||
% (
|
||||
app_name,
|
||||
app_config_class.__module__,
|
||||
app_config_class.__qualname__,
|
||||
)
|
||||
)
|
||||
|
||||
# Entry is a path to an app config class.
|
||||
return app_config_class(app_name, app_module)
|
||||
|
||||
def get_model(self, model_name, require_ready=True):
|
||||
"""
|
||||
Return the model with the given case-insensitive model_name.
|
||||
|
||||
Raise LookupError if no model exists with this name.
|
||||
"""
|
||||
if require_ready:
|
||||
self.apps.check_models_ready()
|
||||
else:
|
||||
self.apps.check_apps_ready()
|
||||
try:
|
||||
return self.models[model_name.lower()]
|
||||
except KeyError:
|
||||
raise LookupError(
|
||||
"App '%s' doesn't have a '%s' model." % (self.label, model_name)
|
||||
)
|
||||
|
||||
def get_models(self, include_auto_created=False, include_swapped=False):
|
||||
"""
|
||||
Return an iterable of models.
|
||||
|
||||
By default, the following models aren't included:
|
||||
|
||||
- auto-created models for many-to-many relations without
|
||||
an explicit intermediate table,
|
||||
- models that have been swapped out.
|
||||
|
||||
Set the corresponding keyword argument to True to include such models.
|
||||
Keyword arguments aren't documented; they're a private API.
|
||||
"""
|
||||
self.apps.check_models_ready()
|
||||
for model in self.models.values():
|
||||
if model._meta.auto_created and not include_auto_created:
|
||||
continue
|
||||
if model._meta.swapped and not include_swapped:
|
||||
continue
|
||||
yield model
|
||||
|
||||
def import_models(self):
|
||||
# Dictionary of models for this app, primarily maintained in the
|
||||
# 'all_models' attribute of the Apps this AppConfig is attached to.
|
||||
self.models = self.apps.all_models[self.label]
|
||||
|
||||
if module_has_submodule(self.module, MODELS_MODULE_NAME):
|
||||
models_module_name = "%s.%s" % (self.name, MODELS_MODULE_NAME)
|
||||
self.models_module = import_module(models_module_name)
|
||||
|
||||
def ready(self):
|
||||
"""
|
||||
Override this method in subclasses to run code when Django starts.
|
||||
"""
|
||||
437
venv/lib/python3.10/site-packages/django/apps/registry.py
Normal file
437
venv/lib/python3.10/site-packages/django/apps/registry.py
Normal file
@@ -0,0 +1,437 @@
|
||||
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 installed applications.
|
||||
|
||||
It also keeps track of models, e.g. to provide reverse relations.
|
||||
"""
|
||||
|
||||
def __init__(self, installed_apps=()):
|
||||
# installed_apps is set to None when creating the main registry
|
||||
# because it cannot be populated at that point. Other registries must
|
||||
# provide a list of installed apps and are populated immediately.
|
||||
if installed_apps is None and hasattr(sys.modules[__name__], "apps"):
|
||||
raise RuntimeError("You must supply an installed_apps argument.")
|
||||
|
||||
# Mapping of app labels => model names => model classes. Every time a
|
||||
# model is imported, ModelBase.__new__ calls apps.register_model which
|
||||
# creates an entry in all_models. All imported models are registered,
|
||||
# regardless of whether they're defined in an installed application
|
||||
# and whether the registry has been populated. Since it isn't possible
|
||||
# to reimport a module safely (it could reexecute initialization code)
|
||||
# all_models is never overridden or reset.
|
||||
self.all_models = defaultdict(dict)
|
||||
|
||||
# Mapping of labels to AppConfig instances for installed apps.
|
||||
self.app_configs = {}
|
||||
|
||||
# Stack of app_configs. Used to store the current state in
|
||||
# set_available_apps and set_installed_apps.
|
||||
self.stored_app_configs = []
|
||||
|
||||
# Whether the registry is populated.
|
||||
self.apps_ready = self.models_ready = self.ready = False
|
||||
# For the autoreloader.
|
||||
self.ready_event = threading.Event()
|
||||
|
||||
# Lock for thread-safe population.
|
||||
self._lock = threading.RLock()
|
||||
self.loading = False
|
||||
|
||||
# Maps ("app_label", "modelname") tuples to lists of functions to be
|
||||
# called when the corresponding model is ready. Used by this class's
|
||||
# `lazy_model_operation()` and `do_pending_operations()` methods.
|
||||
self._pending_operations = defaultdict(list)
|
||||
|
||||
# Populate apps and models, unless it's the main registry.
|
||||
if installed_apps is not None:
|
||||
self.populate(installed_apps)
|
||||
|
||||
def populate(self, installed_apps=None):
|
||||
"""
|
||||
Load application configurations and models.
|
||||
|
||||
Import each application module and then each model module.
|
||||
|
||||
It is thread-safe and idempotent, but not reentrant.
|
||||
"""
|
||||
if self.ready:
|
||||
return
|
||||
|
||||
# populate() might be called by two threads in parallel on servers
|
||||
# that create threads before initializing the WSGI callable.
|
||||
with self._lock:
|
||||
if self.ready:
|
||||
return
|
||||
|
||||
# An RLock prevents other threads from entering this section. The
|
||||
# compare and set operation below is atomic.
|
||||
if self.loading:
|
||||
# Prevent reentrant calls to avoid running AppConfig.ready()
|
||||
# methods twice.
|
||||
raise RuntimeError("populate() isn't reentrant")
|
||||
self.loading = True
|
||||
|
||||
# Phase 1: initialize app configs and import app modules.
|
||||
for entry in installed_apps:
|
||||
if isinstance(entry, AppConfig):
|
||||
app_config = entry
|
||||
else:
|
||||
app_config = AppConfig.create(entry)
|
||||
if app_config.label in self.app_configs:
|
||||
raise ImproperlyConfigured(
|
||||
"Application labels aren't unique, "
|
||||
"duplicates: %s" % app_config.label
|
||||
)
|
||||
|
||||
self.app_configs[app_config.label] = app_config
|
||||
app_config.apps = self
|
||||
|
||||
# Check for duplicate app names.
|
||||
counts = Counter(
|
||||
app_config.name for app_config in self.app_configs.values()
|
||||
)
|
||||
duplicates = [name for name, count in counts.most_common() if count > 1]
|
||||
if duplicates:
|
||||
raise ImproperlyConfigured(
|
||||
"Application names aren't unique, "
|
||||
"duplicates: %s" % ", ".join(duplicates)
|
||||
)
|
||||
|
||||
self.apps_ready = True
|
||||
|
||||
# Phase 2: import models modules.
|
||||
for app_config in self.app_configs.values():
|
||||
app_config.import_models()
|
||||
|
||||
self.clear_cache()
|
||||
|
||||
self.models_ready = True
|
||||
|
||||
# Phase 3: run ready() methods of app configs.
|
||||
for app_config in self.get_app_configs():
|
||||
app_config.ready()
|
||||
|
||||
self.ready = True
|
||||
self.ready_event.set()
|
||||
|
||||
def check_apps_ready(self):
|
||||
"""Raise an exception if all apps haven't been imported yet."""
|
||||
if not self.apps_ready:
|
||||
from django.conf import settings
|
||||
|
||||
# If "not ready" is due to unconfigured settings, accessing
|
||||
# INSTALLED_APPS raises a more helpful ImproperlyConfigured
|
||||
# exception.
|
||||
settings.INSTALLED_APPS
|
||||
raise AppRegistryNotReady("Apps aren't loaded yet.")
|
||||
|
||||
def check_models_ready(self):
|
||||
"""Raise an exception if all models haven't been imported yet."""
|
||||
if not self.models_ready:
|
||||
raise AppRegistryNotReady("Models aren't loaded yet.")
|
||||
|
||||
def get_app_configs(self):
|
||||
"""Import applications and return an iterable of app configs."""
|
||||
self.check_apps_ready()
|
||||
return self.app_configs.values()
|
||||
|
||||
def get_app_config(self, app_label):
|
||||
"""
|
||||
Import applications and returns an app config for the given label.
|
||||
|
||||
Raise LookupError if no application exists with this label.
|
||||
"""
|
||||
self.check_apps_ready()
|
||||
try:
|
||||
return self.app_configs[app_label]
|
||||
except KeyError:
|
||||
message = "No installed app with label '%s'." % app_label
|
||||
for app_config in self.get_app_configs():
|
||||
if app_config.name == app_label:
|
||||
message += " Did you mean '%s'?" % app_config.label
|
||||
break
|
||||
raise LookupError(message)
|
||||
|
||||
# This method is performance-critical at least for Django's test suite.
|
||||
@functools.cache
|
||||
def get_models(self, include_auto_created=False, include_swapped=False):
|
||||
"""
|
||||
Return a list of all installed models.
|
||||
|
||||
By default, the following models aren't included:
|
||||
|
||||
- auto-created models for many-to-many relations without
|
||||
an explicit intermediate table,
|
||||
- models that have been swapped out.
|
||||
|
||||
Set the corresponding keyword argument to True to include such models.
|
||||
"""
|
||||
self.check_models_ready()
|
||||
|
||||
result = []
|
||||
for app_config in self.app_configs.values():
|
||||
result.extend(app_config.get_models(include_auto_created, include_swapped))
|
||||
return result
|
||||
|
||||
def get_model(self, app_label, model_name=None, require_ready=True):
|
||||
"""
|
||||
Return the model matching the given app_label and model_name.
|
||||
|
||||
As a shortcut, app_label may be in the form <app_label>.<model_name>.
|
||||
|
||||
model_name is case-insensitive.
|
||||
|
||||
Raise LookupError if no application exists with this label, or no
|
||||
model exists with this name in the application. Raise ValueError if
|
||||
called with a single argument that doesn't contain exactly one dot.
|
||||
"""
|
||||
if require_ready:
|
||||
self.check_models_ready()
|
||||
else:
|
||||
self.check_apps_ready()
|
||||
|
||||
if model_name is None:
|
||||
app_label, model_name = app_label.split(".")
|
||||
|
||||
app_config = self.get_app_config(app_label)
|
||||
|
||||
if not require_ready and app_config.models is None:
|
||||
app_config.import_models()
|
||||
|
||||
return app_config.get_model(model_name, require_ready=require_ready)
|
||||
|
||||
def register_model(self, app_label, model):
|
||||
# Since this method is called when models are imported, it cannot
|
||||
# perform imports because of the risk of import loops. It mustn't
|
||||
# call get_app_config().
|
||||
model_name = model._meta.model_name
|
||||
app_models = self.all_models[app_label]
|
||||
if model_name in app_models:
|
||||
if (
|
||||
model.__name__ == app_models[model_name].__name__
|
||||
and model.__module__ == app_models[model_name].__module__
|
||||
):
|
||||
warnings.warn(
|
||||
"Model '%s.%s' was already registered. Reloading models is not "
|
||||
"advised as it can lead to inconsistencies, most notably with "
|
||||
"related models." % (app_label, model_name),
|
||||
RuntimeWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"Conflicting '%s' models in application '%s': %s and %s."
|
||||
% (model_name, app_label, app_models[model_name], model)
|
||||
)
|
||||
app_models[model_name] = model
|
||||
self.do_pending_operations(model)
|
||||
self.clear_cache()
|
||||
|
||||
def is_installed(self, app_name):
|
||||
"""
|
||||
Check whether an application with this name exists in the registry.
|
||||
|
||||
app_name is the full name of the app e.g. 'django.contrib.admin'.
|
||||
"""
|
||||
self.check_apps_ready()
|
||||
return any(ac.name == app_name for ac in self.app_configs.values())
|
||||
|
||||
def get_containing_app_config(self, object_name):
|
||||
"""
|
||||
Look for an app config containing a given object.
|
||||
|
||||
object_name is the dotted Python path to the object.
|
||||
|
||||
Return the app config for the inner application in case of nesting.
|
||||
Return None if the object isn't in any registered app config.
|
||||
"""
|
||||
self.check_apps_ready()
|
||||
candidates = []
|
||||
for app_config in self.app_configs.values():
|
||||
if object_name.startswith(app_config.name):
|
||||
subpath = object_name.removeprefix(app_config.name)
|
||||
if subpath == "" or subpath[0] == ".":
|
||||
candidates.append(app_config)
|
||||
if candidates:
|
||||
return sorted(candidates, key=lambda ac: -len(ac.name))[0]
|
||||
|
||||
def get_registered_model(self, app_label, model_name):
|
||||
"""
|
||||
Similar to get_model(), but doesn't require that an app exists with
|
||||
the given app_label.
|
||||
|
||||
It's safe to call this method at import time, even while the registry
|
||||
is being populated.
|
||||
"""
|
||||
model = self.all_models[app_label].get(model_name.lower())
|
||||
if model is None:
|
||||
raise LookupError("Model '%s.%s' not registered." % (app_label, model_name))
|
||||
return model
|
||||
|
||||
@functools.cache
|
||||
def get_swappable_settings_name(self, to_string):
|
||||
"""
|
||||
For a given model string (e.g. "auth.User"), return the name of the
|
||||
corresponding settings name if it refers to a swappable model. If the
|
||||
referred model is not swappable, return None.
|
||||
|
||||
This method is decorated with @functools.cache because it's performance
|
||||
critical when it comes to migrations. Since the swappable settings don't
|
||||
change after Django has loaded the settings, there is no reason to get
|
||||
the respective settings attribute over and over again.
|
||||
"""
|
||||
to_string = to_string.lower()
|
||||
for model in self.get_models(include_swapped=True):
|
||||
swapped = model._meta.swapped
|
||||
# Is this model swapped out for the model given by to_string?
|
||||
if swapped and swapped.lower() == to_string:
|
||||
return model._meta.swappable
|
||||
# Is this model swappable and the one given by to_string?
|
||||
if model._meta.swappable and model._meta.label_lower == to_string:
|
||||
return model._meta.swappable
|
||||
return None
|
||||
|
||||
def set_available_apps(self, available):
|
||||
"""
|
||||
Restrict the set of installed apps used by get_app_config[s].
|
||||
|
||||
available must be an iterable of application names.
|
||||
|
||||
set_available_apps() must be balanced with unset_available_apps().
|
||||
|
||||
Primarily used for performance optimization in TransactionTestCase.
|
||||
|
||||
This method is safe in the sense that it doesn't trigger any imports.
|
||||
"""
|
||||
available = set(available)
|
||||
installed = {app_config.name for app_config in self.get_app_configs()}
|
||||
if not available.issubset(installed):
|
||||
raise ValueError(
|
||||
"Available apps isn't a subset of installed apps, extra apps: %s"
|
||||
% ", ".join(available - installed)
|
||||
)
|
||||
|
||||
self.stored_app_configs.append(self.app_configs)
|
||||
self.app_configs = {
|
||||
label: app_config
|
||||
for label, app_config in self.app_configs.items()
|
||||
if app_config.name in available
|
||||
}
|
||||
self.clear_cache()
|
||||
|
||||
def unset_available_apps(self):
|
||||
"""Cancel a previous call to set_available_apps()."""
|
||||
self.app_configs = self.stored_app_configs.pop()
|
||||
self.clear_cache()
|
||||
|
||||
def set_installed_apps(self, installed):
|
||||
"""
|
||||
Enable a different set of installed apps for get_app_config[s].
|
||||
|
||||
installed must be an iterable in the same format as INSTALLED_APPS.
|
||||
|
||||
set_installed_apps() must be balanced with unset_installed_apps(),
|
||||
even if it exits with an exception.
|
||||
|
||||
Primarily used as a receiver of the setting_changed signal in tests.
|
||||
|
||||
This method may trigger new imports, which may add new models to the
|
||||
registry of all imported models. They will stay in the registry even
|
||||
after unset_installed_apps(). Since it isn't possible to replay
|
||||
imports safely (e.g. that could lead to registering listeners twice),
|
||||
models are registered when they're imported and never removed.
|
||||
"""
|
||||
if not self.ready:
|
||||
raise AppRegistryNotReady("App registry isn't ready yet.")
|
||||
self.stored_app_configs.append(self.app_configs)
|
||||
self.app_configs = {}
|
||||
self.apps_ready = self.models_ready = self.loading = self.ready = False
|
||||
self.clear_cache()
|
||||
self.populate(installed)
|
||||
|
||||
def unset_installed_apps(self):
|
||||
"""Cancel a previous call to set_installed_apps()."""
|
||||
self.app_configs = self.stored_app_configs.pop()
|
||||
self.apps_ready = self.models_ready = self.ready = True
|
||||
self.clear_cache()
|
||||
|
||||
def clear_cache(self):
|
||||
"""
|
||||
Clear all internal caches, for methods that alter the app registry.
|
||||
|
||||
This is mostly used in tests.
|
||||
"""
|
||||
self.get_swappable_settings_name.cache_clear()
|
||||
# Call expire cache on each model. This will purge
|
||||
# the relation tree and the fields cache.
|
||||
self.get_models.cache_clear()
|
||||
if self.ready:
|
||||
# Circumvent self.get_models() to prevent that the cache is refilled.
|
||||
# This particularly prevents that an empty value is cached while cloning.
|
||||
for app_config in self.app_configs.values():
|
||||
for model in app_config.get_models(include_auto_created=True):
|
||||
model._meta._expire_cache()
|
||||
|
||||
def lazy_model_operation(self, function, *model_keys):
|
||||
"""
|
||||
Take a function and a number of ("app_label", "modelname") tuples, and
|
||||
when all the corresponding models have been imported and registered,
|
||||
call the function with the model classes as its arguments.
|
||||
|
||||
The function passed to this method must accept exactly n models as
|
||||
arguments, where n=len(model_keys).
|
||||
"""
|
||||
# Base case: no arguments, just execute the function.
|
||||
if not model_keys:
|
||||
function()
|
||||
# Recursive case: take the head of model_keys, wait for the
|
||||
# corresponding model class to be imported and registered, then apply
|
||||
# that argument to the supplied function. Pass the resulting partial
|
||||
# to lazy_model_operation() along with the remaining model args and
|
||||
# repeat until all models are loaded and all arguments are applied.
|
||||
else:
|
||||
next_model, *more_models = model_keys
|
||||
|
||||
# This will be executed after the class corresponding to next_model
|
||||
# has been imported and registered. The `func` attribute provides
|
||||
# duck-type compatibility with partials.
|
||||
def apply_next_model(model):
|
||||
next_function = partial(apply_next_model.func, model)
|
||||
self.lazy_model_operation(next_function, *more_models)
|
||||
|
||||
apply_next_model.func = function
|
||||
|
||||
# If the model has already been imported and registered, partially
|
||||
# apply it to the function now. If not, add it to the list of
|
||||
# pending operations for the model, where it will be executed with
|
||||
# the model class as its sole argument once the model is ready.
|
||||
try:
|
||||
model_class = self.get_registered_model(*next_model)
|
||||
except LookupError:
|
||||
self._pending_operations[next_model].append(apply_next_model)
|
||||
else:
|
||||
apply_next_model(model_class)
|
||||
|
||||
def do_pending_operations(self, model):
|
||||
"""
|
||||
Take a newly-prepared model and pass it to each function waiting for
|
||||
it. This is called at the very end of Apps.register_model().
|
||||
"""
|
||||
key = model._meta.app_label, model._meta.model_name
|
||||
for function in self._pending_operations.pop(key, []):
|
||||
function(model)
|
||||
|
||||
|
||||
apps = Apps(installed_apps=None)
|
||||
272
venv/lib/python3.10/site-packages/django/conf/__init__.py
Normal file
272
venv/lib/python3.10/site-packages/django/conf/__init__.py
Normal file
@@ -0,0 +1,272 @@
|
||||
"""
|
||||
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
|
||||
from pathlib import Path
|
||||
|
||||
import django
|
||||
from django.conf import global_settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.deprecation import RemovedInDjango60Warning
|
||||
from django.utils.functional import LazyObject, empty
|
||||
|
||||
ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
|
||||
DEFAULT_STORAGE_ALIAS = "default"
|
||||
STATICFILES_STORAGE_ALIAS = "staticfiles"
|
||||
|
||||
# RemovedInDjango60Warning.
|
||||
FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG = (
|
||||
"The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated."
|
||||
)
|
||||
|
||||
|
||||
class SettingsReference(str):
|
||||
"""
|
||||
String subclass which references a current settings value. It's treated as
|
||||
the value in memory but serializes to a settings.NAME attribute reference.
|
||||
"""
|
||||
|
||||
def __new__(self, value, setting_name):
|
||||
return str.__new__(self, value)
|
||||
|
||||
def __init__(self, value, setting_name):
|
||||
self.setting_name = setting_name
|
||||
|
||||
|
||||
class LazySettings(LazyObject):
|
||||
"""
|
||||
A lazy proxy for either global Django settings or a custom settings object.
|
||||
The user can manually configure settings prior to using them. Otherwise,
|
||||
Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
|
||||
"""
|
||||
|
||||
def _setup(self, name=None):
|
||||
"""
|
||||
Load the settings module pointed to by the environment variable. This
|
||||
is used the first time settings are needed, if the user hasn't
|
||||
configured settings manually.
|
||||
"""
|
||||
settings_module = os.environ.get(ENVIRONMENT_VARIABLE)
|
||||
if not settings_module:
|
||||
desc = ("setting %s" % name) if name else "settings"
|
||||
raise ImproperlyConfigured(
|
||||
"Requested %s, but settings are not configured. "
|
||||
"You must either define the environment variable %s "
|
||||
"or call settings.configure() before accessing settings."
|
||||
% (desc, ENVIRONMENT_VARIABLE)
|
||||
)
|
||||
|
||||
self._wrapped = Settings(settings_module)
|
||||
|
||||
def __repr__(self):
|
||||
# Hardcode the class name as otherwise it yields 'Settings'.
|
||||
if self._wrapped is empty:
|
||||
return "<LazySettings [Unevaluated]>"
|
||||
return '<LazySettings "%(settings_module)s">' % {
|
||||
"settings_module": self._wrapped.SETTINGS_MODULE,
|
||||
}
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""Return the value of a setting and cache it in self.__dict__."""
|
||||
if (_wrapped := self._wrapped) is empty:
|
||||
self._setup(name)
|
||||
_wrapped = self._wrapped
|
||||
val = getattr(_wrapped, name)
|
||||
|
||||
# Special case some settings which require further modification.
|
||||
# This is done here for performance reasons so the modified value is cached.
|
||||
if name in {"MEDIA_URL", "STATIC_URL"} and val is not None:
|
||||
val = self._add_script_prefix(val)
|
||||
elif name == "SECRET_KEY" and not val:
|
||||
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
|
||||
|
||||
self.__dict__[name] = val
|
||||
return val
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""
|
||||
Set the value of setting. Clear all cached values if _wrapped changes
|
||||
(@override_settings does this) or clear single values when set.
|
||||
"""
|
||||
if name == "_wrapped":
|
||||
self.__dict__.clear()
|
||||
else:
|
||||
self.__dict__.pop(name, None)
|
||||
super().__setattr__(name, value)
|
||||
|
||||
def __delattr__(self, name):
|
||||
"""Delete a setting and clear it from cache if needed."""
|
||||
super().__delattr__(name)
|
||||
self.__dict__.pop(name, None)
|
||||
|
||||
def configure(self, default_settings=global_settings, **options):
|
||||
"""
|
||||
Called to manually configure the settings. The 'default_settings'
|
||||
parameter sets where to retrieve any unspecified values from (its
|
||||
argument must support attribute access (__getattr__)).
|
||||
"""
|
||||
if self._wrapped is not empty:
|
||||
raise RuntimeError("Settings already configured.")
|
||||
holder = UserSettingsHolder(default_settings)
|
||||
for name, value in options.items():
|
||||
if not name.isupper():
|
||||
raise TypeError("Setting %r must be uppercase." % name)
|
||||
setattr(holder, name, value)
|
||||
self._wrapped = holder
|
||||
|
||||
@staticmethod
|
||||
def _add_script_prefix(value):
|
||||
"""
|
||||
Add SCRIPT_NAME prefix to relative paths.
|
||||
|
||||
Useful when the app is being served at a subpath and manually prefixing
|
||||
subpath to STATIC_URL and MEDIA_URL in settings is inconvenient.
|
||||
"""
|
||||
# Don't apply prefix to absolute paths and URLs.
|
||||
if value.startswith(("http://", "https://", "/")):
|
||||
return value
|
||||
from django.urls import get_script_prefix
|
||||
|
||||
return "%s%s" % (get_script_prefix(), value)
|
||||
|
||||
@property
|
||||
def configured(self):
|
||||
"""Return True if the settings have already been configured."""
|
||||
return self._wrapped is not empty
|
||||
|
||||
def _show_deprecation_warning(self, message, category):
|
||||
stack = traceback.extract_stack()
|
||||
# Show a warning if the setting is used outside of Django.
|
||||
# Stack index: -1 this line, -2 the property, -3 the
|
||||
# LazyObject __getattribute__(), -4 the caller.
|
||||
filename, _, _, _ = stack[-4]
|
||||
if not filename.startswith(os.path.dirname(django.__file__)):
|
||||
warnings.warn(message, category, stacklevel=2)
|
||||
|
||||
|
||||
class Settings:
|
||||
def __init__(self, settings_module):
|
||||
# update this dict from global settings (but only for ALL_CAPS settings)
|
||||
for setting in dir(global_settings):
|
||||
if setting.isupper():
|
||||
setattr(self, setting, getattr(global_settings, setting))
|
||||
|
||||
# store the settings module in case someone later cares
|
||||
self.SETTINGS_MODULE = settings_module
|
||||
|
||||
mod = importlib.import_module(self.SETTINGS_MODULE)
|
||||
|
||||
tuple_settings = (
|
||||
"ALLOWED_HOSTS",
|
||||
"INSTALLED_APPS",
|
||||
"TEMPLATE_DIRS",
|
||||
"LOCALE_PATHS",
|
||||
"SECRET_KEY_FALLBACKS",
|
||||
)
|
||||
self._explicit_settings = set()
|
||||
for setting in dir(mod):
|
||||
if setting.isupper():
|
||||
setting_value = getattr(mod, setting)
|
||||
|
||||
if setting in tuple_settings and not isinstance(
|
||||
setting_value, (list, tuple)
|
||||
):
|
||||
raise ImproperlyConfigured(
|
||||
"The %s setting must be a list or a tuple." % setting
|
||||
)
|
||||
setattr(self, setting, setting_value)
|
||||
self._explicit_settings.add(setting)
|
||||
|
||||
if self.is_overridden("FORMS_URLFIELD_ASSUME_HTTPS"):
|
||||
warnings.warn(
|
||||
FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG,
|
||||
RemovedInDjango60Warning,
|
||||
)
|
||||
|
||||
if hasattr(time, "tzset") and self.TIME_ZONE:
|
||||
# When we can, attempt to validate the timezone. If we can't find
|
||||
# this file, no check happens and it's harmless.
|
||||
zoneinfo_root = Path("/usr/share/zoneinfo")
|
||||
zone_info_file = zoneinfo_root.joinpath(*self.TIME_ZONE.split("/"))
|
||||
if zoneinfo_root.exists() and not zone_info_file.exists():
|
||||
raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
|
||||
# Move the time zone info into os.environ. See ticket #2315 for why
|
||||
# we don't do this unconditionally (breaks Windows).
|
||||
os.environ["TZ"] = self.TIME_ZONE
|
||||
time.tzset()
|
||||
|
||||
def is_overridden(self, setting):
|
||||
return setting in self._explicit_settings
|
||||
|
||||
def __repr__(self):
|
||||
return '<%(cls)s "%(settings_module)s">' % {
|
||||
"cls": self.__class__.__name__,
|
||||
"settings_module": self.SETTINGS_MODULE,
|
||||
}
|
||||
|
||||
|
||||
class UserSettingsHolder:
|
||||
"""Holder for user configured settings."""
|
||||
|
||||
# SETTINGS_MODULE doesn't make much sense in the manually configured
|
||||
# (standalone) case.
|
||||
SETTINGS_MODULE = None
|
||||
|
||||
def __init__(self, default_settings):
|
||||
"""
|
||||
Requests for configuration variables not in this class are satisfied
|
||||
from the module specified in default_settings (if possible).
|
||||
"""
|
||||
self.__dict__["_deleted"] = set()
|
||||
self.default_settings = default_settings
|
||||
|
||||
def __getattr__(self, name):
|
||||
if not name.isupper() or name in self._deleted:
|
||||
raise AttributeError
|
||||
return getattr(self.default_settings, name)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
self._deleted.discard(name)
|
||||
if name == "FORMS_URLFIELD_ASSUME_HTTPS":
|
||||
warnings.warn(
|
||||
FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG,
|
||||
RemovedInDjango60Warning,
|
||||
)
|
||||
super().__setattr__(name, value)
|
||||
|
||||
def __delattr__(self, name):
|
||||
self._deleted.add(name)
|
||||
if hasattr(self, name):
|
||||
super().__delattr__(name)
|
||||
|
||||
def __dir__(self):
|
||||
return sorted(
|
||||
s
|
||||
for s in [*self.__dict__, *dir(self.default_settings)]
|
||||
if s not in self._deleted
|
||||
)
|
||||
|
||||
def is_overridden(self, setting):
|
||||
deleted = setting in self._deleted
|
||||
set_locally = setting in self.__dict__
|
||||
set_on_default = getattr(
|
||||
self.default_settings, "is_overridden", lambda s: False
|
||||
)(setting)
|
||||
return deleted or set_locally or set_on_default
|
||||
|
||||
def __repr__(self):
|
||||
return "<%(cls)s>" % {
|
||||
"cls": self.__class__.__name__,
|
||||
}
|
||||
|
||||
|
||||
settings = LazySettings()
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class {{ camel_case_app_name }}Config(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = '{{ app_name }}'
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
670
venv/lib/python3.10/site-packages/django/conf/global_settings.py
Normal file
670
venv/lib/python3.10/site-packages/django/conf/global_settings.py
Normal file
@@ -0,0 +1,670 @@
|
||||
"""
|
||||
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
|
||||
|
||||
|
||||
####################
|
||||
# CORE #
|
||||
####################
|
||||
|
||||
DEBUG = False
|
||||
|
||||
# Whether the framework should propagate raw exceptions rather than catching
|
||||
# them. This is useful under some testing situations and should never be used
|
||||
# on a live site.
|
||||
DEBUG_PROPAGATE_EXCEPTIONS = False
|
||||
|
||||
# People who get code error notifications. In the format
|
||||
# [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
|
||||
ADMINS = []
|
||||
|
||||
# List of IP addresses, as strings, that:
|
||||
# * See debug comments, when DEBUG is true
|
||||
# * Receive x-headers
|
||||
INTERNAL_IPS = []
|
||||
|
||||
# Hosts/domain names that are valid for this site.
|
||||
# "*" matches anything, ".example.com" matches example.com and all subdomains
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
# Local time zone for this installation. All choices can be found here:
|
||||
# https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all
|
||||
# systems may support all possibilities). When USE_TZ is True, this is
|
||||
# interpreted as the default user time zone.
|
||||
TIME_ZONE = "America/Chicago"
|
||||
|
||||
# If you set this to True, Django will use timezone-aware datetimes.
|
||||
USE_TZ = True
|
||||
|
||||
# Language code for this installation. Valid choices can be found here:
|
||||
# https://www.iana.org/assignments/language-subtag-registry/
|
||||
# If LANGUAGE_CODE is not listed in LANGUAGES (below), the project must
|
||||
# provide the necessary translations and locale definitions.
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
# Languages we provide translations for, out of the box.
|
||||
LANGUAGES = [
|
||||
("af", gettext_noop("Afrikaans")),
|
||||
("ar", gettext_noop("Arabic")),
|
||||
("ar-dz", gettext_noop("Algerian Arabic")),
|
||||
("ast", gettext_noop("Asturian")),
|
||||
("az", gettext_noop("Azerbaijani")),
|
||||
("bg", gettext_noop("Bulgarian")),
|
||||
("be", gettext_noop("Belarusian")),
|
||||
("bn", gettext_noop("Bengali")),
|
||||
("br", gettext_noop("Breton")),
|
||||
("bs", gettext_noop("Bosnian")),
|
||||
("ca", gettext_noop("Catalan")),
|
||||
("ckb", gettext_noop("Central Kurdish (Sorani)")),
|
||||
("cs", gettext_noop("Czech")),
|
||||
("cy", gettext_noop("Welsh")),
|
||||
("da", gettext_noop("Danish")),
|
||||
("de", gettext_noop("German")),
|
||||
("dsb", gettext_noop("Lower Sorbian")),
|
||||
("el", gettext_noop("Greek")),
|
||||
("en", gettext_noop("English")),
|
||||
("en-au", gettext_noop("Australian English")),
|
||||
("en-gb", gettext_noop("British English")),
|
||||
("eo", gettext_noop("Esperanto")),
|
||||
("es", gettext_noop("Spanish")),
|
||||
("es-ar", gettext_noop("Argentinian Spanish")),
|
||||
("es-co", gettext_noop("Colombian Spanish")),
|
||||
("es-mx", gettext_noop("Mexican Spanish")),
|
||||
("es-ni", gettext_noop("Nicaraguan Spanish")),
|
||||
("es-ve", gettext_noop("Venezuelan Spanish")),
|
||||
("et", gettext_noop("Estonian")),
|
||||
("eu", gettext_noop("Basque")),
|
||||
("fa", gettext_noop("Persian")),
|
||||
("fi", gettext_noop("Finnish")),
|
||||
("fr", gettext_noop("French")),
|
||||
("fy", gettext_noop("Frisian")),
|
||||
("ga", gettext_noop("Irish")),
|
||||
("gd", gettext_noop("Scottish Gaelic")),
|
||||
("gl", gettext_noop("Galician")),
|
||||
("he", gettext_noop("Hebrew")),
|
||||
("hi", gettext_noop("Hindi")),
|
||||
("hr", gettext_noop("Croatian")),
|
||||
("hsb", gettext_noop("Upper Sorbian")),
|
||||
("hu", gettext_noop("Hungarian")),
|
||||
("hy", gettext_noop("Armenian")),
|
||||
("ia", gettext_noop("Interlingua")),
|
||||
("id", gettext_noop("Indonesian")),
|
||||
("ig", gettext_noop("Igbo")),
|
||||
("io", gettext_noop("Ido")),
|
||||
("is", gettext_noop("Icelandic")),
|
||||
("it", gettext_noop("Italian")),
|
||||
("ja", gettext_noop("Japanese")),
|
||||
("ka", gettext_noop("Georgian")),
|
||||
("kab", gettext_noop("Kabyle")),
|
||||
("kk", gettext_noop("Kazakh")),
|
||||
("km", gettext_noop("Khmer")),
|
||||
("kn", gettext_noop("Kannada")),
|
||||
("ko", gettext_noop("Korean")),
|
||||
("ky", gettext_noop("Kyrgyz")),
|
||||
("lb", gettext_noop("Luxembourgish")),
|
||||
("lt", gettext_noop("Lithuanian")),
|
||||
("lv", gettext_noop("Latvian")),
|
||||
("mk", gettext_noop("Macedonian")),
|
||||
("ml", gettext_noop("Malayalam")),
|
||||
("mn", gettext_noop("Mongolian")),
|
||||
("mr", gettext_noop("Marathi")),
|
||||
("ms", gettext_noop("Malay")),
|
||||
("my", gettext_noop("Burmese")),
|
||||
("nb", gettext_noop("Norwegian Bokmål")),
|
||||
("ne", gettext_noop("Nepali")),
|
||||
("nl", gettext_noop("Dutch")),
|
||||
("nn", gettext_noop("Norwegian Nynorsk")),
|
||||
("os", gettext_noop("Ossetic")),
|
||||
("pa", gettext_noop("Punjabi")),
|
||||
("pl", gettext_noop("Polish")),
|
||||
("pt", gettext_noop("Portuguese")),
|
||||
("pt-br", gettext_noop("Brazilian Portuguese")),
|
||||
("ro", gettext_noop("Romanian")),
|
||||
("ru", gettext_noop("Russian")),
|
||||
("sk", gettext_noop("Slovak")),
|
||||
("sl", gettext_noop("Slovenian")),
|
||||
("sq", gettext_noop("Albanian")),
|
||||
("sr", gettext_noop("Serbian")),
|
||||
("sr-latn", gettext_noop("Serbian Latin")),
|
||||
("sv", gettext_noop("Swedish")),
|
||||
("sw", gettext_noop("Swahili")),
|
||||
("ta", gettext_noop("Tamil")),
|
||||
("te", gettext_noop("Telugu")),
|
||||
("tg", gettext_noop("Tajik")),
|
||||
("th", gettext_noop("Thai")),
|
||||
("tk", gettext_noop("Turkmen")),
|
||||
("tr", gettext_noop("Turkish")),
|
||||
("tt", gettext_noop("Tatar")),
|
||||
("udm", gettext_noop("Udmurt")),
|
||||
("ug", gettext_noop("Uyghur")),
|
||||
("uk", gettext_noop("Ukrainian")),
|
||||
("ur", gettext_noop("Urdu")),
|
||||
("uz", gettext_noop("Uzbek")),
|
||||
("vi", gettext_noop("Vietnamese")),
|
||||
("zh-hans", gettext_noop("Simplified Chinese")),
|
||||
("zh-hant", gettext_noop("Traditional Chinese")),
|
||||
]
|
||||
|
||||
# Languages using BiDi (right-to-left) layout
|
||||
LANGUAGES_BIDI = ["he", "ar", "ar-dz", "ckb", "fa", "ug", "ur"]
|
||||
|
||||
# If you set this to False, Django will make some optimizations so as not
|
||||
# to load the internationalization machinery.
|
||||
USE_I18N = True
|
||||
LOCALE_PATHS = []
|
||||
|
||||
# Settings for language cookie
|
||||
LANGUAGE_COOKIE_NAME = "django_language"
|
||||
LANGUAGE_COOKIE_AGE = None
|
||||
LANGUAGE_COOKIE_DOMAIN = None
|
||||
LANGUAGE_COOKIE_PATH = "/"
|
||||
LANGUAGE_COOKIE_SECURE = False
|
||||
LANGUAGE_COOKIE_HTTPONLY = False
|
||||
LANGUAGE_COOKIE_SAMESITE = None
|
||||
|
||||
# Not-necessarily-technical managers of the site. They get broken link
|
||||
# notifications and other various emails.
|
||||
MANAGERS = ADMINS
|
||||
|
||||
# Default charset to use for all HttpResponse objects, if a MIME type isn't
|
||||
# manually specified. It's used to construct the Content-Type header.
|
||||
DEFAULT_CHARSET = "utf-8"
|
||||
|
||||
# Email address that error messages come from.
|
||||
SERVER_EMAIL = "root@localhost"
|
||||
|
||||
# Database connection info. If left empty, will default to the dummy backend.
|
||||
DATABASES = {}
|
||||
|
||||
# Classes used to implement DB routing behavior.
|
||||
DATABASE_ROUTERS = []
|
||||
|
||||
# The email backend to use. For possible shortcuts see django.core.mail.
|
||||
# The default is to use the SMTP backend.
|
||||
# Third-party backends can be specified by providing a Python path
|
||||
# to a module that defines an EmailBackend class.
|
||||
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
||||
|
||||
# Host for sending email.
|
||||
EMAIL_HOST = "localhost"
|
||||
|
||||
# Port for sending email.
|
||||
EMAIL_PORT = 25
|
||||
|
||||
# Whether to send SMTP 'Date' header in the local time zone or in UTC.
|
||||
EMAIL_USE_LOCALTIME = False
|
||||
|
||||
# Optional SMTP authentication information for EMAIL_HOST.
|
||||
EMAIL_HOST_USER = ""
|
||||
EMAIL_HOST_PASSWORD = ""
|
||||
EMAIL_USE_TLS = False
|
||||
EMAIL_USE_SSL = False
|
||||
EMAIL_SSL_CERTFILE = None
|
||||
EMAIL_SSL_KEYFILE = None
|
||||
EMAIL_TIMEOUT = None
|
||||
|
||||
# List of strings representing installed apps.
|
||||
INSTALLED_APPS = []
|
||||
|
||||
TEMPLATES = []
|
||||
|
||||
# Default form rendering class.
|
||||
FORM_RENDERER = "django.forms.renderers.DjangoTemplates"
|
||||
|
||||
# RemovedInDjango60Warning: It's a transitional setting helpful in early
|
||||
# adoption of "https" as the new default value of forms.URLField.assume_scheme.
|
||||
# Set to True to assume "https" during the Django 5.x release cycle.
|
||||
FORMS_URLFIELD_ASSUME_HTTPS = False
|
||||
|
||||
# Default email address to use for various automated correspondence from
|
||||
# the site managers.
|
||||
DEFAULT_FROM_EMAIL = "webmaster@localhost"
|
||||
|
||||
# Subject-line prefix for email messages send with django.core.mail.mail_admins
|
||||
# or ...mail_managers. Make sure to include the trailing space.
|
||||
EMAIL_SUBJECT_PREFIX = "[Django] "
|
||||
|
||||
# Whether to append trailing slashes to URLs.
|
||||
APPEND_SLASH = True
|
||||
|
||||
# Whether to prepend the "www." subdomain to URLs that don't have it.
|
||||
PREPEND_WWW = False
|
||||
|
||||
# Override the server-derived value of SCRIPT_NAME
|
||||
FORCE_SCRIPT_NAME = None
|
||||
|
||||
# List of compiled regular expression objects representing User-Agent strings
|
||||
# that are not allowed to visit any page, systemwide. Use this for bad
|
||||
# robots/crawlers. Here are a few examples:
|
||||
# import re
|
||||
# DISALLOWED_USER_AGENTS = [
|
||||
# re.compile(r'^NaverBot.*'),
|
||||
# re.compile(r'^EmailSiphon.*'),
|
||||
# re.compile(r'^SiteSucker.*'),
|
||||
# re.compile(r'^sohu-search'),
|
||||
# ]
|
||||
DISALLOWED_USER_AGENTS = []
|
||||
|
||||
ABSOLUTE_URL_OVERRIDES = {}
|
||||
|
||||
# List of compiled regular expression objects representing URLs that need not
|
||||
# be reported by BrokenLinkEmailsMiddleware. Here are a few examples:
|
||||
# import re
|
||||
# IGNORABLE_404_URLS = [
|
||||
# re.compile(r'^/apple-touch-icon.*\.png$'),
|
||||
# re.compile(r'^/favicon.ico$'),
|
||||
# re.compile(r'^/robots.txt$'),
|
||||
# re.compile(r'^/phpmyadmin/'),
|
||||
# re.compile(r'\.(cgi|php|pl)$'),
|
||||
# ]
|
||||
IGNORABLE_404_URLS = []
|
||||
|
||||
# A secret key for this particular Django installation. Used in secret-key
|
||||
# hashing algorithms. Set this in your settings, or Django will complain
|
||||
# loudly.
|
||||
SECRET_KEY = ""
|
||||
|
||||
# List of secret keys used to verify the validity of signatures. This allows
|
||||
# secret key rotation.
|
||||
SECRET_KEY_FALLBACKS = []
|
||||
|
||||
STORAGES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
||||
},
|
||||
"staticfiles": {
|
||||
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
|
||||
},
|
||||
}
|
||||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/var/www/example.com/media/"
|
||||
MEDIA_ROOT = ""
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT.
|
||||
# Examples: "http://example.com/media/", "http://media.example.com/"
|
||||
MEDIA_URL = ""
|
||||
|
||||
# Absolute path to the directory static files should be collected to.
|
||||
# Example: "/var/www/example.com/static/"
|
||||
STATIC_ROOT = None
|
||||
|
||||
# URL that handles the static files served from STATIC_ROOT.
|
||||
# Example: "http://example.com/static/", "http://static.example.com/"
|
||||
STATIC_URL = None
|
||||
|
||||
# List of upload handler classes to be applied in order.
|
||||
FILE_UPLOAD_HANDLERS = [
|
||||
"django.core.files.uploadhandler.MemoryFileUploadHandler",
|
||||
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
|
||||
]
|
||||
|
||||
# Maximum size, in bytes, of a request before it will be streamed to the
|
||||
# file system instead of into memory.
|
||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 # i.e. 2.5 MB
|
||||
|
||||
# Maximum size in bytes of request data (excluding file uploads) that will be
|
||||
# read before a SuspiciousOperation (RequestDataTooBig) is raised.
|
||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 # i.e. 2.5 MB
|
||||
|
||||
# Maximum number of GET/POST parameters that will be read before a
|
||||
# SuspiciousOperation (TooManyFieldsSent) is raised.
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000
|
||||
|
||||
# Maximum number of files encoded in a multipart upload that will be read
|
||||
# before a SuspiciousOperation (TooManyFilesSent) is raised.
|
||||
DATA_UPLOAD_MAX_NUMBER_FILES = 100
|
||||
|
||||
# Directory in which upload streamed files will be temporarily saved. A value of
|
||||
# `None` will make Django use the operating system's default temporary directory
|
||||
# (i.e. "/tmp" on *nix systems).
|
||||
FILE_UPLOAD_TEMP_DIR = None
|
||||
|
||||
# The numeric mode to set newly-uploaded files to. The value should be a mode
|
||||
# you'd pass directly to os.chmod; see
|
||||
# https://docs.python.org/library/os.html#files-and-directories.
|
||||
FILE_UPLOAD_PERMISSIONS = 0o644
|
||||
|
||||
# The numeric mode to assign to newly-created directories, when uploading files.
|
||||
# The value should be a mode as you'd pass to os.chmod;
|
||||
# see https://docs.python.org/library/os.html#files-and-directories.
|
||||
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
|
||||
|
||||
# Python module path where user will place custom format definition.
|
||||
# The directory where this setting is pointing should contain subdirectories
|
||||
# named as the locales, containing a formats.py file
|
||||
# (i.e. "myproject.locale" for myproject/locale/en/formats.py etc. use)
|
||||
FORMAT_MODULE_PATH = None
|
||||
|
||||
# Default formatting for date objects. See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
DATE_FORMAT = "N j, Y"
|
||||
|
||||
# Default formatting for datetime objects. See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
DATETIME_FORMAT = "N j, Y, P"
|
||||
|
||||
# Default formatting for time objects. See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
TIME_FORMAT = "P"
|
||||
|
||||
# Default formatting for date objects when only the year and month are relevant.
|
||||
# See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
YEAR_MONTH_FORMAT = "F Y"
|
||||
|
||||
# Default formatting for date objects when only the month and day are relevant.
|
||||
# See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
MONTH_DAY_FORMAT = "F j"
|
||||
|
||||
# Default short formatting for date objects. See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
SHORT_DATE_FORMAT = "m/d/Y"
|
||||
|
||||
# Default short formatting for datetime objects.
|
||||
# See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
SHORT_DATETIME_FORMAT = "m/d/Y P"
|
||||
|
||||
# Default formats to be used when parsing dates from input boxes, in order
|
||||
# See all available format string here:
|
||||
# https://docs.python.org/library/datetime.html#strftime-behavior
|
||||
# * Note that these format strings are different from the ones to display dates
|
||||
DATE_INPUT_FORMATS = [
|
||||
"%Y-%m-%d", # '2006-10-25'
|
||||
"%m/%d/%Y", # '10/25/2006'
|
||||
"%m/%d/%y", # '10/25/06'
|
||||
"%b %d %Y", # 'Oct 25 2006'
|
||||
"%b %d, %Y", # 'Oct 25, 2006'
|
||||
"%d %b %Y", # '25 Oct 2006'
|
||||
"%d %b, %Y", # '25 Oct, 2006'
|
||||
"%B %d %Y", # 'October 25 2006'
|
||||
"%B %d, %Y", # 'October 25, 2006'
|
||||
"%d %B %Y", # '25 October 2006'
|
||||
"%d %B, %Y", # '25 October, 2006'
|
||||
]
|
||||
|
||||
# Default formats to be used when parsing times from input boxes, in order
|
||||
# See all available format string here:
|
||||
# https://docs.python.org/library/datetime.html#strftime-behavior
|
||||
# * Note that these format strings are different from the ones to display dates
|
||||
TIME_INPUT_FORMATS = [
|
||||
"%H:%M:%S", # '14:30:59'
|
||||
"%H:%M:%S.%f", # '14:30:59.000200'
|
||||
"%H:%M", # '14:30'
|
||||
]
|
||||
|
||||
# Default formats to be used when parsing dates and times from input boxes,
|
||||
# in order
|
||||
# See all available format string here:
|
||||
# https://docs.python.org/library/datetime.html#strftime-behavior
|
||||
# * Note that these format strings are different from the ones to display dates
|
||||
DATETIME_INPUT_FORMATS = [
|
||||
"%Y-%m-%d %H:%M:%S", # '2006-10-25 14:30:59'
|
||||
"%Y-%m-%d %H:%M:%S.%f", # '2006-10-25 14:30:59.000200'
|
||||
"%Y-%m-%d %H:%M", # '2006-10-25 14:30'
|
||||
"%m/%d/%Y %H:%M:%S", # '10/25/2006 14:30:59'
|
||||
"%m/%d/%Y %H:%M:%S.%f", # '10/25/2006 14:30:59.000200'
|
||||
"%m/%d/%Y %H:%M", # '10/25/2006 14:30'
|
||||
"%m/%d/%y %H:%M:%S", # '10/25/06 14:30:59'
|
||||
"%m/%d/%y %H:%M:%S.%f", # '10/25/06 14:30:59.000200'
|
||||
"%m/%d/%y %H:%M", # '10/25/06 14:30'
|
||||
]
|
||||
|
||||
# First day of week, to be used on calendars
|
||||
# 0 means Sunday, 1 means Monday...
|
||||
FIRST_DAY_OF_WEEK = 0
|
||||
|
||||
# Decimal separator symbol
|
||||
DECIMAL_SEPARATOR = "."
|
||||
|
||||
# Boolean that sets whether to add thousand separator when formatting numbers
|
||||
USE_THOUSAND_SEPARATOR = False
|
||||
|
||||
# Number of digits that will be together, when splitting them by
|
||||
# THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
|
||||
NUMBER_GROUPING = 0
|
||||
|
||||
# Thousand separator symbol
|
||||
THOUSAND_SEPARATOR = ","
|
||||
|
||||
# The tablespaces to use for each model when not specified otherwise.
|
||||
DEFAULT_TABLESPACE = ""
|
||||
DEFAULT_INDEX_TABLESPACE = ""
|
||||
|
||||
# Default primary key field type.
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||
|
||||
# Default X-Frame-Options header value
|
||||
X_FRAME_OPTIONS = "DENY"
|
||||
|
||||
USE_X_FORWARDED_HOST = False
|
||||
USE_X_FORWARDED_PORT = False
|
||||
|
||||
# The Python dotted path to the WSGI application that Django's internal server
|
||||
# (runserver) will use. If `None`, the return value of
|
||||
# 'django.core.wsgi.get_wsgi_application' is used, thus preserving the same
|
||||
# behavior as previous versions of Django. Otherwise this should point to an
|
||||
# actual WSGI application object.
|
||||
WSGI_APPLICATION = None
|
||||
|
||||
# If your Django app is behind a proxy that sets a header to specify secure
|
||||
# connections, AND that proxy ensures that user-submitted headers with the
|
||||
# same name are ignored (so that people can't spoof it), set this value to
|
||||
# a tuple of (header_name, header_value). For any requests that come in with
|
||||
# that header/value, request.is_secure() will return True.
|
||||
# WARNING! Only set this if you fully understand what you're doing. Otherwise,
|
||||
# you may be opening yourself up to a security risk.
|
||||
SECURE_PROXY_SSL_HEADER = None
|
||||
|
||||
##############
|
||||
# MIDDLEWARE #
|
||||
##############
|
||||
|
||||
# List of middleware to use. Order is important; in the request phase, these
|
||||
# middleware will be applied in the order given, and in the response
|
||||
# phase the middleware will be applied in reverse order.
|
||||
MIDDLEWARE = []
|
||||
|
||||
############
|
||||
# SESSIONS #
|
||||
############
|
||||
|
||||
# Cache to store session data if using the cache session backend.
|
||||
SESSION_CACHE_ALIAS = "default"
|
||||
# Cookie name. This can be whatever you want.
|
||||
SESSION_COOKIE_NAME = "sessionid"
|
||||
# Age of cookie, in seconds (default: 2 weeks).
|
||||
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
|
||||
# A string like "example.com", or None for standard domain cookie.
|
||||
SESSION_COOKIE_DOMAIN = None
|
||||
# Whether the session cookie should be secure (https:// only).
|
||||
SESSION_COOKIE_SECURE = False
|
||||
# The path of the session cookie.
|
||||
SESSION_COOKIE_PATH = "/"
|
||||
# Whether to use the HttpOnly flag.
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
# Whether to set the flag restricting cookie leaks on cross-site requests.
|
||||
# This can be 'Lax', 'Strict', 'None', or False to disable the flag.
|
||||
SESSION_COOKIE_SAMESITE = "Lax"
|
||||
# Whether to save the session data on every request.
|
||||
SESSION_SAVE_EVERY_REQUEST = False
|
||||
# Whether a user's session cookie expires when the web browser is closed.
|
||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
|
||||
# The module to store session data
|
||||
SESSION_ENGINE = "django.contrib.sessions.backends.db"
|
||||
# Directory to store session files if using the file session module. If None,
|
||||
# the backend will use a sensible default.
|
||||
SESSION_FILE_PATH = None
|
||||
# class to serialize session data
|
||||
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
|
||||
|
||||
#########
|
||||
# CACHE #
|
||||
#########
|
||||
|
||||
# The cache backends to use.
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
|
||||
}
|
||||
}
|
||||
CACHE_MIDDLEWARE_KEY_PREFIX = ""
|
||||
CACHE_MIDDLEWARE_SECONDS = 600
|
||||
CACHE_MIDDLEWARE_ALIAS = "default"
|
||||
|
||||
##################
|
||||
# AUTHENTICATION #
|
||||
##################
|
||||
|
||||
AUTH_USER_MODEL = "auth.User"
|
||||
|
||||
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]
|
||||
|
||||
LOGIN_URL = "/accounts/login/"
|
||||
|
||||
LOGIN_REDIRECT_URL = "/accounts/profile/"
|
||||
|
||||
LOGOUT_REDIRECT_URL = None
|
||||
|
||||
# The number of seconds a password reset link is valid for (default: 3 days).
|
||||
PASSWORD_RESET_TIMEOUT = 60 * 60 * 24 * 3
|
||||
|
||||
# the first hasher in this list is the preferred algorithm. any
|
||||
# password using different algorithms will be converted automatically
|
||||
# upon login
|
||||
PASSWORD_HASHERS = [
|
||||
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
|
||||
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
|
||||
"django.contrib.auth.hashers.Argon2PasswordHasher",
|
||||
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
|
||||
"django.contrib.auth.hashers.ScryptPasswordHasher",
|
||||
]
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = []
|
||||
|
||||
###########
|
||||
# SIGNING #
|
||||
###########
|
||||
|
||||
SIGNED_COOKIE_LEGACY_SALT_FALLBACK = True
|
||||
SIGNING_BACKEND = "django.core.signing.TimestampSigner"
|
||||
|
||||
########
|
||||
# CSRF #
|
||||
########
|
||||
|
||||
# Dotted path to callable to be used as view when a request is
|
||||
# rejected by the CSRF middleware.
|
||||
CSRF_FAILURE_VIEW = "django.views.csrf.csrf_failure"
|
||||
|
||||
# Settings for CSRF cookie.
|
||||
CSRF_COOKIE_NAME = "csrftoken"
|
||||
CSRF_COOKIE_AGE = 60 * 60 * 24 * 7 * 52
|
||||
CSRF_COOKIE_DOMAIN = None
|
||||
CSRF_COOKIE_PATH = "/"
|
||||
CSRF_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
CSRF_COOKIE_SAMESITE = "Lax"
|
||||
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
|
||||
CSRF_TRUSTED_ORIGINS = []
|
||||
CSRF_USE_SESSIONS = False
|
||||
|
||||
############
|
||||
# MESSAGES #
|
||||
############
|
||||
|
||||
# Class to use as messages backend
|
||||
MESSAGE_STORAGE = "django.contrib.messages.storage.fallback.FallbackStorage"
|
||||
|
||||
# Default values of MESSAGE_LEVEL and MESSAGE_TAGS are defined within
|
||||
# django.contrib.messages to avoid imports in this settings file.
|
||||
|
||||
###########
|
||||
# LOGGING #
|
||||
###########
|
||||
|
||||
# The callable to use to configure logging
|
||||
LOGGING_CONFIG = "logging.config.dictConfig"
|
||||
|
||||
# Custom logging configuration.
|
||||
LOGGING = {}
|
||||
|
||||
# Default exception reporter class used in case none has been
|
||||
# specifically assigned to the HttpRequest instance.
|
||||
DEFAULT_EXCEPTION_REPORTER = "django.views.debug.ExceptionReporter"
|
||||
|
||||
# Default exception reporter filter class used in case none has been
|
||||
# specifically assigned to the HttpRequest instance.
|
||||
DEFAULT_EXCEPTION_REPORTER_FILTER = "django.views.debug.SafeExceptionReporterFilter"
|
||||
|
||||
###########
|
||||
# TESTING #
|
||||
###########
|
||||
|
||||
# The name of the class to use to run the test suite
|
||||
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
||||
|
||||
# Apps that don't need to be serialized at test database creation time
|
||||
# (only apps with migrations are to start with)
|
||||
TEST_NON_SERIALIZED_APPS = []
|
||||
|
||||
############
|
||||
# FIXTURES #
|
||||
############
|
||||
|
||||
# The list of directories to search for fixtures
|
||||
FIXTURE_DIRS = []
|
||||
|
||||
###############
|
||||
# STATICFILES #
|
||||
###############
|
||||
|
||||
# A list of locations of additional static files
|
||||
STATICFILES_DIRS = []
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
STATICFILES_FINDERS = [
|
||||
"django.contrib.staticfiles.finders.FileSystemFinder",
|
||||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
]
|
||||
|
||||
##############
|
||||
# MIGRATIONS #
|
||||
##############
|
||||
|
||||
# Migration module overrides for apps, by app label.
|
||||
MIGRATION_MODULES = {}
|
||||
|
||||
#################
|
||||
# SYSTEM CHECKS #
|
||||
#################
|
||||
|
||||
# List of all issues generated by system checks that should be silenced. Light
|
||||
# issues like warnings, infos or debugs will not generate a message. Silencing
|
||||
# serious issues like errors and criticals does not result in hiding the
|
||||
# message, but Django will not stop you from e.g. running server.
|
||||
SILENCED_SYSTEM_CHECKS = []
|
||||
|
||||
#######################
|
||||
# SECURITY MIDDLEWARE #
|
||||
#######################
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
||||
SECURE_CROSS_ORIGIN_OPENER_POLICY = "same-origin"
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
||||
SECURE_HSTS_PRELOAD = False
|
||||
SECURE_HSTS_SECONDS = 0
|
||||
SECURE_REDIRECT_EXEMPT = []
|
||||
SECURE_REFERRER_POLICY = "same-origin"
|
||||
SECURE_SSL_HOST = None
|
||||
SECURE_SSL_REDIRECT = False
|
||||
629
venv/lib/python3.10/site-packages/django/conf/locale/__init__.py
Normal file
629
venv/lib/python3.10/site-packages/django/conf/locale/__init__.py
Normal file
@@ -0,0 +1,629 @@
|
||||
"""
|
||||
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' fallback logic.
|
||||
"""
|
||||
|
||||
LANG_INFO = {
|
||||
"af": {
|
||||
"bidi": False,
|
||||
"code": "af",
|
||||
"name": "Afrikaans",
|
||||
"name_local": "Afrikaans",
|
||||
},
|
||||
"ar": {
|
||||
"bidi": True,
|
||||
"code": "ar",
|
||||
"name": "Arabic",
|
||||
"name_local": "العربيّة",
|
||||
},
|
||||
"ar-dz": {
|
||||
"bidi": True,
|
||||
"code": "ar-dz",
|
||||
"name": "Algerian Arabic",
|
||||
"name_local": "العربية الجزائرية",
|
||||
},
|
||||
"ast": {
|
||||
"bidi": False,
|
||||
"code": "ast",
|
||||
"name": "Asturian",
|
||||
"name_local": "asturianu",
|
||||
},
|
||||
"az": {
|
||||
"bidi": True,
|
||||
"code": "az",
|
||||
"name": "Azerbaijani",
|
||||
"name_local": "Azərbaycanca",
|
||||
},
|
||||
"be": {
|
||||
"bidi": False,
|
||||
"code": "be",
|
||||
"name": "Belarusian",
|
||||
"name_local": "беларуская",
|
||||
},
|
||||
"bg": {
|
||||
"bidi": False,
|
||||
"code": "bg",
|
||||
"name": "Bulgarian",
|
||||
"name_local": "български",
|
||||
},
|
||||
"bn": {
|
||||
"bidi": False,
|
||||
"code": "bn",
|
||||
"name": "Bengali",
|
||||
"name_local": "বাংলা",
|
||||
},
|
||||
"br": {
|
||||
"bidi": False,
|
||||
"code": "br",
|
||||
"name": "Breton",
|
||||
"name_local": "brezhoneg",
|
||||
},
|
||||
"bs": {
|
||||
"bidi": False,
|
||||
"code": "bs",
|
||||
"name": "Bosnian",
|
||||
"name_local": "bosanski",
|
||||
},
|
||||
"ca": {
|
||||
"bidi": False,
|
||||
"code": "ca",
|
||||
"name": "Catalan",
|
||||
"name_local": "català",
|
||||
},
|
||||
"ckb": {
|
||||
"bidi": True,
|
||||
"code": "ckb",
|
||||
"name": "Central Kurdish (Sorani)",
|
||||
"name_local": "کوردی",
|
||||
},
|
||||
"cs": {
|
||||
"bidi": False,
|
||||
"code": "cs",
|
||||
"name": "Czech",
|
||||
"name_local": "česky",
|
||||
},
|
||||
"cy": {
|
||||
"bidi": False,
|
||||
"code": "cy",
|
||||
"name": "Welsh",
|
||||
"name_local": "Cymraeg",
|
||||
},
|
||||
"da": {
|
||||
"bidi": False,
|
||||
"code": "da",
|
||||
"name": "Danish",
|
||||
"name_local": "dansk",
|
||||
},
|
||||
"de": {
|
||||
"bidi": False,
|
||||
"code": "de",
|
||||
"name": "German",
|
||||
"name_local": "Deutsch",
|
||||
},
|
||||
"dsb": {
|
||||
"bidi": False,
|
||||
"code": "dsb",
|
||||
"name": "Lower Sorbian",
|
||||
"name_local": "dolnoserbski",
|
||||
},
|
||||
"el": {
|
||||
"bidi": False,
|
||||
"code": "el",
|
||||
"name": "Greek",
|
||||
"name_local": "Ελληνικά",
|
||||
},
|
||||
"en": {
|
||||
"bidi": False,
|
||||
"code": "en",
|
||||
"name": "English",
|
||||
"name_local": "English",
|
||||
},
|
||||
"en-au": {
|
||||
"bidi": False,
|
||||
"code": "en-au",
|
||||
"name": "Australian English",
|
||||
"name_local": "Australian English",
|
||||
},
|
||||
"en-gb": {
|
||||
"bidi": False,
|
||||
"code": "en-gb",
|
||||
"name": "British English",
|
||||
"name_local": "British English",
|
||||
},
|
||||
"eo": {
|
||||
"bidi": False,
|
||||
"code": "eo",
|
||||
"name": "Esperanto",
|
||||
"name_local": "Esperanto",
|
||||
},
|
||||
"es": {
|
||||
"bidi": False,
|
||||
"code": "es",
|
||||
"name": "Spanish",
|
||||
"name_local": "español",
|
||||
},
|
||||
"es-ar": {
|
||||
"bidi": False,
|
||||
"code": "es-ar",
|
||||
"name": "Argentinian Spanish",
|
||||
"name_local": "español de Argentina",
|
||||
},
|
||||
"es-co": {
|
||||
"bidi": False,
|
||||
"code": "es-co",
|
||||
"name": "Colombian Spanish",
|
||||
"name_local": "español de Colombia",
|
||||
},
|
||||
"es-mx": {
|
||||
"bidi": False,
|
||||
"code": "es-mx",
|
||||
"name": "Mexican Spanish",
|
||||
"name_local": "español de Mexico",
|
||||
},
|
||||
"es-ni": {
|
||||
"bidi": False,
|
||||
"code": "es-ni",
|
||||
"name": "Nicaraguan Spanish",
|
||||
"name_local": "español de Nicaragua",
|
||||
},
|
||||
"es-ve": {
|
||||
"bidi": False,
|
||||
"code": "es-ve",
|
||||
"name": "Venezuelan Spanish",
|
||||
"name_local": "español de Venezuela",
|
||||
},
|
||||
"et": {
|
||||
"bidi": False,
|
||||
"code": "et",
|
||||
"name": "Estonian",
|
||||
"name_local": "eesti",
|
||||
},
|
||||
"eu": {
|
||||
"bidi": False,
|
||||
"code": "eu",
|
||||
"name": "Basque",
|
||||
"name_local": "Basque",
|
||||
},
|
||||
"fa": {
|
||||
"bidi": True,
|
||||
"code": "fa",
|
||||
"name": "Persian",
|
||||
"name_local": "فارسی",
|
||||
},
|
||||
"fi": {
|
||||
"bidi": False,
|
||||
"code": "fi",
|
||||
"name": "Finnish",
|
||||
"name_local": "suomi",
|
||||
},
|
||||
"fr": {
|
||||
"bidi": False,
|
||||
"code": "fr",
|
||||
"name": "French",
|
||||
"name_local": "français",
|
||||
},
|
||||
"fy": {
|
||||
"bidi": False,
|
||||
"code": "fy",
|
||||
"name": "Frisian",
|
||||
"name_local": "frysk",
|
||||
},
|
||||
"ga": {
|
||||
"bidi": False,
|
||||
"code": "ga",
|
||||
"name": "Irish",
|
||||
"name_local": "Gaeilge",
|
||||
},
|
||||
"gd": {
|
||||
"bidi": False,
|
||||
"code": "gd",
|
||||
"name": "Scottish Gaelic",
|
||||
"name_local": "Gàidhlig",
|
||||
},
|
||||
"gl": {
|
||||
"bidi": False,
|
||||
"code": "gl",
|
||||
"name": "Galician",
|
||||
"name_local": "galego",
|
||||
},
|
||||
"he": {
|
||||
"bidi": True,
|
||||
"code": "he",
|
||||
"name": "Hebrew",
|
||||
"name_local": "עברית",
|
||||
},
|
||||
"hi": {
|
||||
"bidi": False,
|
||||
"code": "hi",
|
||||
"name": "Hindi",
|
||||
"name_local": "हिंदी",
|
||||
},
|
||||
"hr": {
|
||||
"bidi": False,
|
||||
"code": "hr",
|
||||
"name": "Croatian",
|
||||
"name_local": "Hrvatski",
|
||||
},
|
||||
"hsb": {
|
||||
"bidi": False,
|
||||
"code": "hsb",
|
||||
"name": "Upper Sorbian",
|
||||
"name_local": "hornjoserbsce",
|
||||
},
|
||||
"hu": {
|
||||
"bidi": False,
|
||||
"code": "hu",
|
||||
"name": "Hungarian",
|
||||
"name_local": "Magyar",
|
||||
},
|
||||
"hy": {
|
||||
"bidi": False,
|
||||
"code": "hy",
|
||||
"name": "Armenian",
|
||||
"name_local": "հայերեն",
|
||||
},
|
||||
"ia": {
|
||||
"bidi": False,
|
||||
"code": "ia",
|
||||
"name": "Interlingua",
|
||||
"name_local": "Interlingua",
|
||||
},
|
||||
"io": {
|
||||
"bidi": False,
|
||||
"code": "io",
|
||||
"name": "Ido",
|
||||
"name_local": "ido",
|
||||
},
|
||||
"id": {
|
||||
"bidi": False,
|
||||
"code": "id",
|
||||
"name": "Indonesian",
|
||||
"name_local": "Bahasa Indonesia",
|
||||
},
|
||||
"ig": {
|
||||
"bidi": False,
|
||||
"code": "ig",
|
||||
"name": "Igbo",
|
||||
"name_local": "Asụsụ Ìgbò",
|
||||
},
|
||||
"is": {
|
||||
"bidi": False,
|
||||
"code": "is",
|
||||
"name": "Icelandic",
|
||||
"name_local": "Íslenska",
|
||||
},
|
||||
"it": {
|
||||
"bidi": False,
|
||||
"code": "it",
|
||||
"name": "Italian",
|
||||
"name_local": "italiano",
|
||||
},
|
||||
"ja": {
|
||||
"bidi": False,
|
||||
"code": "ja",
|
||||
"name": "Japanese",
|
||||
"name_local": "日本語",
|
||||
},
|
||||
"ka": {
|
||||
"bidi": False,
|
||||
"code": "ka",
|
||||
"name": "Georgian",
|
||||
"name_local": "ქართული",
|
||||
},
|
||||
"kab": {
|
||||
"bidi": False,
|
||||
"code": "kab",
|
||||
"name": "Kabyle",
|
||||
"name_local": "taqbaylit",
|
||||
},
|
||||
"kk": {
|
||||
"bidi": False,
|
||||
"code": "kk",
|
||||
"name": "Kazakh",
|
||||
"name_local": "Қазақ",
|
||||
},
|
||||
"km": {
|
||||
"bidi": False,
|
||||
"code": "km",
|
||||
"name": "Khmer",
|
||||
"name_local": "Khmer",
|
||||
},
|
||||
"kn": {
|
||||
"bidi": False,
|
||||
"code": "kn",
|
||||
"name": "Kannada",
|
||||
"name_local": "Kannada",
|
||||
},
|
||||
"ko": {
|
||||
"bidi": False,
|
||||
"code": "ko",
|
||||
"name": "Korean",
|
||||
"name_local": "한국어",
|
||||
},
|
||||
"ky": {
|
||||
"bidi": False,
|
||||
"code": "ky",
|
||||
"name": "Kyrgyz",
|
||||
"name_local": "Кыргызча",
|
||||
},
|
||||
"lb": {
|
||||
"bidi": False,
|
||||
"code": "lb",
|
||||
"name": "Luxembourgish",
|
||||
"name_local": "Lëtzebuergesch",
|
||||
},
|
||||
"lt": {
|
||||
"bidi": False,
|
||||
"code": "lt",
|
||||
"name": "Lithuanian",
|
||||
"name_local": "Lietuviškai",
|
||||
},
|
||||
"lv": {
|
||||
"bidi": False,
|
||||
"code": "lv",
|
||||
"name": "Latvian",
|
||||
"name_local": "latviešu",
|
||||
},
|
||||
"mk": {
|
||||
"bidi": False,
|
||||
"code": "mk",
|
||||
"name": "Macedonian",
|
||||
"name_local": "Македонски",
|
||||
},
|
||||
"ml": {
|
||||
"bidi": False,
|
||||
"code": "ml",
|
||||
"name": "Malayalam",
|
||||
"name_local": "മലയാളം",
|
||||
},
|
||||
"mn": {
|
||||
"bidi": False,
|
||||
"code": "mn",
|
||||
"name": "Mongolian",
|
||||
"name_local": "Mongolian",
|
||||
},
|
||||
"mr": {
|
||||
"bidi": False,
|
||||
"code": "mr",
|
||||
"name": "Marathi",
|
||||
"name_local": "मराठी",
|
||||
},
|
||||
"ms": {
|
||||
"bidi": False,
|
||||
"code": "ms",
|
||||
"name": "Malay",
|
||||
"name_local": "Bahasa Melayu",
|
||||
},
|
||||
"my": {
|
||||
"bidi": False,
|
||||
"code": "my",
|
||||
"name": "Burmese",
|
||||
"name_local": "မြန်မာဘာသာ",
|
||||
},
|
||||
"nb": {
|
||||
"bidi": False,
|
||||
"code": "nb",
|
||||
"name": "Norwegian Bokmal",
|
||||
"name_local": "norsk (bokmål)",
|
||||
},
|
||||
"ne": {
|
||||
"bidi": False,
|
||||
"code": "ne",
|
||||
"name": "Nepali",
|
||||
"name_local": "नेपाली",
|
||||
},
|
||||
"nl": {
|
||||
"bidi": False,
|
||||
"code": "nl",
|
||||
"name": "Dutch",
|
||||
"name_local": "Nederlands",
|
||||
},
|
||||
"nn": {
|
||||
"bidi": False,
|
||||
"code": "nn",
|
||||
"name": "Norwegian Nynorsk",
|
||||
"name_local": "norsk (nynorsk)",
|
||||
},
|
||||
"no": {
|
||||
"bidi": False,
|
||||
"code": "no",
|
||||
"name": "Norwegian",
|
||||
"name_local": "norsk",
|
||||
},
|
||||
"os": {
|
||||
"bidi": False,
|
||||
"code": "os",
|
||||
"name": "Ossetic",
|
||||
"name_local": "Ирон",
|
||||
},
|
||||
"pa": {
|
||||
"bidi": False,
|
||||
"code": "pa",
|
||||
"name": "Punjabi",
|
||||
"name_local": "Punjabi",
|
||||
},
|
||||
"pl": {
|
||||
"bidi": False,
|
||||
"code": "pl",
|
||||
"name": "Polish",
|
||||
"name_local": "polski",
|
||||
},
|
||||
"pt": {
|
||||
"bidi": False,
|
||||
"code": "pt",
|
||||
"name": "Portuguese",
|
||||
"name_local": "Português",
|
||||
},
|
||||
"pt-br": {
|
||||
"bidi": False,
|
||||
"code": "pt-br",
|
||||
"name": "Brazilian Portuguese",
|
||||
"name_local": "Português Brasileiro",
|
||||
},
|
||||
"ro": {
|
||||
"bidi": False,
|
||||
"code": "ro",
|
||||
"name": "Romanian",
|
||||
"name_local": "Română",
|
||||
},
|
||||
"ru": {
|
||||
"bidi": False,
|
||||
"code": "ru",
|
||||
"name": "Russian",
|
||||
"name_local": "Русский",
|
||||
},
|
||||
"sk": {
|
||||
"bidi": False,
|
||||
"code": "sk",
|
||||
"name": "Slovak",
|
||||
"name_local": "slovensky",
|
||||
},
|
||||
"sl": {
|
||||
"bidi": False,
|
||||
"code": "sl",
|
||||
"name": "Slovenian",
|
||||
"name_local": "Slovenščina",
|
||||
},
|
||||
"sq": {
|
||||
"bidi": False,
|
||||
"code": "sq",
|
||||
"name": "Albanian",
|
||||
"name_local": "shqip",
|
||||
},
|
||||
"sr": {
|
||||
"bidi": False,
|
||||
"code": "sr",
|
||||
"name": "Serbian",
|
||||
"name_local": "српски",
|
||||
},
|
||||
"sr-latn": {
|
||||
"bidi": False,
|
||||
"code": "sr-latn",
|
||||
"name": "Serbian Latin",
|
||||
"name_local": "srpski (latinica)",
|
||||
},
|
||||
"sv": {
|
||||
"bidi": False,
|
||||
"code": "sv",
|
||||
"name": "Swedish",
|
||||
"name_local": "svenska",
|
||||
},
|
||||
"sw": {
|
||||
"bidi": False,
|
||||
"code": "sw",
|
||||
"name": "Swahili",
|
||||
"name_local": "Kiswahili",
|
||||
},
|
||||
"ta": {
|
||||
"bidi": False,
|
||||
"code": "ta",
|
||||
"name": "Tamil",
|
||||
"name_local": "தமிழ்",
|
||||
},
|
||||
"te": {
|
||||
"bidi": False,
|
||||
"code": "te",
|
||||
"name": "Telugu",
|
||||
"name_local": "తెలుగు",
|
||||
},
|
||||
"tg": {
|
||||
"bidi": False,
|
||||
"code": "tg",
|
||||
"name": "Tajik",
|
||||
"name_local": "тоҷикӣ",
|
||||
},
|
||||
"th": {
|
||||
"bidi": False,
|
||||
"code": "th",
|
||||
"name": "Thai",
|
||||
"name_local": "ภาษาไทย",
|
||||
},
|
||||
"tk": {
|
||||
"bidi": False,
|
||||
"code": "tk",
|
||||
"name": "Turkmen",
|
||||
"name_local": "Türkmençe",
|
||||
},
|
||||
"tr": {
|
||||
"bidi": False,
|
||||
"code": "tr",
|
||||
"name": "Turkish",
|
||||
"name_local": "Türkçe",
|
||||
},
|
||||
"tt": {
|
||||
"bidi": False,
|
||||
"code": "tt",
|
||||
"name": "Tatar",
|
||||
"name_local": "Татарча",
|
||||
},
|
||||
"udm": {
|
||||
"bidi": False,
|
||||
"code": "udm",
|
||||
"name": "Udmurt",
|
||||
"name_local": "Удмурт",
|
||||
},
|
||||
"ug": {
|
||||
"bidi": True,
|
||||
"code": "ug",
|
||||
"name": "Uyghur",
|
||||
"name_local": "ئۇيغۇرچە",
|
||||
},
|
||||
"uk": {
|
||||
"bidi": False,
|
||||
"code": "uk",
|
||||
"name": "Ukrainian",
|
||||
"name_local": "Українська",
|
||||
},
|
||||
"ur": {
|
||||
"bidi": True,
|
||||
"code": "ur",
|
||||
"name": "Urdu",
|
||||
"name_local": "اردو",
|
||||
},
|
||||
"uz": {
|
||||
"bidi": False,
|
||||
"code": "uz",
|
||||
"name": "Uzbek",
|
||||
"name_local": "oʻzbek tili",
|
||||
},
|
||||
"vi": {
|
||||
"bidi": False,
|
||||
"code": "vi",
|
||||
"name": "Vietnamese",
|
||||
"name_local": "Tiếng Việt",
|
||||
},
|
||||
"zh-cn": {
|
||||
"fallback": ["zh-hans"],
|
||||
},
|
||||
"zh-hans": {
|
||||
"bidi": False,
|
||||
"code": "zh-hans",
|
||||
"name": "Simplified Chinese",
|
||||
"name_local": "简体中文",
|
||||
},
|
||||
"zh-hant": {
|
||||
"bidi": False,
|
||||
"code": "zh-hant",
|
||||
"name": "Traditional Chinese",
|
||||
"name_local": "繁體中文",
|
||||
},
|
||||
"zh-hk": {
|
||||
"fallback": ["zh-hant"],
|
||||
},
|
||||
"zh-mo": {
|
||||
"fallback": ["zh-hant"],
|
||||
},
|
||||
"zh-my": {
|
||||
"fallback": ["zh-hans"],
|
||||
},
|
||||
"zh-sg": {
|
||||
"fallback": ["zh-hans"],
|
||||
},
|
||||
"zh-tw": {
|
||||
"fallback": ["zh-hant"],
|
||||
},
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
# 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 F، Y"
|
||||
TIME_FORMAT = "g:i A"
|
||||
# DATETIME_FORMAT =
|
||||
YEAR_MONTH_FORMAT = "F Y"
|
||||
MONTH_DAY_FORMAT = "j F"
|
||||
SHORT_DATE_FORMAT = "d/m/Y"
|
||||
# SHORT_DATETIME_FORMAT =
|
||||
# FIRST_DAY_OF_WEEK =
|
||||
|
||||
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
|
||||
# see https://docs.python.org/library/datetime.html#strftime-strptime-behavior
|
||||
# DATE_INPUT_FORMATS =
|
||||
# TIME_INPUT_FORMATS =
|
||||
# DATETIME_INPUT_FORMATS =
|
||||
DECIMAL_SEPARATOR = ","
|
||||
THOUSAND_SEPARATOR = "."
|
||||
# NUMBER_GROUPING =
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
# 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 F Y"
|
||||
TIME_FORMAT = "H:i"
|
||||
DATETIME_FORMAT = "j F Y H:i"
|
||||
YEAR_MONTH_FORMAT = "F Y"
|
||||
MONTH_DAY_FORMAT = "j F"
|
||||
SHORT_DATE_FORMAT = "j F Y"
|
||||
SHORT_DATETIME_FORMAT = "j F Y H:i"
|
||||
FIRST_DAY_OF_WEEK = 0 # Sunday
|
||||
|
||||
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
|
||||
# see https://docs.python.org/library/datetime.html#strftime-strptime-behavior
|
||||
DATE_INPUT_FORMATS = [
|
||||
"%Y/%m/%d", # '2006/10/25'
|
||||
]
|
||||
TIME_INPUT_FORMATS = [
|
||||
"%H:%M", # '14:30
|
||||
"%H:%M:%S", # '14:30:59'
|
||||
]
|
||||
DATETIME_INPUT_FORMATS = [
|
||||
"%Y/%m/%d %H:%M", # '2006/10/25 14:30'
|
||||
"%Y/%m/%d %H:%M:%S", # '2006/10/25 14:30:59'
|
||||
]
|
||||
DECIMAL_SEPARATOR = ","
|
||||
THOUSAND_SEPARATOR = "."
|
||||
NUMBER_GROUPING = 3
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user