Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib64/python2.7/site-packages/markupsafe/ |
| [Home] [System Details] [Kill Me] |
�
"^�Lc@s�dZddlZddlmZddddgZejd�Zejd �Zdefd
��YZ d�Z
defd
��YZy 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(timaptMarkuptsoft_unicodetescapet
escape_silents(<!--.*?-->|<[^>]*>)s &([^;]+);cBsveZdZd'Zdd(dd�Zd�Zd�Zd�Zd�Z e Z
d�Zd �Zd
�Z
ej
je
_d�Zejje_d�Zejje_d
�Zejje_d�Zd�Zed��Zd�Zx!d)D]Zee�e�e<q�Weed"�r2d#�Zd$�Zneed%�rPed%�Zneed&�rned&�Zn[[RS(*sMarks
a string as being safe for inclusion in HTML/XML output without
needing to be escaped. This implements the `__html__` interface a
couple
of frameworks and web applications use. :class:`Markup` is a direct
subclass of `unicode` and provides all the methods of `unicode` just
that
it escapes arguments passed and always returns `Markup`.
The `escape` function returns markup objects so that double escaping
can't
happen.
The constructor of the :class:`Markup` class can be used for three
different things: When passed an unicode object it's assumed to
be safe,
when passed an object with an HTML representation (has an `__html__`
method) that representation is used, otherwise the object passed is
converted into a unicode string and then assumed to be safe:
>>> Markup("Hello <em>World</em>!")
Markup(u'Hello <em>World</em>!')
>>> class Foo(object):
... def __html__(self):
... return '<a href="#">foo</a>'
...
>>> Markup(Foo())
Markup(u'<a href="#">foo</a>')
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
<em>World</em>!")
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("<em>%s</em>")
>>> em % "foo & bar"
Markup(u'<em>foo & bar</em>')
>>> strong =
Markup("<strong>%(text)s</strong>")
>>> strong % {'text': '<blink>hacker
here</blink>'}
Markup(u'<strong><blink>hacker
here</blink></strong>')
>>> Markup("<em>Hello</em> ") +
"<foo>"
Markup(u'<em>Hello</em> <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|��}nt|�}|jtj||��S(N(RttupleRt_MarkupEscapeHelperRR t__mod__(Rtarg((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR]scCsd|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 »
<em>About</em>").unescape()
u'Main \xbb <em>About</em>'
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__.pythandle_match�s
(tmarkupsafe._constantsR)t
_entity_retsubR (RR1((R)s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pytunescapezscCs1djtjd|�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 »
<em>About</em>").striptags()
u'Main \xbb About'
u
t(R!t
_striptags_reR4R$RR5(Rtstripped((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt striptags�s!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(Rtstrv((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__.pytmake_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�scCs(tt|jtj|t|����S(N(RR#RR t
rpartitionR(RRV((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRW�stformatt__getslice__(N(s__getitem__s
capitalizestitleslowersuppersreplacesljustsrjustslstripsrstripscentersstrips translates
expandtabssswapcaseszfill(Rt
__module__RCt __slots__RR
RRRRt__rmul__RR
R!R R$R'R(R5R9tclassmethodRRDtmethodtlocalsRRURWRXRY(((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyRsF*
cCsLxE|D]=\}}t|d�s1t|t�rt|�||<qqW|S(s,Helper
for various string-wrapped
functions.R(RRRR(tobjtiterabletkeytvalue((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyR<�sRcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z RS(sHelper
for
Markup.__mod__cCs
||_dS(N(R`(RR`((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt__init__�scCst|j|�S(N(RR`(R:tx((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt<lambda>�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._speedupsRRRtImportErrortmarkupsafe._native(((s9/usr/lib64/python2.7/site-packages/markupsafe/__init__.pyt<module>
s�