ó
Ñ7ec           @   s?  d  Z  d d l Z d d l m Z d d l m Z d d l m Z m Z m	 Z	 d e
 f d „  ƒ  YZ d e e f d	 „  ƒ  YZ d
 e j e f d „  ƒ  YZ e j r« e Z n e Z e Z d e
 f d „  ƒ  YZ d e e f d „  ƒ  YZ d e j e f d „  ƒ  YZ e j re Z n e Z e Z d „  Z d „  Z d „  Z d S(   s8  
Functions for working with "safe strings": strings that can be displayed safely
without further escaping in HTML. Marking something as a "safe string" means
that the producer of the string has already turned characters that should not
be interpreted by the HTML engine (e.g. '<') into the appropriate entities.
iÿÿÿÿN(   t   six(   t   RemovedInDjango20Warning(   t   Promiset   curryt   wrapst
   EscapeDatac           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR      s   t   EscapeBytesc           B   s   e  Z d  Z RS(   s@   
    A byte string that should be HTML-escaped when output.
    (   R   R   t   __doc__(    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR      s   t
   EscapeTextc           B   s   e  Z d  Z RS(   sJ   
    A unicode string object that should be HTML-escaped when output.
    (   R   R   R	   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR
      s   t   SafeDatac           B   s   e  Z d  „  Z RS(   c         C   s   |  S(   s    
        Returns the html representation of a string for interoperability.

        This allows other template engines to understand Django's SafeData.
        (    (   t   self(    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyt   __html__)   s    (   R   R   R   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR   (   s   t	   SafeBytesc           B   s5   e  Z d  Z d „  Z d „  Z e e d e j ƒZ RS(   sƒ   
    A bytes subclass that has been specifically marked as "safe" (requires no
    further escaping) for HTML output purposes.
    c         C   sN   t  t |  ƒ j | ƒ } t | t ƒ r1 t | ƒ St | t ƒ rJ t | ƒ S| S(   s¡   
        Concatenating a safe byte string with another safe byte string or safe
        unicode string is safe. Otherwise, the result is no longer safe.
        (   t   superR   t   __add__t
   isinstancet   SafeText(   R   t   rhst   t(    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR   7   s    

c         O   sH   | j  d ƒ } | |  | | Ž } t | t ƒ r: t | ƒ St | ƒ Sd S(   s°   
        Wrap a call to a normal unicode method up so that we return safe
        results. The method that is being wrapped is passed in the 'method'
        argument.
        t   methodN(   t   popR   t   bytesR   R   (   R   t   argst   kwargsR   t   data(    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyt   _proxy_methodC   s
    
R   (   R   R   R	   R   R   R   R   t   decode(    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR   2   s   		R   c           B   s8   e  Z d  Z d „  Z d „  Z e e d e j j ƒZ RS(   s‚   
    A unicode (Python 2) / str (Python 3) subclass that has been specifically
    marked as "safe" for HTML output purposes.
    c         C   s5   t  t |  ƒ j | ƒ } t | t ƒ r1 t | ƒ S| S(   s¤   
        Concatenating a safe unicode string with another safe byte string or
        safe unicode string is safe. Otherwise, the result is no longer safe.
        (   R   R   R   R   R   (   R   R   R   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR   X   s    
c         O   sH   | j  d ƒ } | |  | | Ž } t | t ƒ r: t | ƒ St | ƒ Sd S(   s°   
        Wrap a call to a normal unicode method up so that we return safe
        results. The method that is being wrapped is passed in the 'method'
        argument.
        R   N(   R   R   R   R   R   (   R   R   R   R   R   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR   b   s
    
R   (	   R   R   R	   R   R   R   R    t	   text_typet   encode(    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR   S   s   	
	c            s"   t  ˆ  ƒ ‡  ‡ f d †  ƒ } | S(   Nc             s   ˆ ˆ  |  | Ž  ƒ S(   N(    (   R   R   (   t   funct   safety_marker(    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyt   wrapped{   s    (   R   (   R    R   R!   (    (   R   R    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyt   _safety_decoratorz   s    c         C   s   t  |  d ƒ r |  St |  t ƒ s: t |  t ƒ rD |  j rD t |  ƒ St |  t j t f ƒ rf t |  ƒ St	 |  ƒ r t
 t |  ƒ St t |  ƒ ƒ S(   s  
    Explicitly mark a string as safe for (HTML) output purposes. The returned
    object can be used everywhere a string or unicode object is appropriate.

    If used on a method as a decorator, mark the returned data as safe.

    Can be called multiple times on a single string.
    R   (   t   hasattrR   R   R   t   _delegate_bytesR   R    R   R   t   callableR"   t	   mark_safet
   SafeStringt   str(   t   s(    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyR&      s    	'

c         C   s•   t  j d t ƒ t |  d ƒ s. t |  t ƒ r2 |  St |  t ƒ sY t |  t ƒ rc |  j rc t	 |  ƒ St |  t
 j t f ƒ r… t |  ƒ St t |  ƒ ƒ S(   sÜ   
    Explicitly mark a string as requiring HTML escaping upon output. Has no
    effect on SafeData subclasses.

    Can be called multiple times on a single string (the resulting escaping is
    only applied once).
    s"   mark_for_escaping() is deprecated.R   (   t   warningst   warnR   R#   R   R   R   R   R$   R   R    R   R
   t   EscapeStringR(   (   R)   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyt   mark_for_escaping•   s    '

(   R	   R*   t   django.utilsR    t   django.utils.deprecationR   t   django.utils.functionalR   R   R   t   objectR   R   R   R   R
   t   PY3R,   t   EscapeUnicodeR   R   R   R'   t   SafeUnicodeR"   R&   R-   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/utils/safestring.pyt   <module>   s*   		
!				