B
    JDb                 @   s   d Z ddlmZmZ G dd deZG dd deeZG dd deeZ	G d	d
 d
eZ
G dd dee
ZG dd de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.
    )curryPromisec               @   s   e Zd ZdS )
EscapeDataN)__name__
__module____qualname__ r   r   *G:\easytimepro\master/mysite/safestring.pyr   	   s   r   c               @   s   e Zd ZdZdS )EscapeStringz;
    A 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 )EscapeUnicodezC
    A unicode 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S )SafeDataN)r   r   r   r   r   r   r	   r      s   r   c                   s>   e Zd ZdZ fddZdd Zdd Zeeej	dZ	  Z
S )	
SafeStringz
    A string subclass that has been specifically marked as "safe" (requires no
    further escaping) for HTML output purposes.
    c                s@   t |trt| | S t |tr,t| | S tt| |S dS )z
        Concatenating a safe string with another safe string or safe unicode
        object is safe. Otherwise, the result is no longer safe.
        N)
isinstanceSafeUnicoder   super__add__)selfrhs)	__class__r   r	   r       s
    

zSafeString.__add__c             C   s   | S )Nr   )r   r   r   r	   __str__,   s    zSafeString.__str__c             O   s8   | d}|| f||}t|tr,t|S t|S d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   strr   r   )r   argskwargsr   datar   r   r	   _proxy_method/   s
    

zSafeString._proxy_method)r   )r   r   r   r   r   r   r   r   r   decode__classcell__r   r   )r   r	   r      s
   r   c                   s6   e Zd ZdZ fddZdd ZeeejdZ  Z	S )r   zf
    A unicode subclass that has been specifically marked as "safe" for HTML
    output purposes.
    c                s*   t |trt| | S tt| |S dS )z
        Concatenating a safe unicode object with another safe string or safe
        unicode object is safe. Otherwise, the result is no longer safe.
        N)r   r   r   r   r   )r   r   )r   r   r	   r   C   s    
zSafeUnicode.__add__c             O   s8   | d}|| f||}t|tr,t|S t|S d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   M   s
    

zSafeUnicode._proxy_method)r   )
r   r   r   r   r   r   r   unicodeencoder   r   r   )r   r	   r   >   s   
r   c             C   sR   t | tr| S t | ts(t | tr0| jr0t| S t | ttfrFt| S t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   r   r   r   _delegate_strr   r    r   )sr   r   r	   	mark_safe\   s    
r$   c             C   sV   t | ttfr| S t | ts,t | tr4| jr4t| S t | ttfrJt| S t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).
    )	r   r   r   r   r   r"   r
   r    r   )r#   r   r   r	   mark_for_escapingk   s    r%   N)r   Zdjango.utils.functionalr   r   objectr   r   r
   r    r   r   r   r   r$   r%   r   r   r   r	   <module>   s   #