Viewing File: /usr/lib64/python2.7/site-packages/markupsafe/__init__.pyo

ó
"^†Lc@sÛdZddlZddlmZddddgZejdƒZejd	ƒZdefd
„ƒYZ	d„Z
defd
„ƒ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„Zd	„Zd
„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 &lt;em&gt;World&lt;/em&gt;!')

    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 &amp; bar</em>')
    >>> strong = Markup("<strong>%(text)s</strong>")
    >>> strong % {'text': '<blink>hacker here</blink>'}
    Markup(u'<strong>&lt;blink&gt;hacker here&lt;/blink&gt;</strong>')
    >>> Markup("<em>Hello</em> ") + "<foo>"
    Markup(u'<em>Hello</em> &lt;foo&gt;')
    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 &raquo; <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__.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 &raquo;  <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	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(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__.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(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´	 

Back to Directory File Manager