î
ªÍ Xß  ã               @   s6  d  Z  d d l Z d d l m Z d d l m Z d d l m Z m Z Gd d „  d e	 ƒ Z
 Gd d	 „  d	 e e
 ƒ Z Gd
 d „  d e j e
 ƒ Z e j r¥ e Z n e Z e Z Gd d „  d e	 ƒ Z Gd d „  d e e ƒ Z Gd d „  d e j e ƒ Z e j re Z n e Z e Z d d „  Z d d „  Z d S)a8  
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.
é    N)Úsix)ÚRemovedInDjango20Warning)ÚPromiseÚcurryc               @   s   e  Z d  Z d S)Ú
EscapeDataN)Ú__name__Ú
__module__Ú__qualname__© r
   r
   úE/home/ubuntu/projects/ifolica/build/django/django/utils/safestring.pyr      s   r   c               @   s   e  Z d  Z d Z d S)ÚEscapeBytesz@
    A byte string that should be HTML-escaped when output.
    N)r   r   r	   Ú__doc__r
   r
   r
   r   r      s   r   c               @   s   e  Z d  Z d Z d S)Ú
EscapeTextzJ
    A unicode string object that should be HTML-escaped when output.
    N)r   r   r	   r   r
   r
   r
   r   r      s   r   c               @   s   e  Z d  Z d d „  Z d S)ÚSafeDatac             C   s   |  S)z 
        Returns the html representation of a string for interoperability.

        This allows other template engines to understand Django's SafeData.
        r
   )Úselfr
   r
   r   Ú__html__(   s    zSafeData.__html__N)r   r   r	   r   r
   r
   r
   r   r   '   s   r   c                   sI   e  Z d  Z d Z ‡  f d d †  Z d d „  Z e e d e j ƒZ ‡  S)Ú	SafeByteszƒ
    A bytes subclass that has been specifically marked as "safe" (requires no
    further escaping) for HTML output purposes.
    c                sN   t  t |  ƒ j | ƒ } t | t ƒ r1 t | ƒ St | t ƒ rJ t | ƒ S| S)z¡
        Concatenating a safe byte string with another safe byte string or safe
        unicode string is safe. Otherwise, the result is no longer safe.
        )Úsuperr   Ú__add__Ú
isinstanceÚSafeText)r   ÚrhsÚt)Ú	__class__r
   r   r   6   s    

zSafeBytes.__add__c             O   sH   | j  d ƒ } | |  | | Ž } t | t ƒ r: t | ƒ St | ƒ Sd S)z°
        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.
        ÚmethodN)Úpopr   Úbytesr   r   )r   ÚargsÚkwargsr   Údatar
   r
   r   Ú_proxy_methodB   s
    
zSafeBytes._proxy_methodr   )	r   r   r	   r   r   r    r   r   Údecoder
   r
   )r   r   r   1   s   r   c                   sL   e  Z d  Z d Z ‡  f d d †  Z d d „  Z e e d e j j	 ƒZ	 ‡  S)r   z‚
    A unicode (Python 2) / str (Python 3) subclass that has been specifically
    marked as "safe" for HTML output purposes.
    c                s5   t  t |  ƒ j | ƒ } t | t ƒ r1 t | ƒ S| S)z¤
        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   )r   r
   r   r   W   s    
zSafeText.__add__c             O   sH   | j  d ƒ } | |  | | Ž } t | t ƒ r: t | ƒ St | ƒ Sd S)z°
        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   r
   r
   r   r    a   s
    
zSafeText._proxy_methodr   )
r   r   r	   r   r   r    r   r   Ú	text_typeÚencoder
   r
   )r   r   r   R   s   
r   c             C   sv   t  |  d ƒ r |  St |  t ƒ s: t |  t ƒ rD |  j rD t |  ƒ St |  t j t f ƒ rf t |  ƒ St	 t
 |  ƒ ƒ S)zÖ
    Explicitly mark a string as safe for (HTML) output purposes. The returned
    object can be used everywhere a string or unicode object is appropriate.

    Can be called multiple times on a single string.
    r   )Úhasattrr   r   r   Ú_delegate_bytesr   r   r"   r   Ú
SafeStringÚstr)Úsr
   r
   r   Ú	mark_safex   s    '

r)   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)zÜ
    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).
    z"mark_for_escaping() is deprecated.r   )ÚwarningsÚwarnr   r$   r   r   r   r   r%   r   r   r"   r   ÚEscapeStringr'   )r(   r
   r
   r   Úmark_for_escapingˆ   s    '

r-   )r   r*   Zdjango.utilsr   Zdjango.utils.deprecationr   Zdjango.utils.functionalr   r   Úobjectr   r   r   r"   r   ÚPY3r,   ZEscapeUnicoder   r   r   r&   ZSafeUnicoder)   r-   r
   r
   r
   r   Ú<module>   s(   		
!		