ó "^†Lc@sÛdZddlZddlmZddddgZejdƒZejd ƒZdefd „ƒYZ d „Z d e fd „ƒYZ y ddl mZmZmZWn-ek rÖddlmZmZmZnXdS(sž markupsafe ~~~~~~~~~~ Implements a Markup string. :copyright: (c) 2010 by Armin Ronacher. :license: BSD, see LICENSE for more details. iÿÿÿÿN(timaptMarkupt soft_unicodetescapet escape_silents(|<[^>]*>)s &([^;]+);cBsveZdZd'Zdd(dd„Zd„Zd„Zd„Zd„Z e Z d„Z d „Z d „Z ej je _d „Zejje_d „Zejje_d „Zejje_d„Zd„Zed„ƒZd„Zx!d)D]Zeeƒeƒe>> Markup("Hello World!") Markup(u'Hello World!') >>> class Foo(object): ... def __html__(self): ... return 'foo' ... >>> Markup(Foo()) Markup(u'foo') If you want object passed being always treated as unsafe you can use the :meth:`escape` classmethod to create a :class:`Markup` object: >>> Markup.escape("Hello World!") Markup(u'Hello <em>World</em>!') Operations on a markup string are markup aware which means that all arguments are passed through the :func:`escape` function: >>> em = Markup("%s") >>> em % "foo & bar" Markup(u'foo & bar') >>> strong = Markup("%(text)s") >>> strong % {'text': 'hacker here'} Markup(u'<blink>hacker here</blink>') >>> Markup("Hello ") + "" Markup(u'Hello <foo>') utstrictcCsPt|dƒr|jƒ}n|dkr:tj||ƒStj||||ƒS(Nt__html__(thasattrRtNonetunicodet__new__(tclstbasetencodingterrors((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR Cs  cCs|S(N((tself((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRJscCsEt|dƒst|tƒrA|jt|ƒtt|ƒƒƒStS(NR(Rt isinstancet basestringt __class__R RtNotImplemented(Rtother((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt__add__Ms#cCsEt|dƒst|tƒrA|jtt|ƒƒt|ƒƒStS(NR(RRRRR RR(RR((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt__radd__Rs#cCs2t|ttfƒr.|jtj||ƒƒStS(N(RtinttlongRR t__mul__R(Rtnum((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRWscCsLt|tƒr'ttt|ƒƒ}n t|ƒ}|jtj||ƒƒS(N(RttupleRt_MarkupEscapeHelperRR t__mod__(Rtarg((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR]s cCsd|jjtj|ƒfS(Ns%s(%s)(Rt__name__R t__repr__(R((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR ds cCs"|jtj|tt|ƒƒƒS(N(RR tjoinRR(Rtseq((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR!jscOst|jtj|||ŽƒS(N(tmapRR tsplit(Rtargstkwargs((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR$nscOst|jtj|||ŽƒS(N(R#RR trsplit(RR%R&((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR'rscOst|jtj|||ŽƒS(N(R#RR t splitlines(RR%R&((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR(vscs5ddlm‰‡fd†}tj|t|ƒƒS(sÔUnescape markup again into an unicode string. This also resolves known HTML4 and XHTML entities: >>> Markup("Main » About").unescape() u'Main \xbb About' iÿÿÿÿ(t HTML_ENTITIEScs|jdƒ}|ˆkr)tˆ|ƒSyN|d dkrStt|ddƒƒS|jdƒrvtt|dƒƒSWntk rŠnXdS( Niis#xs#Xit#u(s#xs#X(tgrouptunichrRt startswitht ValueError(tmtname(R)(s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt handle_match‚s  (tmarkupsafe._constantsR)t _entity_retsubR (RR1((R)s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pytunescapezs cCs1djtjd|ƒjƒƒ}t|ƒjƒS(sUnescape markup into an unicode string and strip all tags. This also resolves known HTML4 and XHTML entities. Whitespace is normalized to one: >>> Markup("Main » About").striptags() u'Main \xbb About' u t(R!t _striptags_reR4R$RR5(Rtstripped((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt striptagss!cCs)t|ƒ}|j|k r%||ƒS|S(s²Escape the string. Works like :func:`escape` with the difference that for subclasses of :class:`Markup` this function would return the correct subclass. (RR(R tstrv((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR›s  cs:tt|ƒ‰‡fd†}ˆj|_ˆj|_|S(NcsGtt|ƒt|ƒƒ}t||jƒƒ|jˆ|||ŽƒS(N(t_escape_argspectlistt enumeratet iteritemsR(RR%R&(torig(s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pytfunc¨s(tgetattrR Rt__doc__(R0RA((R@s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt make_wrapper¦s   t __getitem__t capitalizettitletlowertuppertreplacetljusttrjusttlstriptrstriptcentertstript translatet expandtabstswapcasetzfillt partitioncCs(tt|jtj|t|ƒƒƒƒS(N(RR#RR RUR(Rtsep((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRU¸s cCs(tt|jtj|t|ƒƒƒƒS(N(RR#RR t rpartitionR(RRV((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRW»s tformatt __getslice__(N(s __getitem__s capitalizestitleslowersuppersreplacesljustsrjustslstripsrstripscentersstrips translates expandtabssswapcaseszfill(Rt __module__RCt __slots__RR RRRRt__rmul__RR R!R R$R'R(R5R9t classmethodRRDtmethodtlocalsRRURWRXRY(((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRsF*                cCsLxE|D]=\}}t|dƒs1t|tƒrt|ƒ||ØscCstt|jƒƒS(N(tstrRR`(R:((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRfÙscCstt|jƒƒS(N(R RR`(R:((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRfÚscCsttt|jƒƒƒS(N(RgRtreprR`(R:((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRfÛscCs t|jƒS(N(RR`(R:((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRfÜscCs t|jƒS(N(tfloatR`(R:((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRfÝs( RRZRCRdREt__str__t __unicode__R t__int__t __float__(((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRÒs      (RRR(RCtret itertoolsRt__all__tcompileR7R3R RR<tobjectRtmarkupsafe._speedupsRRRt ImportErrortmarkupsafe._native(((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt s ´