%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python3.9/site-packages/markupsafe/__pycache__/
Upload File :
Create Path :
Current File : //lib64/python3.9/site-packages/markupsafe/__pycache__/__init__.cpython-39.pyc

a

_�q\�'�@s6dZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
lm
Z
dZgd�Ze�
d
�Ze�
d�ZGdd�de	�ZGdd�de�Zee	d�r�Gdd�dej�Zdd�ZGdd�de�ZzddlmZmZmZWn(e�yddlmZmZmZYn0e�s2eZe�d�dS)z�
markupsafe
~~~~~~~~~~

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

:copyright: 2010 Pallets
:license: BSD-3-Clause
�N�)�	int_types)�	iteritems)�Mapping)�PY2)�string_types)�	text_type)�unichrz1.1.1)�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|��}|dur&t�||�St�||||�S�N�__html__)�hasattrrr�__new__)�cls�base�encoding�errorsrr�9/usr/lib64/python3.9/site-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>c�z!Markup.__mod__.<locals>.<genexpr>)r�tupler'rrr�__mod__)r�argrrrr-as
zMarkup.__mod__cCsd|jjt�|�fS)Nz%s(%s))r�__name__r�__repr__rrrrr0hszMarkup.__repr__cCs|�t�|t|j|���Sr)rr�join�mapr)r�seqrrrr1kszMarkup.joincOs$tt|jtj|g|�Ri|����Sr)�listr2rr�split�r�args�kwargsrrrr5pszMarkup.splitcOs$tt|jtj|g|�Ri|����Sr)r4r2rr�rsplitr6rrrr9usz
Markup.rsplitcOs$tt|jtj|g|�Ri|����Sr)r4r2rr�
splitlinesr6rrrr:zszMarkup.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�}|�vrt�|�SzL|dd�dvrHtt|dd�d��WS|�d�rhtt|dd���WSWnty|Yn0|��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)rrFrr;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)r1�
_striptags_rerHr5r
rI)r�strippedrrr�	striptags�szMarkup.striptagscCst|�}|j|ur||�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)NcsDtt|�t|�|j�}t|t|�|j�|��|g|�Ri|���Sr)�_escape_argspecr4�	enumeraterrrr6�Zorigrr�func�sz1Markup.make_simple_escaping_wrapper.<locals>.func)�getattrrr/�__doc__)rErSrrRr�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,r2rr�	partitionr�r�seprrrrg�szMarkup.partitionc	Cstt|jt�||�|����Sr)r,r2rr�
rpartitionrrhrrrrj�szMarkup.rpartitioncOs(t|j�}t||�}|�|�|||��Sr)�EscapeFormatterr�_MagicFormatMappingrZvformat)rr7r8�	formatterrrr�format�s

z
Markup.formatcCs|rtd��|S)Nz,Unsupported format specification for Markup.)rC)r�format_specrrr�__html_format__�szMarkup.__html_format__�__getslice__)rNr) r/�
__module__�__qualname__rU�	__slots__rrr r%r&�__rmul__r-r0r1rr5r9r:rIrM�classmethodrrV�method�localsrgrjrnrprrq�
__classcell__rrr$rr
s@$






	r
c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)rlz�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_indexr6rrr�__init__�sz_MagicFormatMapping.__init__cCsN|dkrD|j}|jd7_z|j|WSty:Yn0t|�}|j|S)Nrr)r|rz�LookupError�strr{)r�key�idxrrrrW�sz_MagicFormatMapping.__getitem__cCs
t|j�Sr)�iterr{rrrr�__iter__�sz_MagicFormatMapping.__iter__cCs
t|j�Sr)�lenr{rrrr�__len__�sz_MagicFormatMapping.__len__N)r/rrrsrUr}rWr�r�rrrrrl�s
rlrnc@seZdZdd�Zdd�ZdS)rkcCs
||_dSr)r)rrrrrr}szEscapeFormatter.__init__cCsdt|d�r|�|�}n@t|d�rB|r8td�|t|����|��}ntj�||t	|��}t	|�
|��S)Nrprz�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.)rrprCrn�typer�string�	Formatter�format_fieldrr)r�valuerorOrrrr�s

��
zEscapeFormatter.format_fieldN)r/rrrsr}r�rrrrrksrkcCs2|D](\}}t|d�s t|t�r||�||<q|S)z,Helper for various string-wrapped functions.r)rrr)�obj�iterablerr�r�rrrrPsrPc@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�itemrrrrW,sz_MarkupEscapeHelper.__getitem__cCst|�|j��Sr)rrr�rrrr�__str__/sz_MarkupEscapeHelper.__str__cCst|�t|j���Sr)rr�reprr�rrrrr04sz_MarkupEscapeHelper.__repr__cCs
t|j�Sr)rAr�rrrr�__int__7sz_MarkupEscapeHelper.__int__cCs
t|j�Sr)�floatr�rrrr�	__float__:sz_MarkupEscapeHelper.__float__N)r/rrrsrUr}rWr�Z__unicode__r0r�r�rrrrr'%sr')rr
r�soft_str) rU�rer�Z_compatrrrrrrr	�__version__�__all__�compilerKrGr
rlrr�rkrP�objectr'Z	_speedupsrr
r�ImportErrorZ_nativer��appendrrrr�<module>s6


E


Zerion Mini Shell 1.0