HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/django/utils/__pycache__/text.cpython-310.pyc
o

�h@�@s�ddlZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZdd	lmZmZe
d
d��Zedej�Zed
ej�ZGdd�d�ZGdd�d�ZeZedej�Zedej�Zed�Zed�Z e
dd��Z!Gdd�de�Z"e
dd��Z#e
ed�fdd��Z$e
dd ��Z%e
d!d"��Z&d#d$�Z'dd%�d&d'�Z(Gd(d)�d)e�Z)dd%�d*d+�Z*ed,ej+�Z,d-d.�Z-e
d/d0��Z.e
d8d2d3��Z/d4d5�Z0d6d7�Z1ee1e2�Z3dS)9�N)�GzipFile)�compress)�BytesIO)�SuspiciousFileOperation)�SimpleLazyObject�keep_lazy_text�lazy)�_lazy_re_compile)�gettext)�gettext_lazy�pgettextcCs2|s|St|t�s
t|�}|d��|dd�S)z(Capitalize the first letter of a string.r�N)�
isinstance�str�upper)�x�r�G/usr/local/CyberPanel/lib/python3.10/site-packages/django/utils/text.py�capfirsts

rz
([^<>\s]+)z<|([^<>\s]+)c@seZdZedd��ZdS)�
WordsRegexcCsnt�||�}|dus|ddur|S|�d|�d��}|dkr't�||d�S|d7}t||�d�|�|�S)Nr
�>r)�re_prt�search�find�end�re_notag�	FakeMatch�start)�text�pos�partialrrrrr*szWordsRegex.searchN)�__name__�
__module__�__qualname__�staticmethodrrrrrr)src@s.eZdZddgZddd�Zdd�Zdd	�Zd
S)r�_text�_endrcCs|dksJd��|jS)Nrz'This specific object takes only group=0)r&��self�grouprrrr?sz
FakeMatch.endcCs"|dkrdS|dksJd��|jS)Nr
rz.This specific object takes only group in {0,1})r%r'rrr�__getitem__CszFakeMatch.__getitem__cCs|||_|_dS�N)r%r&)r(rrrrr�__init__IszFakeMatch.__init__N)r)r!r"r#�	__slots__rr*r,rrrrr<s

rz<[^>]+?>|(.)z<(/)?(\S+?)(?:(\s*/)|\s.*?)?>z\r\n|\rz&(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))cs��fdd�}d�|��S)aC
    A word-wrap function that preserves existing line breaks. Expects that
    existing line breaks are posix newlines.

    Preserve all white space except added line breaks consume the space on
    which they break the line.

    Don't wrap long words, thus the output text may have lines longer than
    ``width``.
    c3s����d�D]b}t|�d�r�dp���}t|�|krc|d|d��d�d}|dkr>|�d�d}|dkr>|Vd}n%d|d|d�V||d�}t|�d�rY�dpZ���}t|�|ks|rh|VqdS)NT�
r
� r�z%s
)�
splitlines�min�endswith�len�rfindr)�line�	max_width�space�r�widthrr�
_generatords&����zwrap.<locals>._generatorr0)�join)rr:r;rr9r�wrapWs
r=csZeZdZdZdZ�fdd�Zddd�Zdd	d
�Zdd�Zdd
d�Z	dd�Z
dd�Z�ZS)�	Truncatorz�
    An object used to truncate text, either by characters or words.

    When truncating HTML text (either chars or words), input will be limited to
    at most `MAX_LENGTH_HTML` characters.
    i@KLcst���fdd��dS)Ncst��Sr+�rr�rrr�<lambda>�sz$Truncator.__init__.<locals>.<lambda>)�superr,)r(r��	__class__r@rr,�szTruncator.__init__NcCs@|dur	tdd�}d|vr|d|iS|�|�r|Sd||fS)Nz%String to return when truncating textu%(truncated_text)s…z%(truncated_text)s�truncated_textz%s%s)rr3)r(r�truncaterrr�add_truncation_text�s�
zTruncator.add_truncation_textFcCsx|��t|�}t�d|j�}|}|�d|�D]}t�|�s(|d8}|dkr(nq|r4|�||||d�S|�||||�S)a
        Return the text truncated to be no longer than the specified number
        of characters.

        `truncate` specifies what should be used to notify that the string has
        been truncated, defaulting to a translatable string of an ellipsis.
        �NFCr0r
rF)	�_setup�int�unicodedata�	normalize�_wrappedrG�	combining�_truncate_html�_text_chars)r(�numrF�html�lengthr�truncate_len�charrrr�chars�s
�zTruncator.charsc	Csjd}d}t|�D]*\}}t�|�rq|d7}|dur ||kr |}||kr2|�|d|p+d�|�Sq|S)z2Truncate a string after a certain number of chars.rNr
)�	enumeraterKrNrG)	r(rSrFrrT�s_len�	end_index�irUrrrrP�s
�zTruncator._text_charscCs4|��t|�}|r|�|||j|d�S|�||�S)z�
        Truncate a string after a certain number of words. `truncate` specifies
        what should be used to notify that the string has been truncated,
        defaulting to ellipsis.
        T)rIrJrOrM�_text_words)r(rQrFrRrSrrr�words�s
zTruncator.wordscCs>|j��}t|�|kr|d|�}|�d�|�|�Sd�|�S)zk
        Truncate a string after a certain number of words.

        Strip newlines in the string.
        Nr/)rM�splitr4rGr<)r(rSrFr\rrrr[�s


zTruncator._text_wordscCs||r|dkrdSd}t|�|jkr|d|j�}d}d}d}d}	d}
g}|r(tnt}|
|kr�|�||�}
|
s7nZ|
�d�}|
drK|
d7}
|
|krJ|}	q*t�|
d�}|rX|
|krYq*|��\}}}|�	�}|sj||vrkn"|r�z|�
|�}Wn	ty}Ynw||dd�}n|�d|�|
|ks.|�
d|�}|
|kr�|r�|r�||7}|S|d|	�}|r�||7}|D]}|d|7}q�|S)	a
        Truncate HTML to a certain number of chars (not counting tags and
        comments), or, if words is True, then to a certain number of words.
        Close opened tags if they were correctly closed in the given HTML.

        Preserve newlines in the HTML.
        rr0FNT)	�br�col�link�base�img�param�area�hr�inputr
z</%s>)r4�MAX_LENGTH_HTML�re_words�re_charsrr�re_tag�match�groups�lower�index�
ValueError�insertrG)r(rSrFrrTr\�size_limited�html4_singletsr�end_text_pos�current_len�	open_tags�regex�m�tag�closing_tag�tagname�self_closingrZ�
truncate_text�outrrrrO�sb

��$zTruncator._truncate_htmlr+)NF)
r!r"r#�__doc__rgr,rGrVrPr\r[rO�
__classcell__rrrCrr>xs


r>cCs:t|����dd�}t�dd|�}|dvrtd|��|S)aY
    Return the given string converted to a string that can be used for a clean
    filename. Remove leading and trailing spaces; convert other spaces to
    underscores; and remove anything that is not an alphanumeric, dash,
    underscore, or dot.
    >>> get_valid_filename("john's portrait in 2004.jpg")
    'johns_portrait_in_2004.jpg'
    r/�_z(?u)[^-\w.]r0>�..r0�.z$Could not derive file name from '%s')r�strip�replace�re�subr)�name�srrr�get_valid_filename0s

r��orcCsV|sdSt|�dkrt|d�Sdtd��dd�|dd	�D��t|�t|d	�fS)
a
    >>> get_text_list(['a', 'b', 'c', 'd'])
    'a, b, c or d'
    >>> get_text_list(['a', 'b', 'c'], 'and')
    'a, b and c'
    >>> get_text_list(['a', 'b'], 'and')
    'a and b'
    >>> get_text_list(['a'])
    'a'
    >>> get_text_list([])
    ''
    r0r
rz%s %s %sz, css�|]}t|�VqdSr+r?)�.0rZrrr�	<genexpr>Us�z get_text_list.<locals>.<genexpr>N���)r4rr�r<)�list_�	last_wordrrr�
get_text_listAs
�r�cCst�dt|��S)z*Normalize CRLF and CR newlines to just LF.r.)�re_newlinesr�rr@rrr�normalize_newlines[sr�cs�idd�dd�dd�dd�dd�dd�d	d
�dd
�dd
�d
d�dd�dd�dd�dd�dd�dd�dd�dddddddddd�	��d��fdd�|��D��S)z@Convert a phone number with letters into its numeric equivalent.�a�2�b�c�d�3�e�f�g�4�hrZ�j�5�k�lrw�6�n�o�p�7�q�8�9)	�rr��t�u�v�wr�y�zr0c3s�|]	}��||�VqdSr+)�get)r�r���char2numberrrr��s�z phone2numeric.<locals>.<genexpr>)r<rm)�phonerr�r�
phone2numericas\��������	�
���
������r�cCsdt�|�S)N�a)�secrets�	randbelow��max_random_bytesrrr�_get_random_filename�sr�r�cCs\t|ddd�}|s|St|�}t|dd��}tj|d<t|�d}t|�||dd�S)N�r)�
compresslevel�mtime�
��)�
gzip_compress�
memoryview�	bytearray�gzip�FNAMEr��bytes)r�r��compressed_data�compressed_view�header�filenamerrr�compress_string�s
r�c@seZdZdd�ZdS)�StreamingBuffercCs|��}|�d�|��|S)Nr)�getvalue�seekrF)r(�retrrr�read�s
zStreamingBuffer.readN)r!r"r#r�rrrrr��sr�ccs��t�}|r
t|�nd}t|dd|dd�� }|��V|D]}|�|�|��}|r-|VqWd�n1s8wY|��VdS)N�wbr�r)r��moder��fileobjr�)r�r�rr��write)�sequencer��bufr��zfile�item�datarrr�compress_sequence�s"�
�

���
r�z�
    ((?:
        [^\s'"]*
        (?:
            (?:"(?:[^"\\]|\\.)*" | '(?:[^'\\]|\\.)*')
            [^\s'"]*
        )+
    ) | \S+)
ccs$�t�t|��D]}|dVqdS)a�
    Generator that splits a string by spaces, leaving quoted phrases together.
    Supports both single and double quotes, and supports escaping quotes with
    backslashes. In the output, strings will keep their initial and trailing
    quote marks and escaped quotes will remain escaped (the results can then
    be further processed with unescape_string_literal()).

    >>> list(smart_split(r'This is "a person\'s" test.'))
    ['This', 'is', '"a person\\\'s"', 'test.']
    >>> list(smart_split(r"Another 'person\'s' test."))
    ['Another', "'person\\'s'", 'test.']
    >>> list(smart_split(r'A "\"funky\" style" test.'))
    ['A', '"\\"funky\\" style"', 'test.']
    rN)�smart_split_re�finditerr)r�bitrrr�smart_split�s��r�cCsT|r|ddvs|d|dkrtd|��|d}|dd��d||��dd�S)	al
    Convert quoted string literals to unquoted strings with escaped quotes and
    backslashes unquoted::

        >>> unescape_string_literal('"abc"')
        'abc'
        >>> unescape_string_literal("'abc'")
        'abc'
        >>> unescape_string_literal('"a \"bc\""')
        'a "bc"'
        >>> unescape_string_literal("'\'ab\' c'")
        "'ab' c"
    rz"'r�zNot a string literal: %rr
z\%sz\\�\)ror�)r��quoterrr�unescape_string_literal�s  r�FcCsZt|�}|r
t�d|�}n
t�d|��dd��d�}t�dd|���}t�dd|��d	�S)
a
    Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated
    dashes to single dashes. Remove characters that aren't alphanumerics,
    underscores, or hyphens. Convert to lowercase. Also strip leading and
    trailing whitespace, dashes, and underscores.
    �NFKC�NFKD�ascii�ignorez[^\w\s-]r0z[-\s]+�-z-_)	rrKrL�encode�decoder�r�rmr�)�value�
allow_unicoderrr�slugify�s
�r�cCst�d|�����S)zQ
    Split CamelCase and convert to lowercase. Strip surrounding whitespace.
    z \1)�
re_camel_caser�r�rm)r�rrr�camel_case_to_spaces�sr�cOs|j|i|��S)zk
    Apply str.format() on 'format_string' where format_string, args,
    and/or kwargs might be lazy.
    )�format)�
format_string�args�kwargsrrr�_format_lazysr�)F)4r�r�r�rKrrr��ior�django.core.exceptionsr�django.utils.functionalrrr�django.utils.regex_helperr	�django.utils.translationr
r�rrr�Srrrrrhrirjr�r�r=r>r�r�r�r�r�r�r�r��VERBOSEr�r�r�r�r�r�r�format_lazyrrrr�<module>sf

 9


!		�