ó
³Ebc           @   sª  d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d	 l m	 Z	 d d
 l m
 Z
 d Z d d d d g Z e j d ƒ Z e j d ƒ Z d e	 f d „  ƒ  YZ d e f d „  ƒ  YZ e e	 d ƒ rd e j f d „  ƒ  YZ n  d „  Z d e f d „  ƒ  YZ y  d d l m Z m Z m Z Wn- e k
 r‰d d l m Z m Z m Z n Xe s¦e Z e j d ƒ n  d S(   s¹   
markupsafe
~~~~~~~~~~

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

:copyright: 2010 Pallets
:license: BSD-3-Clause
iÿÿÿÿNi   (   t	   int_types(   t	   iteritems(   t   Mapping(   t   PY2(   t   string_types(   t	   text_type(   t   unichrs   1.1.1t   Markupt   soft_unicodet   escapet   escape_silents   (<!--.*?-->|<[^>]*>)s   &([^& ;]+);c           B   sX  e  Z d  Z d' Z d d( d d „ Z d „  Z d „  Z d „  Z d „  Z	 e	 Z
 d „  Z d	 „  Z d
 „  Z e j j e _ d „  Z e j j e _ d „  Z e j j e _ d „  Z e j j e _ d „  Z d „  Z e d „  ƒ Z d „  Z x! d) D] Z e e ƒ e ƒ  e <qñ Wd" „  Z d# „  Z d$ „  Z d% „  Z e e d& ƒ rPe d& ƒ Z n  [ [ RS(*   sö  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;')
    u    t   strictc         C   sP   t  | d ƒ r | j ƒ  } n  | d  k r: t j |  | ƒ St j |  | | | ƒ S(   Nt   __html__(   t   hasattrR   t   NoneR   t   __new__(   t   clst   baset   encodingt   errors(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR   F   s
    c         C   s   |  S(   N(    (   t   self(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR   M   s    c         C   sJ   t  | t ƒ s t | d ƒ rF |  j t t |  ƒ j |  j | ƒ ƒ ƒ St S(   NR   (	   t
   isinstanceR   R   t	   __class__t   superR   t   __add__R	   t   NotImplemented(   R   t   other(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR   P   s    (c         C   s8   t  | d ƒ s t | t ƒ r4 |  j | ƒ j |  ƒ St S(   NR   (   R   R   R   R	   R   R   (   R   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   __radd__U   s    c         C   s,   t  | t ƒ r( |  j t j |  | ƒ ƒ St S(   N(   R   R    R   R   t   __mul__R   (   R   t   num(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR   Z   s    c            sY   t  | t ƒ r. t ‡  f d †  | Dƒ ƒ } n t | ˆ  j ƒ } ˆ  j t j ˆ  | ƒ ƒ S(   Nc         3   s!   |  ] } t  | ˆ  j ƒ Vq d  S(   N(   t   _MarkupEscapeHelperR	   (   t   .0t   x(   R   (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pys	   <genexpr>c   s    (   R   t   tupleR   R	   R   R   t   __mod__(   R   t   arg(    (   R   sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR"   a   s    c         C   s   d |  j  j t j |  ƒ f S(   Ns   %s(%s)(   R   t   __name__R   t   __repr__(   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR%   h   s    c         C   s%   |  j  t j |  t |  j | ƒ ƒ ƒ S(   N(   R   R   t   joint   mapR	   (   R   t   seq(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR&   k   s    c         O   s%   t  t |  j t j |  | | Ž ƒ ƒ S(   N(   t   listR'   R   R   t   split(   R   t   argst   kwargs(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR*   p   s    c         O   s%   t  t |  j t j |  | | Ž ƒ ƒ S(   N(   R)   R'   R   R   t   rsplit(   R   R+   R,   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR-   u   s    c         O   s%   t  t |  j t j |  | | Ž ƒ ƒ S(   N(   R)   R'   R   R   t
   splitlines(   R   R+   R,   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR.   z   s    c            s5   d d l  m ‰  ‡  f d †  } t j | t |  ƒ ƒ S(   sß   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>'
        i   (   t   HTML_ENTITIESc            s•   |  j  d ƒ } | ˆ  k r) t ˆ  | ƒ SyN | d  d k rS t t | d d ƒ ƒ S| j d ƒ rv t t | d ƒ ƒ SWn t k
 rŠ n X|  j  ƒ  S(   Ni   i   s   #xs   #Xi   t   #(   s   #xs   #X(   t   groupR   t   intt
   startswitht
   ValueError(   t   mt   name(   R/   (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   handle_matchˆ   s    (   t
   _constantsR/   t
   _entity_ret   subR   (   R   R7   (    (   R/   sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   unescape   s    c         C   s1   d j  t j d |  ƒ j ƒ  ƒ } t | ƒ j ƒ  S(   s¼   :meth:`unescape` the markup, remove tags, and normalize
        whitespace to single spaces.

        >>> Markup('Main &raquo;	<em>About</em>').striptags()
        'Main Â» About'
        u    t    (   R&   t   _striptags_reR:   R*   R   R;   (   R   t   stripped(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt	   striptags˜   s    !c         C   s)   t  | ƒ } | j |  k	 r% |  | ƒ S| S(   st   Escape a string. Calls :func:`escape` and ensures that for
        subclasses the correct type is returned.
        (   R	   R   (   R   t   st   rv(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR	   ¢   s    
c            s:   t  t |  ƒ ‰  ‡  f d †  } ˆ  j | _ ˆ  j | _ | S(   Nc            sS   t  t | ƒ t | ƒ |  j ƒ } t  | t | ƒ |  j ƒ |  j ˆ  |  | | Ž ƒ S(   N(   t   _escape_argspecR)   t	   enumerateR	   R   R   (   R   R+   R,   (   t   orig(    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   func¯   s    !(   t   getattrR   R$   t   __doc__(   R6   RE   (    (   RD   sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   make_simple_escaping_wrapper¬   s
    t   __getitem__t
   capitalizet   titlet   lowert   uppert   replacet   ljustt   rjustt   lstript   rstript   centert   stript	   translatet
   expandtabst   swapcaset   zfillc         C   s+   t  t |  j t j |  |  j | ƒ ƒ ƒ ƒ S(   N(   R!   R'   R   R   t	   partitionR	   (   R   t   sep(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyRY   Ì   s    c         C   s+   t  t |  j t j |  |  j | ƒ ƒ ƒ ƒ S(   N(   R!   R'   R   R   t
   rpartitionR	   (   R   RZ   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR[   Ï   s    c         O   s:   t  |  j ƒ } t | | ƒ } |  j | j |  | | ƒ ƒ S(   N(   t   EscapeFormatterR	   t   _MagicFormatMappingR   t   vformat(   R   R+   R,   t	   formatter(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   formatÒ   s    c         C   s   | r t  d ƒ ‚ n  |  S(   Ns,   Unsupported format specification for Markup.(   R4   (   R   t   format_spec(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   __html_format__×   s    t   __getslice__(    N(   RI   RJ   RK   RL   RM   RN   RO   RP   RQ   RR   RS   RT   RU   RV   RW   RX   (   R$   t
   __module__RG   t	   __slots__R   R   R   R   R   R   t   __rmul__R"   R%   R&   R   R*   R-   R.   R;   R?   t   classmethodR	   RH   t   methodt   localsRY   R[   R`   Rb   R   Rc   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR      s^   #												

	               
				R]   c           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sÍ   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.
    c         C   s   | |  _  | |  _ d |  _ d  S(   Ni    (   t   _argst   _kwargst   _last_index(   R   R+   R,   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   __init__ë   s    		c         C   sa   | d k rV |  j  } |  j  d 7_  y |  j | SWn t k
 rF n Xt | ƒ } n  |  j | S(   NR<   i   (   Rl   Rj   t   LookupErrort   strRk   (   R   t   keyt   idx(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyRI   ð   s    	c         C   s   t  |  j ƒ S(   N(   t   iterRk   (   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   __iter__û   s    c         C   s   t  |  j ƒ S(   N(   t   lenRk   (   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   __len__þ   s    (   R$   Rd   RG   Rm   RI   Rs   Ru   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR]   ã   s
   			R`   R\   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   R	   (   R   R	   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyRm     s    c         C   s—   t  | d ƒ r! | j | ƒ } nc t  | d ƒ rf | rW t d j | t | ƒ ƒ ƒ ‚ n  | j ƒ  } n t j j |  | t	 | ƒ ƒ } t	 |  j
 | ƒ ƒ S(   NRb   R   sž   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.(   R   Rb   R4   R`   t   typeR   t   stringt	   Formattert   format_fieldR   R	   (   R   t   valueRa   RA   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyRy     s    (   R$   Rd   Rm   Ry   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR\     s   	c         C   sL   xE | D]= \ } } t  | d ƒ s1 t | t ƒ r | | ƒ |  | <q q W|  S(   s,   Helper for various string-wrapped functions.R   (   R   R   R   (   t   objt   iterableR	   Rp   Rz   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyRB     s    R   c           B   sJ   e  Z d  Z d „  Z d „  Z d „  Z e Z d „  Z d „  Z d „  Z	 RS(   s   Helper for Markup.__mod__c         C   s   | |  _  | |  _ d  S(   N(   R{   R	   (   R   R{   R	   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyRm   (  s    	c         C   s   t  |  j | |  j ƒ S(   N(   R   R{   R	   (   R   t   item(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyRI   ,  s    c         C   s   t  |  j |  j ƒ ƒ S(   N(   R   R	   R{   (   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   __str__/  s    c         C   s   t  |  j t |  j ƒ ƒ ƒ S(   N(   Ro   R	   t   reprR{   (   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR%   4  s    c         C   s   t  |  j ƒ S(   N(   R2   R{   (   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   __int__7  s    c         C   s   t  |  j ƒ S(   N(   t   floatR{   (   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt	   __float__:  s    (
   R$   Rd   RG   Rm   RI   R~   t   __unicode__R%   R€   R‚   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyR   %  s   					(   R	   R
   R   t   soft_str(    RG   t   reRw   t   _compatR    R   R   R   R   R   R   t   __version__t   __all__t   compileR=   R9   R   R]   R   Rx   R\   RB   t   objectR   t	   _speedupsR	   R
   R   t   ImportErrort   _nativeR„   t   append(    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/markupsafe/__init__.pyt   <module>   s4   Ä	  