https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/utils/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/utils/__pycache__/text.cpython-310.pyc
o

��IhL>�@s�ddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZddlmZmZmZed	d
��Zedej�Zedej�ZGd
d�d�ZGdd�d�ZeZedej�Z edej�Z!ed�Z"ed�Z#edd��Z$Gdd�de�Z%edd��Z&eed�fdd��Z'edd��Z(ed d!��Z)d"d#�Z*Gd$d%�d%e	�Z+d&d'�Z,ed(ej-�Z.d)d*�Z/d+d,�Z0ed-�Z1ed.d/��Z2ed0d1��Z3ed9d3d4��Z4d5d6�Z5d7d8�Z6ee6e7�Z8dS):�N)�GzipFile)�BytesIO)�SuspiciousFileOperation)�RemovedInDjango40Warning)�SimpleLazyObject�keep_lazy_text�lazy)�_lazy_re_compile)�gettext�gettext_lazy�pgettextcCs$|ot|�d��t|�dd�S)z(Capitalize the first letter of a string.r�N)�str�upper)�x�r�3/usr/lib/python3/dist-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__?szFakeMatch.__getitem__cCs|||_|_dS�N)r$r%)r'rrrrr�__init__EszFakeMatch.__init__N)r)r r!r"�	__slots__rr)r+rrrrr8s

rz<[^>]+?>|(.)z<(/)?(\S+?)(?:(\s*/)|\s.*?)?>z\r\n|\rz&(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))cCs>tj|ddd�}g}|�d�D]
}|�|�|��qd�|�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``.
    F)�width�break_long_words�break_on_hyphensT�
)�textwrap�TextWrapper�
splitlines�extend�wrap�join)rr-�wrapper�result�linerrrr5Ss�
r5csZeZdZdZdZ�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>vsz$Truncator.__init__.<locals>.<lambda>)�superr+)r'r��	__class__r<rr+uszTruncator.__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�endswith)r'r�truncaterrr�add_truncation_textxs�
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.
        �NFC�r
rF)	�_setup�int�unicodedata�	normalize�_wrappedrD�	combining�_truncate_html�_text_chars)r'�numrC�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
)�	enumeraterIrLrD)	r'rQrCrrR�s_len�	end_index�irSrrrrN�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)rGrHrMrK�_text_words)r'rOrCrPrQrrr�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.
        N� )rK�split�lenrDr6)r'rQrCrZrrrrY�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.
        rrFFNT)	�br�col�link�base�img�param�area�hr�inputr
z</%s>)r]�MAX_LENGTH_HTML�re_words�re_charsrr�re_tag�match�groups�lower�index�
ValueError�insertrD)r'rQrCrrRrZ�size_limited�html4_singletsr�end_text_pos�current_len�	open_tags�regex�m�tag�closing_tag�tagname�self_closingrX�
truncate_text�outrrrrM�sb
��$zTruncator._truncate_htmlr*)NF)
r r!r"�__doc__rgr+rDrTrNrZrYrM�
__classcell__rrr?rr:js


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.]rF>�..rF�.z$Could not derive file name from '%s')r�strip�replace�re�subr)�name�srrr�get_valid_filenames

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([])
    ''
    rFr
rz%s %s %sz, css�|]}t|�VqdSr*r;)�.0rXrrr�	<genexpr>As�z get_text_list.<locals>.<genexpr>N���)r]rr�r6)�list_�	last_wordrrr�
get_text_list-s.�r�cCst�dt|��S)z*Normalize CRLF and CR newlines to just LF.r0)�re_newlinesr�rr<rrr�normalize_newlinesEsr�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�hrX�j�5�k�lrw�6�n�o�p�7�q�8�9)	�rr��t�u�v�wr�y�zrFc3s�|]	}��||�VqdSr*)�get)r�r���char2numberrrr�Ts�z phone2numeric.<locals>.<genexpr>)r6rm)�phonerr�r�
phone2numericKsN�����������������
�r�cCsNt�}tdd|dd��}|�|�Wd�|��S1swY|��S�N�wb�r)�mode�
compresslevel�fileobj�mtime)rr�write�getvalue)r��zbuf�zfilerrr�compress_stringYs
��r�c@seZdZdd�ZdS)�StreamingBuffercCs|��}|�d�|��|S)Nr)r��seekrC)r'�retrrr�readas
zStreamingBuffer.readN)r r!r"r�rrrrr�`sr�ccsv�t�}tdd|dd�� }|��V|D]}|�|�|��}|r$|VqWd�n1s/wY|��VdSr�)r�rr�r�)�sequence�bufr��item�datarrr�compress_sequenceis�

���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�cCs�|d}|ddkr7|dd�}z|ddvr!t|dd�d�}nt|�}t|�WSty6|dYSwz	ttjj|�WStyM|dYSw)Nr
r�#�xX�)rH�chrrorP�entities�name2codepoint�KeyError)rkrr�rrr�_replace_entity�s 
��r�z#&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));cCs tjdtdd�t�tt|��S)NzPdjango.utils.text.unescape_entities() is deprecated in favor of html.unescape().�)�
stacklevel)�warnings�warnr�
_entity_rer�r�rr<rrr�unescape_entities�s
�r�cCsP|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-]rFz[-\s]+�-z-_)	rrIrJ�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_lazy�sr�)F)9�
html.entitiesrPr�r1rIr��gzipr�ior�django.core.exceptionsr�django.utils.deprecationr�django.utils.functionalrrr�django.utils.regex_helperr	�django.utils.translationr
r�rrr�Srrrrrhrirjr�r�r5r:r�r�r�r�r�r�r��VERBOSEr�r�r�r�r�r�r�r�r�r�format_lazyrrrr�<module>sj

3



	�
	


https://t.me/RX1948 - 2025