3
7^Y	                 @   sZ   d Z ddlmZ G dd dZG dd deeZG dd de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.
    )wrapsc               @   s   e Zd Zdd ZdS )SafeDatac             C   s   | S )z
        Return the html representation of a string for interoperability.

        This allows other template engines to understand Django's SafeData.
         )selfr   r   9/tmp/pip-build-8app2_gc/Django/django/utils/safestring.py__html__   s    zSafeData.__html__N)__name__
__module____qualname__r   r   r   r   r   r      s   r   c                   s    e Zd ZdZ fddZ  ZS )	SafeBytesz
    A bytes subclass that has been specifically marked as "safe" (requires no
    further escaping) for HTML output purposes.

    Kept in Django 2.0 for usage by apps supporting Python 2. Shouldn't be used
    in Django anymore.
    c                s4   t  j|}t|trt|S t|tr0t|S |S )z
        Concatenating a safe byte string with another safe byte string or safe
        string is safe. Otherwise, the result is no longer safe.
        )super__add__
isinstanceSafeTextr   )r   rhst)	__class__r   r   r      s    

zSafeBytes.__add__)r   r	   r
   __doc__r   __classcell__r   r   )r   r   r      s   r   c                   s(   e Zd ZdZ fddZdd Z  ZS )r   zb
    A str subclass that has been specifically marked as "safe" for HTML output
    purposes.
    c                s"   t  j|}t|trt|S |S )z
        Concatenating a safe string with another safe bytestring or
        safe string is safe. Otherwise, the result is no longer safe.
        )r   r   r   r   r   )r   r   r   )r   r   r   r   /   s    
zSafeText.__add__c             C   s   | S )Nr   )r   r   r   r   __str__9   s    zSafeText.__str__)r   r	   r
   r   r   r   r   r   r   )r   r   r   *   s   
r   c                s   t   fdd}|S )Nc                 s    | |S )Nr   )argskwargs)funcsafety_markerr   r   wrappedA   s    z"_safety_decorator.<locals>.wrapped)r   )r   r   r   r   )r   r   r   _safety_decorator@   s    r   c             C   s(   t | dr| S t| r tt| S t| S )a  
    Explicitly mark a string as safe for (HTML) output purposes. The returned
    object can be used everywhere a string 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   )hasattrcallabler   	mark_safer   )sr   r   r   r   G   s
    	

r   N)r   Zdjango.utils.functionalr   r   bytesr   strr   Z
SafeStringr   r   r   r   r   r   <module>   s   
