B V`"@sLddlZddlZddlZddlZejr@ddlZGdddejZ dZ e dZ e ejdddd ZGd d d e ZGd d d ejZedeeZeejejejejgefedddZGdddZy4ddlmZddlmZddlmZddlmZWnFe k rFddl!mZddl!mZddl!mZddl!mZYnXdS)Nc@seZdZedddZdS)HasHTML)returncCsdS)N)selfrrF/opt/alt/python37/lib64/python3.7/site-packages/markupsafe/__init__.py__html__ szHasHTML.__html__N)__name__ __module__ __qualname__strrrrrrr srz2.0.1z(|<[^>]*>)).Markup)namercs4tt|tdtjtjddfdd }|S)Nr )rargskwargsrcs>tt|t||j}t|||j||f||S)N)_escape_argspeclist enumerateescapeitems __class__)rrr)origrrwrappedsz)_simple_escaping_wrapper..wrapped)getattrr functoolswrapstAny)r rr)rr_simple_escaping_wrappers rcseZdZdZdZd;ejejeeddfdd Z dd d d Z ej ed fdd fdd Z ej ed fdd ddZ eddfdd ZeZejddfdd Zed fdd Zejej ed fddfdd Zejje_deejdd$fd%d& Zejje_ed d'd(Zed d)d*Zeejdd+d,d-Zxd.D]Zeee e<qW[eej!d/d0fd1d2 Z"eej!d/d0fd3d4 Z#ejejdd5d6d7Z$edd8d9d:Z%Z&S)?r aA 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, World!") Markup('Hello, World!') >>> Markup(42) Markup('42') >>> Markup.escape("Hello, World!") Markup('Hello <em>World</em>!') 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 'foo' ... >>> Markup(Foo()) Markup('foo') This is a subclass of :class:`str`. It has the same methods, but escapes their arguments and returns a ``Markup`` instance. >>> Markup("%s") % ("foo & bar",) Markup('foo & bar') >>> Markup("Hello ") + "" Markup('Hello <foo>') rNstrict)baseencodingerrorsrcs:t|dr|}|dkr(t||St||||S)Nr)hasattrrsuper__new__)clsr r!r")rrrr%Es  zMarkup.__new__)rcCs|S)Nr)rrrrrPszMarkup.__html__r)otherrcs0t|tst|dr,|t||StS)Nr) isinstancer r#rr$__add__rNotImplemented)rr')rrrr)SszMarkup.__add__cCs(t|tst|dr$|||StS)Nr)r(r r#rr)r*)rr'rrr__radd__YszMarkup.__radd__)numrcs t|tr|t|StS)N)r(intrr$__mul__r*)rr,)rrrr._s zMarkup.__mul__)argrcs@t|tr"tfdd|D}n t|j}t|S)Nc3s|]}t|jVqdS)N)_MarkupEscapeHelperr).0x)rrr isz!Markup.__mod__..)r(tupler0rrr$__mod__)rr/)r)rrr5gs  zMarkup.__mod__cs|jjdtdS)N())rrr$__repr__)r)rrrr8oszMarkup.__repr__)seqrcs|tt|j|S)N)rr$joinmapr)rr9)rrrr:rsz Markup.join)sepmaxsplitrcsfddt||DS)Ncsg|]}|qSr)r)r1v)rrr zsz Markup.split..)r$split)rr=r>)r)rrrAwsz Markup.splitcsfddt||DS)Ncsg|]}|qSr)r)r1r?)rrrr@sz!Markup.rsplit..)r$rsplit)rr=r>)r)rrrB~sz Markup.rsplitF)keependsrcsfddt|DS)Ncsg|]}|qSr)r)r1r?)rrrr@sz%Markup.splitlines..)r$ splitlines)rrC)r)rrrDszMarkup.splitlinescCsddlm}|t|S)uConvert escaped markup back into a text string. This replaces HTML entities with the characters they represent. >>> Markup("Main » About").unescape() 'Main » About' r)unescape)ZhtmlrEr )rrErrrrEs zMarkup.unescapecCs"dtd|}t|S)u:meth:`unescape` the markup, remove tags, and normalize whitespace to single spaces. >>> Markup("Main » About").striptags() 'Main » About'  r)r: _striptags_resubrAr rE)rstrippedrrr striptagsszMarkup.striptags)srcCst|}|j|k r||S|S)ztEscape a string. Calls :func:`escape` and ensures that for subclasses the correct type is returned. )rr)r&rKrvrrrrs z Markup.escape) __getitem__ capitalizetitlelowerupperreplaceljustrjustlstriprstripcenterstrip translate expandtabsswapcasezfill)r r r )r=rcs4t||\}}}|j}||||||fS)N)r$ partitionrr)rr=lrKrr&)rrrr]szMarkup.partitioncs4t||\}}}|j}||||||fS)N)r$ rpartitionrr)rr=r^rKr_r&)rrrr`szMarkup.rpartition)rrrcOst|j}|||||S)N)EscapeFormatterrrZvformat)rrrZ formatterrrrformats z Markup.format) format_specrcCs|r td|S)Nz,Unsupported format specification for Markup.) ValueError)rrcrrr__html_format__szMarkup.__html_format__)rNr)Nr<)Nr<)F)'rr r __doc__ __slots__rrZOptionalr r%rZUnionr)r+r-r.__rmul__r5r8Iterabler:ZListrArBboolrDrErJ classmethodrmethodrlocalsZTupler]r`rbre __classcell__rr)rrr sB" $         r csJeZdZdZejejgefddfdd Zeje e dddZ Z S) ra)rN)rrcs||_tdS)N)rr$__init__)rr)rrrroszEscapeFormatter.__init__)valuercrcCsjt|dr||}nFt|drH|r>td|dt|d|}ntj||t|}t| |S)NrerzFormat specifier z given, but z{ does not define __html_format__. A class that defines __html__ must define __html_format__ to work with format specifiers.) r#rerdtyperstring Formatter format_fieldr r)rrprcrLrrrrts    zEscapeFormatter.format_field) rr r rgrCallablerr ror rtrnrr)rrras"ra _ListOrDict)objiterablerrcCs6x0|D](\}}t|ts"t|dr||||<qW|S)z,Helper for various string-wrapped functions.r)r(r r#)rwrxrkeyrprrrrsrc@seZdZdZdZejejejgefddddZ ejdddd Z e d d d Z e d d dZ ed ddZed ddZdS)r0z"Helper for :meth:`Markup.__mod__`.)rwrN)rwrrcCs||_||_dS)N)rwr)rrwrrrrrosz_MarkupEscapeHelper.__init__)itemrcCst|j||jS)N)r0rwr)rrzrrrrMsz_MarkupEscapeHelper.__getitem__)rcCst||jS)N)r rrw)rrrr__str__ sz_MarkupEscapeHelper.__str__cCst|t|jS)N)r rreprrw)rrrrr8 sz_MarkupEscapeHelper.__repr__cCs t|jS)N)r-rw)rrrr__int__sz_MarkupEscapeHelper.__int__cCs t|jS)N)floatrw)rrrr __float__sz_MarkupEscapeHelper.__float__)rr r rfrgrrrur rorMr r{r8r-r}r~rrrrrr0s"r0)r) escape_silent)soft_str) soft_unicode)"rrerrtypingrZ TYPE_CHECKINGZtyping_extensionsZteZProtocolr __version__compilerGr rurr rsraZTypeVarrdictrvrirrr0Z _speedupsrrrr ImportErrorZ_nativerrrrs4  8