HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/lib/python3/dist-packages/markupsafe/__pycache__/__init__.cpython-38.pyc
U

�x�[�'�@s<dZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
lm
Z
dZdd
ddgZe�
d�Ze�
d�ZGdd�de	�ZGdd�de�Zee	d�r�Gdd�dej�Zdd�ZGdd�de�ZzddlmZmZmZWn*ek
�r"ddlmZmZmZYnXe�s8eZe�d�dS)u�
markupsafe
~~~~~~~~~~

Implements an escape function and a Markup string to replace HTML
special characters with safe representations.

:copyright: © 2010 by the Pallets team.
:license: BSD, see LICENSE for more details.
�N�)�	int_types)�	iteritems)�Mapping)�PY2)�string_types)�	text_type)�unichrz1.1.0�Markup�soft_unicode�escape�
escape_silentz(<!--.*?-->|<[^>]*>)z&([^& ;]+);cseZdZdZdZd.dd�Zdd	�Z�fd
d�Zdd
�Zdd�Z	e	Z
dd�Zdd�Zdd�Z
ej
je
_dd�Zejje_dd�Zejje_dd�Zejje_dd�Zdd�Zed d!��Zd"d#�Zd$D]Zee�e�e<q�d%d&�Zd'd(�Zd)d*�Zd+d,�Zeed-��r
ed-�Z[[�ZS)/r
a�A string that is ready to be safely inserted into an HTML or XML
    document, either because it was escaped or because it was marked
    safe.

    Passing an object to the constructor converts it to text and wraps
    it to mark it safe without escaping. To escape the text, use the
    :meth:`escape` class method instead.

    >>> Markup('Hello, <em>World</em>!')
    Markup('Hello, <em>World</em>!')
    >>> Markup(42)
    Markup('42')
    >>> Markup.escape('Hello, <em>World</em>!')
    Markup('Hello &lt;em&gt;World&lt;/em&gt;!')

    This implements the ``__html__()`` interface that some frameworks
    use. Passing an object that implements ``__html__()`` will wrap the
    output of that method, marking it safe.

    >>> class Foo:
    ...     def __html__(self):
    ...         return '<a href="/foo">foo</a>'
    ...
    >>> Markup(Foo())
    Markup('<a href="/foo">foo</a>')

    This is a subclass of the text type (``str`` in Python 3,
    ``unicode`` in Python 2). It has the same methods as that type, but
    all methods escape their arguments and return a ``Markup`` instance.

    >>> Markup('<em>%s</em>') % 'foo & bar'
    Markup('<em>foo &amp; bar</em>')
    >>> Markup('<em>Hello</em> ') + '<foo>'
    Markup('<em>Hello</em> &lt;foo&gt;')
    ��N�strictcCs6t|d�r|��}|dkr&t�||�St�||||�S�N�__html__)�hasattrrr�__new__)�cls�base�encoding�errorsrr�5/usr/lib/python3/dist-packages/markupsafe/__init__.pyrFs

zMarkup.__new__cCs|S�Nr��selfrrrrMszMarkup.__html__cs4t|t�st|d�r0|�tt|��|�|���StSr)	�
isinstancerr�	__class__�superr
�__add__r�NotImplemented�r�other�rrrr PszMarkup.__add__cCs(t|d�st|t�r$|�|��|�StSr)rrrrr r!r"rrr�__radd__UszMarkup.__radd__cCs t|t�r|�t�||��StSr)rrrr�__mul__r!)rZnumrrrr&Zs
zMarkup.__mul__cs@t|t�r"t�fdd�|D��}nt|�j�}��t��|��S)Nc3s|]}t|�j�VqdSr)�_MarkupEscapeHelperr)�.0�xrrr�	<genexpr>csz!Markup.__mod__.<locals>.<genexpr>)r�tupler'rrr�__mod__)r�argrrrr,as
zMarkup.__mod__cCsd|jjt�|�fS)Nz%s(%s))r�__name__r�__repr__rrrrr/hszMarkup.__repr__cCs|�t�|t|j|���Sr)rr�join�mapr)r�seqrrrr0kszMarkup.joincOstt|jtj|f|�|���Sr)�listr1rr�split�r�args�kwargsrrrr4pszMarkup.splitcOstt|jtj|f|�|���Sr)r3r1rr�rsplitr5rrrr8usz
Markup.rsplitcOstt|jtj|f|�|���Sr)r3r1rr�
splitlinesr5rrrr9zszMarkup.splitlinescs(ddlm��fdd�}t�|t|��S)u�Convert escaped markup back into a text string. This replaces
        HTML entities with the characters they represent.

        >>> Markup('Main &raquo; <em>About</em>').unescape()
        'Main » <em>About</em>'
        r��
HTML_ENTITIEScs�|�d�}|�krt�|�SzL|dd�dkrHtt|dd�d��WS|�d�rhtt|dd���WSWntk
r~YnX|��S)Nr�)z#xz#X��#)�groupr	�int�
startswith�
ValueError)�m�namer:rr�handle_match�s

z%Markup.unescape.<locals>.handle_match)Z
_constantsr;�
_entity_re�subr)rrErr:r�unescapeszMarkup.unescapecCs"d�t�d|����}t|���S)u�:meth:`unescape` the markup, remove tags, and normalize
        whitespace to single spaces.

        >>> Markup('Main &raquo;	<em>About</em>').striptags()
        'Main » About'
        � r)r0�
_striptags_rerGr4r
rH)r�strippedrrr�	striptags�szMarkup.striptagscCst|�}|j|k	r||�S|S)ztEscape a string. Calls :func:`escape` and ensures that for
        subclasses the correct type is returned.
        )rr)r�s�rvrrrr�s
z
Markup.escapecs*tt|���fdd�}�j|_�j|_|S)Ncs>tt|�t|�|j�}t|t|�|j�|��|f|�|��Sr)�_escape_argspecr3�	enumeraterrrr5�Zorigrr�func�sz1Markup.make_simple_escaping_wrapper.<locals>.func)�getattrrr.�__doc__)rDrRrrQr�make_simple_escaping_wrapper�s

z#Markup.make_simple_escaping_wrapper)�__getitem__�
capitalize�title�lower�upper�replace�ljust�rjust�lstrip�rstrip�center�strip�	translate�
expandtabs�swapcase�zfillc	Cstt|jt�||�|����Sr)r+r1rr�	partitionr�r�seprrrrf�szMarkup.partitionc	Cstt|jt�||�|����Sr)r+r1rr�
rpartitionrrgrrrri�szMarkup.rpartitioncOs(t|j�}t||�}|�|�|||��Sr)�EscapeFormatterr�_MagicFormatMappingrZvformat)rr6r7Z	formatterrrr�format�s

z
Markup.formatcCs|rtd��|S)Nz,Unsupported format specification for Markup.)rB)r�format_specrrr�__html_format__�szMarkup.__html_format__�__getslice__)rNr) r.�
__module__�__qualname__rT�	__slots__rrr r%r&�__rmul__r,r/r0rr4r8r9rHrL�classmethodrrU�method�localsrfrirlrnrro�
__classcell__rrr$rr
s@$






	c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)rkz�This class implements a dummy wrapper to fix a bug in the Python
    standard library for string formatting.

    See http://bugs.python.org/issue13598 for information about why
    this is necessary.
    cCs||_||_d|_dS)Nr)�_args�_kwargs�_last_indexr5rrr�__init__�sz_MagicFormatMapping.__init__cCsP|dkrF|j}|jd7_z|j|WStk
r<YnXt|�}|j|S)Nrr)rzrx�LookupError�strry)r�key�idxrrrrV�sz_MagicFormatMapping.__getitem__cCs
t|j�Sr)�iterryrrrr�__iter__�sz_MagicFormatMapping.__iter__cCs
t|j�Sr)�lenryrrrr�__len__�sz_MagicFormatMapping.__len__N)r.rprqrTr{rVr�r�rrrrrk�s
rkrlc@seZdZdd�Zdd�ZdS)rjcCs
||_dSr)r)rrrrrr{szEscapeFormatter.__init__cCsdt|d�r|�|�}n@t|d�rB|r8td�|t|����|��}ntj�||t	|��}t	|�
|��S)Nrnrz�Format specifier {0} given, but {1} does not define __html_format__. A class that defines __html__ must define __html_format__ to work with format specifiers.)rrnrBrl�typer�string�	Formatter�format_fieldrr)r�valuermrNrrrr�s

��
zEscapeFormatter.format_fieldN)r.rprqr{r�rrrrrjsrjcCs2|D](\}}t|d�s t|t�r||�||<q|S)z,Helper for various string-wrapped functions.r)rrr)�obj�iterablerr~r�rrrrOsrOc@sDeZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
d�Z	dd
�Z
dS)r'zHelper for Markup.__mod__cCs||_||_dSr)r�r)rr�rrrrr{(sz_MarkupEscapeHelper.__init__cCst|j||j�Sr)r'r�r)r�itemrrrrV,sz_MarkupEscapeHelper.__getitem__cCst|�|j��Sr)rrr�rrrr�__str__/sz_MarkupEscapeHelper.__str__cCst|�t|j���Sr)r}r�reprr�rrrrr/4sz_MarkupEscapeHelper.__repr__cCs
t|j�Sr)r@r�rrrr�__int__7sz_MarkupEscapeHelper.__int__cCs
t|j�Sr)�floatr�rrrr�	__float__:sz_MarkupEscapeHelper.__float__N)r.rprqrTr{rVr�Z__unicode__r/r�r�rrrrr'%sr')rr
r�soft_str) rT�rer�Z_compatrrrrrrr	�__version__�__all__�compilerJrFr
rkrr�rjrO�objectr'Z	_speedupsrr
r�ImportErrorZ_nativer��appendrrrr�<module>s6


E