403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/django/utils/translation/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/django/utils/translation/__pycache__/trans_real.cpython-311.pyc
�

48zjDW����dZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZdd
lmZmZiae	��Zda dZ!dZ"edej#��Z$edej%��Z&ed��Z'ee��d���Z(Gd�d��Z)Gd�dej*��Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Zd �Z3d!�Z4d"�Z5d#�Z6d$�Z7d%�Z8d&�Z9ej:d'�(��d)���Z;ej:��d*���Z<ej:d'�(��d1d,���Z=d1d-�Z>d1d.�Z?ej:d'�(��d/���Z@d0�ZAdS)2zTranslation helper functions.�N)�Local)�apps)�settings)�	LANG_INFO)�AppRegistryNotReady)�setting_changed)�receiver)�_lazy_re_compile)�SafeData�	mark_safe�)�to_language�	to_locale�i�a
        ([A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*|\*)      # "en", "en-au", "x-y-z", "es-419", "*"
        (?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:\.0{,3})?))?  # Optional "q=1.00", "q=0.8"
        (?:\s*,\s*|$)                                 # Multiple accepts per header.
        z3^[a-z]{1,8}(?:-[a-z0-9]{1,8})*(?:@[a-z0-9]{1,20})?$z^/(\w+([@-]\w+)?)(/|$)c��|ddvrMt���t���t���dSdS)zy
    Reset global state when LANGUAGES setting has been changed, as some
    languages should no longer be accepted.
    �setting)�	LANGUAGES�
LANGUAGE_CODEN)�translation_catalog_exists�cache_clear�
get_languages�get_supported_language_variant)�kwargss �E/usr/lib/python3/dist-packages/django/utils/translation/trans_real.py�reset_cacher8sY���i��:�:�:�"�.�.�0�0�0��!�!�#�#�#�&�2�2�4�4�4�4�4�;�:�c�L�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
dd
�Zd�ZdS)
�TranslationCatalogz�
    Simulate a dict for DjangoTranslation._catalog so as multiple catalogs
    with different plural equations are kept separate.
    Nc�t�|r|j���gnig|_|r|jgnd�g|_dS)Nc�(�t|dk��S�Nr
��int��ns r�<lambda>z-TranslationCatalog.__init__.<locals>.<lambda>Ks���A��F���r)�_catalog�copy�	_catalogs�plural�_plurals)�self�transs  r�__init__zTranslationCatalog.__init__IsE��49�C�%�.�-�-�/�/�0�0��t���*/�L�����6K�6K�5L��
�
�
rc�h�|jD]}	||cS#t$rY�wxYwt|����N)r)�KeyError)r,�key�cats   r�__getitem__zTranslationCatalog.__getitem__MsQ���>�	�	�C�
��3�x������
�
�
���
�����s�m�m�s��
"�"c�&�||jd|<dS�Nr)r))r,r2�values   r�__setitem__zTranslationCatalog.__setitem__Us��!&���q��#���rc�D��t�fd�|jD����S)Nc3� �K�|]}�|vV��	dSr0�)�.0r3r2s  �r�	<genexpr>z2TranslationCatalog.__contains__.<locals>.<genexpr>Ys'�����8�8�#�3�#�:�8�8�8�8�8�8r)�anyr))r,r2s `r�__contains__zTranslationCatalog.__contains__Xs(����8�8�8�8���8�8�8�8�8�8rc#�RK�|jD]}|���Ed{V���dSr0)r)�items�r,r3s  rrAzTranslationCatalog.items[sD�����>�	#�	#�C��y�y�{�{�"�"�"�"�"�"�"�"�	#�	#rc#�RK�|jD]}|���Ed{V���dSr0)r)�keysrBs  rrDzTranslationCatalog.keys_sD�����>�	"�	"�C��x�x�z�z�!�!�!�!�!�!�!�!�	"�	"rc�N�t|j|j��D]7\}}|jj|jkr|�|j��dS�8|j�d|j�����|j�d|j��dSr6)	�zipr)r+r*�__code__�updater'�insertr()r,r-r3r*s    rrHzTranslationCatalog.updatecs����t�~�t�}�=�=�	2�	2�K�C���|�$���7�7��
�
�5�>�*�*�*����8�
�N�!�!�!�U�^�%8�%8�%:�%:�;�;�;��M� � ��E�L�1�1�1�1�1rc�r�t��}|jD] }|�||��}||ur|cS�!|Sr0)�objectr)�get)r,r2�default�missingr3�results      rrLzTranslationCatalog.getmsM���(�(���>�	�	�C��W�W�S�'�*�*�F��W�$�$��
�
�
�%��rc��t|j|j��D]+\}}|�|||��f��}|�|cS�,t�r0)rFr)r+rLr1)r,�msgid�numr3r*�tmsgs      rr*zTranslationCatalog.pluralusZ���t�~�t�}�=�=�	�	�K�C���7�7�E�6�6�#�;�;�/�0�0�D������� ��rr0)
�__name__�
__module__�__qualname__�__doc__r.r4r8r?rArDrHrLr*r;rrrrDs���������M�M�M�M����'�'�'�9�9�9�#�#�#�"�"�"�2�2�2���������rrc�^�eZdZdZdZdd�Zd�Zdd�Zd�Zd	�Z	d
�Z
dd�Zd�Zd
�Z
d�Zd�ZdS)�DjangoTranslationa]
    Set up the GNUTranslations context with regard to output charset.

    This translation object will be constructed out of multiple GNUTranslations
    objects by merging their catalogs. It will construct an object for the
    requested language and add a fallback to the default language, if it's
    different from the requested language.
    �djangoNc���tj�|��|�||_||_t|��|_t|��|_d|_	d�|_
|jdkr2|�tjdt��d}|���|r0|D],}|�|��}|�|���-n|���|���|jt&jkr.|jdkr#|j	�t+dt&jz���|�|��|j	�t/��|_	dSdS)z8Create a GNUTranslations() using many locale directoriesNc�(�t|dk��Sr!r"r$s rr&z,DjangoTranslation.__init__.<locals>.<lambda>�s���A��F���rrZz.localedirs is ignored when domain is 'django'.z3No translation files found for default language %s.)�gettext_module�GNUTranslationsr.�domain�_DjangoTranslation__languager�_DjangoTranslation__to_languager�_DjangoTranslation__localer'r*�warnings�warn�RuntimeWarning�_init_translation_catalog�_new_gnu_trans�merge� _add_installed_apps_translations�_add_local_translationsrr�OSError�
_add_fallbackr)r,�languager_�
localedirs�	localedir�translations      rr.zDjangoTranslation.__init__�sy���&�/�/��5�5�5��� �D�K�"���(��2�2���!�(�+�+��
���
�,�+����;�(�"�"��%��
�N�P^�_�_�_�!�
��*�*�,�,�,��	4�'�
(�
(�	�"�1�1�)�<�<���
�
�;�'�'�'�'�
(�
�1�1�3�3�3��$�$�&�&�&��?�h�4�4�4����9P�9P�UY�Ub�Uj��O�RZ�Rh�h�i�i�i����:�&�&�&��=� �.�0�0�D�M�M�M�!� rc��d|jzS)Nz<DjangoTranslation lang:%s>�r`�r,s r�__repr__zDjangoTranslation.__repr__�s��,�t��>�>rTc�H�tj|j||jg|���S)z�
        Return a mergeable gettext.GNUTranslations instance.

        A convenience wrapper. By default gettext uses 'fallback=False'.
        Using param `use_null_fallback` to avoid confusion with any other
        references to 'fallback'.
        )r_ro�	languages�fallback)r]rpr_rb)r,ro�use_null_fallbacks   rrgz DjangoTranslation._new_gnu_trans�s0���)��;���}�o�&�	
�
�
�	
rc��tjtjj}t
j�t
j�|��d��}|�	|��}|�
|��dS)z7Create a base catalog using global django translations.�localeN)�sys�modulesrrU�__file__�os�path�join�dirnamergrh)r,�settingsfilerorps    rrfz+DjangoTranslation._init_translation_catalog�sb���{�8�#6�7�@���G�L�L������!>�!>��I�I�	��)�)�)�4�4���
�
�;�����rc��	tttj������}n#t$rt	d���wxYw|D]p}t
j�|jd��}t
j�|��r*|�	|��}|�
|���qdS)z+Merge translations from each installed app.z�The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.rzN)�reversed�listr�get_app_configsrr~rr��existsrgrh)r,�app_configs�
app_configrorps     rriz2DjangoTranslation._add_installed_apps_translations�s���	1�"�4��(<�(>�(>�#?�#?�@�@�K�K��"�	1�	1�	1�%�0�1�1�
1�	1����
&�	(�	(�J�����Z�_�h�?�?�I��w�~�~�i�(�(�
(�"�1�1�)�<�<���
�
�;�'�'�'��		(�	(s	�-0�A
c��ttj��D],}|�|��}|�|���-dS)z+Merge translations defined in LOCALE_PATHS.N)r�r�LOCALE_PATHSrgrh)r,rorps   rrjz)DjangoTranslation._add_local_translations�sN��!�(�"7�8�8�	$�	$�I��-�-�i�8�8�K��J�J�{�#�#�#�#�	$�	$rc��|jtjks|j�d��rdS|jdkrttj��}n!t
tj|j|���}|�|��dS)z=Set the GNUTranslations() fallback with the default language.�enNrZ)r_rn)r`rr�
startswithr_rprY�add_fallback)r,rn�default_translations   rrlzDjangoTranslation._add_fallback�s����?�h�4�4�4���8R�8R�SW�8X�8X�4��F��;�(�"�"�"-�h�.D�"E�"E���"3��&�t�{�z�#�#�#��	
���-�.�.�.�.�.rc�2�t|dd��sdS|j�?|j|_|j���|_t|��|_n|j�|��|jr|�|j��dSdS)z,Merge another translation into this catalog.r'N)	�getattrr'r*�_infor(rrH�	_fallbackr�)r,�others  rrhzDjangoTranslation.merge�s����u�j�$�/�/�	��F��=� ��,�D�K���)�)�+�+�D�J�.�u�5�5�D�M�M��M� � ��'�'�'��?�	/����e�o�.�.�.�.�.�	/�	/rc��|jS)z Return the translation language.rrrss rrmzDjangoTranslation.language�s
����rc��|jS)z%Return the translation language name.)rarss rrzDjangoTranslation.to_language�s���!�!rc��	|j�||��}n@#t$r3|jr|j�|||��cYS|dkr|}n|}YnwxYw|Sr!)r'r*r1r��ngettext)r,�msgid1�msgid2r%rSs     rr�zDjangoTranslation.ngettexts���	��=�'�'���2�2�D�D���	�	�	��~�
B��~�.�.�v�v�q�A�A�A�A�A��A�v�v��������
	�����s��-A�
A�A)NN)Tr0)rTrUrVrWr_r.rtrgrfrirjrlrhrmrr�r;rrrYrY}s����������F�#1�#1�#1�#1�J?�?�?�

�

�

�

� � � �
(�
(�
(�$�$�$�
/�
/�
/�
/�/�/�/����"�"�"�
�
�
�
�
rrYc�\�|tvrt|��t|<t|S)zE
    Return a translation object in the default 'django' domain.
    )�
_translationsrY�rms rrprp
s,��
�}�$�$�"3�H�"=�"=�
�h����"�"rc�@�|sdSt|��t_dS)z�
    Fetch the translation object for a given language and install it as the
    current translation object for the current thread.
    N)rp�_activer7r�s r�activater�s$��
������)�)�G�M�M�Mrc�B�ttd��r	t`dSdS)zz
    Uninstall the active translation object so that further _() calls resolve
    to the default translation object.
    r7N)�hasattrr�r7r;rr�
deactivater�!s)��
�w�� � ���M�M�M��rc�d�tj��t_d�tj_dS)z�
    Make the active translation object a NullTranslations() instance. This is
    useful when we want delayed translations to appear as the original string
    for some reason.
    c��dSr0r;)�argss rr&z deactivate_all.<locals>.<lambda>1s��d�rN)r]�NullTranslationsr�r7rr;rr�deactivate_allr�*s'��#�3�5�5�G�M� 2� 2�G�M���rc��ttdd��}|�%	|���S#t$rYnwxYwtjS)z'Return the currently selected language.r7N)r�r�r�AttributeErrorrr��ts r�get_languager�4sV�����$�'�'�A��}�	��=�=�?�?�"���	�	�	��D�	�����!�!s�.�
;�;c��t��}|�dSt���d��d}|tjvS)zw
    Return selected language's BiDi layout.

    * False = left-to-right layout
    * True = right-to-left layout
    NF�-r)r��splitr�LANGUAGES_BIDI)�lang�	base_langs  r�get_language_bidir�@sA���>�>�D��|��u� �N�N�(�(��-�-�a�0�	��H�3�3�3rc��ttdd��}|�|St�ttj��atS)z�
    Return the current active catalog for further processing.
    This can be used if you need to modify the catalog or want to access the
    whole message catalog instead of just translating one string.
    r7N�r�r��_defaultrprrr�s r�catalogr�Os:��	���$�'�'�A��}������x�5�6�6���Orc�x�|�dd���dd��}|rQtpttj��attdt��}|�|��}nt|��d��}t|t��rt|��S|S)z�
    Translate the 'message' string. It uses the current thread to find the
    translation object to use. If no current translation is activated, the
    message will be run through the default translation object.
    z
�
�
r7�)�replacer�rprrr�r��gettext�type�
isinstancerr)�message�eol_message�translation_objectrOs    rr�r�_s����/�/�&�$�/�/�7�7��d�C�C�K��#��B�{�8�+A�B�B��$�W�g�x�@�@��#�+�+�K�8�8�����g���r�"�"���'�8�$�$�!��� � � ��Mrc��|�t�|��}t|��}t|vr|}n$t|t��rt	|��}|Sr0)�CONTEXT_SEPARATORr�r�rr)�contextr��
msg_with_ctxtrOs    r�pgettextr�ysY�� '��):�):�G�G�D�M�
�]�
#�
#�F��F�"�"����	�G�X�	&�	&�#��6�"�"���Mrc��|S)z�
    Mark strings for translation but don't translate them now. This can be
    used to store strings in global variables that should stay in the base
    language (because they might be used externally) and will be translated
    later.
    r;)r�s r�gettext_noopr��s	���Nrc���ttdd��}|�t||��|||��St�ttj��att|��|||��S)Nr7r�)�singularr*�number�translation_functionr�s     r�
do_ntranslater��sn��	���$�'�'�A��}�/�w�q�.�/�/��&�&�I�I�I����x�5�6�6��2�7�8�1�2�2�8�V�V�L�L�Lrc�&�t|||d��S)zg
    Return a string of the translation of either the singular or plural,
    based on the number.
    r�)r�)r�r*r�s   rr�r��s��
��6�6�:�>�>�>rc��|�t�|��|�t�|��|f}t|�}t|vrt|||��}|Sr0)r�r�)r�r�r*r��msgs_with_ctxtrOs      r�	npgettextr��s]��")�'�+<�+<�h�h�G�")�'�+<�+<�f�f�E���N��~�
&�F��F�"�"��(�F�F�3�3���Mrc��tj�tj�tjtjj��d��}g}tj
��D][}tj�|jd��}tj�|��r|�|���\|gtj
�|�S)zB
    Return a list of paths to user-provides languages files.
    rz)r~rr�r�r{r|rrUr}rr�r��appendr�)�
globalpath�	app_pathsr��locale_paths    r�all_locale_pathsr��s�������
������H�$7�8�A�B�B�H�N�N�J��I��*�,�,�*�*�
��g�l�l�:�?�H�=�=��
�7�>�>�+�&�&�	*����[�)�)�)���;��.�;��;�;rc�X�|�t|��tkrdSt|��S)a+
    Check whether there is a global language file for the given language
    code. This is used to decide whether a user-provided language is
    available.

    Reject over-length codes before the cached lookup so that oversized,
    attacker-controlled values are not retained as cache keys.
    NF)�len�LANGUAGE_CODE_MAX_LENGTHr��	lang_codes r�check_for_languager��s.����C�	�N�N�-E�E�E��u�%�i�0�0�0ri�)�maxsizec���t����sdSt�fd�t��D����S)z�Return whether a translation catalog exists for the given language code.

    lru_cache should have a maxsize to prevent memory exhaustion attacks. See:
    <https://www.djangoproject.com/weblog/2007/oct/26/security-fix/>.
    Fc3�d�K�|]*}tjd|t���g��duV��+dS)rZN)r]�findr)r<rr�s  �rr=z-translation_catalog_exists.<locals>.<genexpr>�sV��������	��H�d�Y�y�-A�-A�,B�C�C�4�O������r)�language_code_re�searchr>r�r�s`rrr�s^����"�"�9�-�-���u������$�&�&������rc�4�ttj��S)zN
    Cache of settings.LANGUAGES in a dictionary for easy lookups by key.
    )�dictrrr;rrrr�s��
��"�#�#�#rFc�B�|�rt|��tkr>|�ddt��}|s|dkr|d|�}ntd���|g}	|�t
|d��n#t$rYnwxYw|�d��d}|�|��t��}|D]}||vrt|��r|cS�|s!|D]}|�|dz��r|cS�t|���)a}
    Return the language code that's listed in supported languages, possibly
    selecting a more generic variant. Raise LookupError if nothing is found.

    If `strict` is False (the default), look for a country-specific variant
    when neither the language code nor its generic variant is found.

    The language code is truncated to a maximum length to avoid potential
    denial of service attacks.

    lru_cache should have a maxsize to prevent from memory exhaustion attacks,
    as the provided language codes are taken from the HTTP request. See also
    <https://www.djangoproject.com/weblog/2007/oct/26/security-fix/>.
    r�rNz/'lang_code' exceeds the maximum accepted lengthrw)
r�r��rfind�
ValueError�extendrr1r�r�rr�r��LookupError)r��strict�index�possible_lang_codes�generic_lang_code�supported_lang_codes�code�supported_codes        rrr�so�� �*��y�>�>�4�4�4��O�O�C��,D�E�E�E��
T�e�a�i�i�%�f�u�f�-�	�	� �!R�S�S�S�(�k��	��&�&�y��';�J�'G�H�H�H�H���	�	�	��D�	����%�O�O�C�0�0��3���"�"�#4�5�5�5�,����'�	�	�D��+�+�+�0B�4�0H�0H�+�������	*�"6�
*�
*��!�,�,�->��-D�E�E�*�)�)�)�)�*�
�i�
 �
 � s�&B�
B�Bc��t�|��}|sdS|d}	t||���S#t$rYdSwxYw)z�
    Return the language code if there's a valid language code found in `path`.

    If `strict` is False (the default), look for a country-specific variant
    when neither the language code nor its generic variant is found.
    Nr
)r�)�language_code_prefix_re�matchrr�)rr��regex_matchr�s    r�get_language_from_pathr�sg��*�/�/��5�5�K����t��A��I��-�i��G�G�G�G�������t�t����s�9�
A�Ac�X�|rt|j��}|�|S|j�tj��}|�!|t
��vrt|��r|S	t|��S#t$rYnwxYw|j
�dd��}t|��D]I\}}|dkrn=t�
|��s�(	t|��cS#t$rY�FwxYw	ttj��S#t$rtjcYSwxYw)a�
    Analyze the request to find what language the user wants the system to
    show. Only languages listed in settings.LANGUAGES are taken into account.
    If the user requests a sublanguage where we have a main language, we send
    out the main language.

    If check_path is True, the URL path prefix will be checked for a language
    code, otherwise this is skipped for backwards compatibility.
    N�HTTP_ACCEPT_LANGUAGEr��*)r��	path_info�COOKIESrLr�LANGUAGE_COOKIE_NAMErr�rr��META�parse_accept_lang_headerr�r�r)�request�
check_pathr��accept�accept_lang�unuseds      r�get_language_from_requestr st����*�7�+<�=�=�	�� �����#�#�H�$A�B�B�I����m�o�o�!=�!=�BT�U^�B_�B_�!=���
�-�i�8�8�8���
�
�
���
�����\�
�
�4�b�
9�
9�F�7��?�?�
�
���V��#����E��&�&�{�3�3�	��	�1�+�>�>�>�>�>���	�	�	��H�	����&�-�h�.D�E�E�E���&�&�&��%�%�%�%�&���s6�#A2�2
A?�>A?�C&�&
C3�2C3�7D�D)�(D)c��g}t�|�����}|drdStdt	|��dz
d��D]C}|||dz�\}}}|rdS|rt|��}nd}|�||f���D|�d�d�	��t|��S)
z�
    Parse the lang_string, which is the body of an HTTP Accept-Language
    header, and return a tuple of (lang, q-value), ordered by 'q' values.

    Return an empty tuple if there are any format errors in lang_string.
    ���r;rr
�g�?c��|dSr!r;)�ks rr&z+_parse_accept_lang_header.<locals>.<lambda>`s
��a��d�rT)r2�reverse)	�accept_language_rer��lower�ranger��floatr��sort�tuple)�lang_stringrO�pieces�i�firstr��prioritys       r�_parse_accept_lang_headerrKs����F�
�
%�
%�k�&7�&7�&9�&9�
:�
:�F�
�b�z���r�
�1�c�&�k�k�A�o�q�
)�
)�(�(�� &�q��Q��w����t�X��	��2�2��	��X���H�H��H��
�
�t�X�&�'�'�'�'�
�K�K�N�N�D�K�1�1�1���=�=�rc���t|��tkrt|��S|�ddt��}|dkrt|d|���SdS)a�
    Parse the value of the Accept-Language header up to a maximum length.

    The value of the header is truncated to a maximum length to avoid potential
    denial of service and memory exhaustion attacks. Excessive memory could be
    used if the raw value is very large as it would be cached due to the use of
    functools.lru_cache() to avoid repetitive parsing of common header values.
    �,rNr;)r�r�rr�)rr�s  rrrdsg���;���3�3�3�(��5�5�5�

���c�1�&>�?�?�E��q�y�y�(��V�e�V�)<�=�=�=��2r)F)BrW�	functoolsr�r]r~�rer{rc�
asgiref.localr�django.appsr�django.confr�django.conf.localer�django.core.exceptionsr�django.core.signalsr�django.dispatchr	�django.utils.regex_helperr
�django.utils.safestringrrr�rrr�r�r�r�r��VERBOSEr�
IGNORECASEr�r�rrr^rYrpr�r�r�r�r�r�r�r�r�r�r�r�r��	lru_cacherrrr�rrrr;rr�<module>r*s���#�#����� � � � �	�	�	�	�	�	�	�	�
�
�
�
����������������� � � � � � �(�(�(�(�(�(�6�6�6�6�6�6�/�/�/�/�/�/�$�$�$�$�$�$�6�6�6�6�6�6�7�7�7�7�7�7�7�7�$�$�$�$�$�$�$�$��
�
�%�'�'��������&�%�'��Z�	���$�#�:��M����
+�*�+D�E�E��
��/���5�5���5�6�6�6�6�6�6�6�6�rM�M�M�M�M��6�M�M�M�`#�#�#�*�*�*����3�3�3�	"�	"�	"�4�4�4�
�
�
� ���4������M�M�M�?�?�?����<�<�<�1�1�1����T�"�"�"���#�"�������$�$���$����T�"�"�"�+!�+!�+!�#�"�+!�\����"(&�(&�(&�(&�V���T�"�"�"���#�"��0����r

Youez - 2016 - github.com/yon3zu
LinuXploit