ó
i4Vdc           @  sí  d  Z  d d l m Z d d l Z d d l Z d d l m Z d d l m Z d d l	 m
 Z
 m Z d d l m Z d d l m Z m Z d d	 l m Z m Z m Z d d
 l m Z m Z m Z m Z m Z m Z d d l m Z d d l m Z m  Z  d d d d d d d d g Z! dS dT dU dV dW dX g Z" d d d  d! d" d# g Z# e j$ d$ ƒ Z% e j$ d% ƒ Z& e j$ d& e j' ƒ Z( e j$ d' e j' ƒ Z) e j$ d( ƒ Z* e j$ d) ƒ Z+ e j$ d* e j' ƒ Z, e j$ d+ d, j- d- „  e# Dƒ ƒ e j. ƒ Z/ e j$ d. ƒ Z0 d/ „  Z1 e e1 e j2 e ƒ Z1 i d0 e3 d1 ƒ 6d2 e3 d ƒ 6d3 e3 d ƒ 6d4 e3 d ƒ 6d5 e3 d ƒ 6d6 e3 d7 ƒ 6d8 e3 d9 ƒ 6d: e3 d; ƒ 6d< e3 d ƒ 6d= e3 d> ƒ 6d? e3 d@ ƒ 6Z4 e4 j5 dA „  e6 dB ƒ Dƒ ƒ dC „  Z7 e e7 e j2 e ƒ Z7 dD „  Z8 dE „  Z9 dF „  Z: e; dG „ Z< e e< e j2 ƒ Z< dH e  f dI „  ƒ  YZ= dJ „  Z> dK „  Z? e e? ƒ Z? dL „  Z@ e e@ e j2 ƒ Z@ dM „  ZA e eA e j2 ƒ ZA dN „  ZB e eB e j2 ƒ ZB dO „  ZC d e; e; dP „ ZE e eE e j2 ƒ ZE dQ „  ZF dR „  ZG d S(Y   u'   HTML utilities suitable for global use.iÿÿÿÿ(   t   unicode_literalsN(   t   six(   t   RemovedInDjango110Warning(   t	   force_strt
   force_text(   t
   allow_lazy(   t   RFC3986_GENDELIMSt   RFC3986_SUBDELIMS(   t   SafeDatat   SafeTextt	   mark_safe(   t	   parse_qslt   quotet   unquotet	   urlencodet   urlsplitt
   urlunsplit(   t   normalize_newlinesi   (   t   HTMLParseErrort
   HTMLParseru   .u   ,u   :u   ;u   .)u   "u   'u   !u   (u   )u   <u   >u   [u   ]u   &lt;u   &gt;u   &middot;u   *u   â€¢u   &#149;u   &bull;u   &#8226;u   &(?!(\w+|#\d+);)u   ([\s<>"']+)u   ^https?://\[?\wu>   ^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net|org)($|/.*)$u   ^\S+@\S+\.\S+$u   (<a [^>]*?)target=[^\s>]+ub   (?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)u%   ((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)u   |c         c  s   |  ] } t  j | ƒ Vq d  S(   N(   t   ret   escape(   t   .0t   x(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pys	   <genexpr>&   s   u(   (?:<p>(?:&nbsp;|\s|<br \/>)*?</p>\s*)+\Zc         C  sL   t  t |  ƒ j d d ƒ j d d ƒ j d d ƒ j d d ƒ j d	 d
 ƒ ƒ S(   u*  
    Returns the given text with ampersands, quotes and angle brackets encoded
    for use in HTML.

    This function always escapes its input, even if it's already escaped and
    marked as such. This may result in double-escaping. If this is a concern,
    use conditional_escape() instead.
    u   &u   &amp;u   <u   &lt;u   >u   &gt;u   "u   &quot;u   'u   &#39;(   R
   R   t   replace(   t   text(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyR   +   s    	'u   \u005Cu   \u   \u0027u   \u0022u   \u003Eu   \u003Cu   \u0026u   &u   \u003Du   =u   \u002Du   -u   \u003Bu   \u2028u   â€¨u   \u2029u   â€©c         c  s)   |  ] } t  d  | ƒ d | f Vq d S(   u   %cu   \u%04XN(   t   ord(   R   t   z(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pys	   <genexpr>G   s    i    c         C  s   t  t |  ƒ j t ƒ ƒ S(   u5   Hex encodes characters for use in JavaScript strings.(   R
   R   t	   translatet   _js_escapes(   t   value(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   escapejsJ   s    c         C  s'   t  |  d ƒ r |  j ƒ  St |  ƒ Sd S(   uá   
    Similar to escape(), except that it doesn't operate on pre-escaped strings.

    This function relies on the __html__ convention used both by Django's
    SafeData class and by third-party libraries like markupsafe.
    u   __html__N(   t   hasattrt   __html__R   (   R   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   conditional_escapeP   s    
c         O  s>   t  t | ƒ } d „  t j | ƒ Dƒ } t |  j | | Ž  ƒ S(   uê   
    Similar to str.format, but passes all arguments through conditional_escape,
    and calls 'mark_safe' on the result. This function should be used instead
    of str.format or % interpolation to build up small HTML fragments.
    c         S  s%   i  |  ] \ } } t  | ƒ | “ q S(    (   R"   (   R   t   kt   v(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pys
   <dictcomp>d   s   	 (   t   mapR"   R   t	   iteritemsR
   t   format(   t   format_stringt   argst   kwargst	   args_safet   kwargs_safe(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   format_html]   s    c           s)   t  t |  ƒ j ‡  f d †  | Dƒ ƒ ƒ S(   uò  
    A wrapper of format_html, for the common case of a group of arguments that
    need to be formatted using the same format string, and then joined using
    'sep'. 'sep' is also passed through conditional_escape.

    'args_generator' should be an iterator that returns the sequence of 'args'
    that will be passed to format_html.

    Example:

      format_html_join('
', "<li>{} {}</li>", ((u.first_name, u.last_name)
                                                  for u in users))
    c         3  s$   |  ] } t  ˆ  t | ƒ Œ Vq d  S(   N(   R-   t   tuple(   R   R)   (   R(   (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pys	   <genexpr>w   s   (   R
   R"   t   join(   t   sepR(   t   args_generator(    (   R(   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   format_html_joinh   s    c         C  sŒ   t  |  ƒ }  t j d |  ƒ } | rV g  | D]" } d t | ƒ j d d ƒ ^ q+ } n) g  | D] } d | j d d ƒ ^ q] } d j | ƒ S(   u'   Converts newlines into <p> and <br />s.u   
{2,}u	   <p>%s</p>u   
u   <br />u   

(   R   R   t   splitR   R   R/   (   R   t
   autoescapet   parast   p(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt
   linebreaks{   s    2)t
   MLStripperc           B  s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C  s$   t  j |  ƒ |  j ƒ  g  |  _ d  S(   N(   R   t   __init__t   resett   fed(   t   self(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyR9   ˆ   s    
c         C  s   |  j  j | ƒ d  S(   N(   R;   t   append(   R<   t   d(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   handle_data   s    c         C  s   |  j  j d | ƒ d  S(   Nu   &%s;(   R;   R=   (   R<   t   name(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   handle_entityref   s    c         C  s   |  j  j d | ƒ d  S(   Nu   &#%s;(   R;   R=   (   R<   R@   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   handle_charref“   s    c         C  s   d j  |  j ƒ S(   Nu    (   R/   R;   (   R<   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   get_data–   s    (   t   __name__t
   __module__R9   R?   RA   RB   RC   (    (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyR8   ‡   s
   				c         C  sm   t  ƒ  } y | j |  ƒ Wn t k
 r. |  SXy | j ƒ  Wn t k
 r^ | j ƒ  | j SX| j ƒ  Sd S(   u<   
    Internal tag stripping utility used by strip_tags.
    N(   R8   t   feedR   t   closeRC   t   rawdata(   R   t   s(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   _strip_onceš   s    	c         C  sQ   xJ d |  k rL d |  k rL t  |  ƒ } t | ƒ t |  ƒ k rC Pn  | }  q W|  S(   u.   Returns the given HTML with all tags stripped.u   <u   >(   RJ   t   len(   R   t	   new_value(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt
   strip_tags«   s    
c         C  s¥   t  j d t d d ƒg  | j ƒ  D] } t j | ƒ ^ q# } d d j | ƒ } t j d | t j ƒ } t j d | ƒ } | j	 d |  ƒ }  | j	 d |  ƒ }  |  S(	   u/   Returns the given HTML with given tags removed.u}   django.utils.html.remove_tags() and the removetags template filter are deprecated. Consider using the bleach library instead.t
   stackleveli   u   (%s)u   |u   <%s(/?>|(\s+[^>]*>))u   </%s>u    (
   t   warningst   warnR   R3   R   R   R/   t   compilet   Ut   sub(   t   htmlt   tagst   tagt   tags_ret   starttag_ret	   endtag_re(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   remove_tags»   s    (c         C  s   t  j d d t |  ƒ ƒ S(   u8   Returns the given HTML with spaces between tags removed.u   >\s+<u   ><(   R   RS   R   (   R   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   strip_spaces_between_tagsÌ   s    c         C  s/   t  j d t d d ƒt j d d t |  ƒ ƒ S(   u@   Returns the given HTML with all entities (&something;) stripped.u1   django.utils.html.strip_entities() is deprecated.RN   i   u   &(?:\w+|#\d+);u    (   RO   RP   R   R   RS   R   (   R   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   strip_entitiesÒ   s    c   	      C  s  d „  } y t  |  ƒ \ } } } } } Wn t k
 rB | |  ƒ SXy | j d ƒ j d ƒ } Wn t k
 ry | |  ƒ SX| rÚ g  t | d t ƒD]2 } t t | d ƒ ƒ t t | d ƒ ƒ f ^ q“ } t	 | ƒ } n  | | ƒ } | | ƒ } t
 | | | | | f ƒ S(   u(   Quotes a URL if it isn't already quoted.c         S  s<   t  t |  ƒ ƒ }  t |  d t t t d ƒ ƒ}  t |  ƒ S(   Nt   safeu   ~(   R   R   R   R   R   t   strR   (   t   segment(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   unquote_quoteÞ   s     u   idnau   asciit   keep_blank_valuesi    i   (   R   t
   ValueErrort   encodet   decodet   UnicodeErrorR   t   TrueR   R   R   R   (	   t   urlR`   t   schemet   netloct   patht   queryt   fragmentt   qt   query_parts(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   smart_urlquoteÜ   s     		Hc         C  sY  t  |  t ƒ } | d „ } d „  } t j t |  ƒ ƒ } xt | ƒ D]\ } }	 d |	 k sv d |	 k sv d |	 k rd |	 d }
 } } x; t D]3 } | j | ƒ r‘ | t | ƒ  } | | } q‘ q‘ Wx t	 D]‡ \ } } | j
 | ƒ r| t | ƒ } |
 | }
 n  | j | ƒ rÏ | j | ƒ | j | ƒ d k rÏ | t | ƒ  } | | } qÏ qÏ Wd } | rld n d } t j | ƒ r¨| | | ƒ \ } } } t | ƒ } n¹ t j | ƒ râ| | | ƒ \ } } } t d	 | ƒ } n d | k rat j | ƒ ra| j d d ƒ \ } } y | j d
 ƒ j d ƒ } Wn t k
 rGqF n Xd | | f } d } n  | rá| | ƒ } | r¨| r¨t |
 ƒ t | ƒ }
 } t | ƒ } n  d t | ƒ | | f } t d |
 | | f ƒ | | <qH| rút |	 ƒ | | <qH| rHt |	 ƒ | | <qHqF | r/t |	 ƒ | | <qF | rF t |	 ƒ | | <qF qF Wd j | ƒ S(   u­  
    Converts any URLs in text into clickable links.

    Works on http://, https://, www. links, and also on links ending in one of
    the original seven gTLDs (.com, .edu, .gov, .int, .mil, .net, and .org).
    Links can have trailing punctuation (periods, commas, close-parens) and
    leading punctuation (opening parens) and it'll still do the right thing.

    If trim_url_limit is not None, the URLs in the link text longer than this
    limit will be truncated to trim_url_limit-3 characters and appended with
    an ellipsis.

    If nofollow is True, the links will get a rel="nofollow" attribute.

    If autoescape is True, the link text and URLs will be autoescaped.
    c         S  s;   | d  k s t |  ƒ | k r" |  Sd |  t d | d ƒ  S(   Nu   %s...i    i   (   t   NoneRK   t   max(   R   t   limit(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   trim_url  s    c         S  s›   |  | j  d d ƒ j  d d ƒ j  d d ƒ j  d d ƒ j  d	 d
 ƒ } | ro | j | ƒ ro | t | ƒ  } n | d k rŽ |  | 7}  d } n  |  | | f S(   uÎ   
        If input URL is HTML-escaped, unescape it so as we can safely feed it to
        smart_urlquote. For example:
        http://example.com?x=1&amp;y=&lt;2&gt; => http://example.com?x=1&y=<2>
        u   &amp;u   &u   &lt;u   <u   &gt;u   >u   &quot;u   "u   &#39;u   'u   ;u    (   R   t   endswithRK   (   R   t   trailt	   unescaped(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   unescape  s    
$
	u   .u   @u   :u    i   u    rel="nofollow"u	   http://%su   idnau   asciiu   mailto:%s@%su   <a href="%s"%s>%s</a>u   %s%s%sN(   t
   isinstanceR   t   word_split_reR3   R   t	   enumeratet   TRAILING_PUNCTUATIONRt   RK   t   WRAPPING_PUNCTUATIONt
   startswitht   countRp   t   simple_url_ret   matchRo   t   simple_url_2_ret   simple_email_ret   rsplitRc   Rd   Re   R   R
   R/   (   R   t   trim_url_limitt   nofollowR4   t
   safe_inputRs   Rw   t   wordst   it   wordt   leadt   middleRu   t   punctuationt   openingt   closingRg   t   nofollow_attrt   middle_unescapedt   localt   domaint   trimmed(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   urlize   sf    	$"	 c         C  s   |  j  d d ƒ S(   u„   
    Avoid text wrapping in the middle of a phrase by adding non-breaking
    spaces where there previously were normal spaces.
    u    u   Â (   R   (   R   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   avoid_wrappingd  s    c           sÍ   d |  j  k r% t d |  j ƒ ‚ n  t j r} d |  j  k rS t d |  j ƒ ‚ n  |  j ‰ ‡ f d †  |  _ d „  |  _ nL d |  j  k r¢ t d |  j ƒ ‚ n  |  j ‰  ‡  f d	 †  |  _ d
 „  |  _ |  S(   u”   
    A decorator that defines the __html__ method. This helps non-Django
    templates to detect classes whose __str__ methods return SafeText.
    u   __html__u;   can't apply @html_safe to %s because it defines __html__().u   __unicode__uE   can't apply @html_safe to %s because it doesn't define __unicode__().c           s   t  ˆ  |  ƒ ƒ S(   N(   R
   (   R<   (   t   klass_unicode(    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   <lambda>}  t    c         S  s
   t  |  ƒ S(   N(   t   unicode(   R<   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyR—   ~  R˜   u   __str__uA   can't apply @html_safe to %s because it doesn't define __str__().c           s   t  ˆ  |  ƒ ƒ S(   N(   R
   (   R<   (   t	   klass_str(    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyR—   †  R˜   c         S  s
   t  |  ƒ S(   N(   R^   (   R<   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyR—   ‡  R˜   (   t   __dict__Rb   RD   R   t   PY2t   __unicode__R!   t   __str__(   t   klass(    (   Rš   R–   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt	   html_safel  s(    			(   u   (u   )(   u   <u   >(   u   [u   ](   u   &lt;u   &gt;(   u   "u   "(   u   'u   '(H   t   __doc__t
   __future__R    R   RO   t   django.utilsR   t   django.utils.deprecationR   t   django.utils.encodingR   R   t   django.utils.functionalR   t   django.utils.httpR   R   t   django.utils.safestringR   R	   R
   t#   django.utils.six.moves.urllib.parseR   R   R   R   R   R   t   django.utils.textR   t   html_parserR   R   R{   R|   t   DOTSRQ   t   unencoded_ampersands_reRy   t
   IGNORECASER   R   R‚   t   link_target_attribute_ret   html_gunk_reR/   t   DOTALLt   hard_coded_bullets_ret   trailing_empty_content_reR   t	   text_typeR   R   t   updatet   rangeR   R"   R-   R2   t   FalseR7   R8   RJ   RM   RZ   R[   R\   Ro   Rp   R”   R•   R    (    (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/html.pyt   <module>   s‚   .												$a	