U
    '1eÓ  ã                   @   sH   d Z dZddlmZ G dd„ dƒZeƒ ZG dd„ dƒZeƒ ZedƒZd	S )
z3.3.0zALogging and warning framework, predating Python's logging packageé    )Ústderrc                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚLoggerz‡
    An extended file type thing initially equivalent to sys.stderr
    You can add/remove file type things; it has a write method
    c                 C   s   t g| _i | _d S ©N)r   Ú_fpsÚ_fns)Úself© r   ú8/tmp/pip-unpacked-wheel-109iniqw/reportlab/lib/logger.pyÚ__init__   s    zLogger.__init__c                 C   s<   t |tƒr,|| jkrdS ttdƒ}|| jt< | j |¡ dS )z*add the file/string fp to the destinationsNÚwb)Ú
isinstanceÚstrr   ÚopenÚfnr   Úappend)r   Úfpr   r   r	   Úadd   s    

 

z
Logger.addc                 C   sL   t |tƒr.|| jkrdS |}| j| }| j|= || jkrH| j| j |¡= dS )z/remove the file/string fp from the destinationsN)r   r   r   Úfnsr   Úindex)r   r   r   r   r   r	   Úremove   s    

 

zLogger.removec                 C   s.   |d dkr|d }| j D ]}| |¡ qdS )z"write text to all the destinationséÿÿÿÿÚ
N)r   Úwrite)r   Útextr   r   r   r	   r   #   s     
 zLogger.writec                 C   s   |   |¡ d S r   )r   )r   r   r   r   r	   Ú__call__(   s    zLogger.__call__N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r   r   r   r   r	   r      s   
r   c                   @   s&   e Zd Zd	dd„Zdd„ Zdd„ ZdS )
ÚWarnOnceÚWarnc                 C   s   i | _ d| | _d| _d S )Nz%s: é   )ÚutteredÚpfxÚenabled)r   Úkindr   r   r	   r
   /   s    
zWarnOnce.__init__c                 C   s.   || j kr*| jr t | j| ¡ d| j |< d S )Nr!   )r"   r$   Úloggerr   r#   ©r   Úwarningr   r   r	   Úonce4   s    
 zWarnOnce.oncec                 C   s   |   |¡ d S r   )r)   r'   r   r   r	   r   9   s    zWarnOnce.__call__N)r    )r   r   r   r
   r)   r   r   r   r   r	   r   -   s   
r   ZInfoN)	Ú__version__r   Úsysr   r   r&   r   ZwarnOnceZinfoOncer   r   r   r	   Ú<module>   s   #