3
ªôÁgc
  ã               @   s8   d dl Z d dlZd dlmZ ddd„ZG dd„ dƒZdS )	é    N)ÚSuspiciousFileOperationFc             C   sj   t jj| ƒdkrtd|  ƒ‚|rJtj| ƒ}|jƒ s<d|jkrftd|  ƒ‚n| t jj| ƒkrftd|  ƒ‚| S )NÚ Ú.ú..z$Could not derive file name from '%s'z'Detected path traversal attempt in '%s'z%File name '%s' includes path elements>   r   r   r   )ÚosÚpathÚbasenamer   ÚpathlibÚPurePosixPathÚis_absoluteÚparts)ÚnameZallow_relative_pathr   © r   úU/var/www/tester-filtro-web/env/lib/python3.6/site-packages/django/core/files/utils.pyÚvalidate_file_name   s    
r   c               @   sä   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZ	edd„ ƒZ
ed	d„ ƒZed
d„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚFileProxyMixinzü
    A mixin class used to forward file methods to an underlaying file
    object.  The internal file object has to be called "file"::

        class FileProxy(FileProxyMixin):
            def __init__(self, file):
                self.file = file
    c             C   s   | j jS )N)ÚfileÚencoding)Úselfr   r   r   Ú<lambda>%   s    zFileProxyMixin.<lambda>c             C   s   | j jS )N)r   Úfileno)r   r   r   r   r   &   s    c             C   s   | j jS )N)r   Úflush)r   r   r   r   r   '   s    c             C   s   | j jS )N)r   Úisatty)r   r   r   r   r   (   s    c             C   s   | j jS )N)r   Únewlines)r   r   r   r   r   )   s    c             C   s   | j jS )N)r   Úread)r   r   r   r   r   *   s    c             C   s   | j jS )N)r   Úreadinto)r   r   r   r   r   +   s    c             C   s   | j jS )N)r   Úreadline)r   r   r   r   r   ,   s    c             C   s   | j jS )N)r   Ú	readlines)r   r   r   r   r   -   s    c             C   s   | j jS )N)r   Úseek)r   r   r   r   r   .   s    c             C   s   | j jS )N)r   Útell)r   r   r   r   r   /   s    c             C   s   | j jS )N)r   Útruncate)r   r   r   r   r   0   s    c             C   s   | j jS )N)r   Úwrite)r   r   r   r   r   1   s    c             C   s   | j jS )N)r   Ú
writelines)r   r   r   r   r   2   s    c             C   s   | j  p| j jS )N)r   Úclosed)r   r   r   r   r#   4   s    zFileProxyMixin.closedc             C   s$   | j r
dS t| jdƒr | jjƒ S dS )NFÚreadableT)r#   Úhasattrr   r$   )r   r   r   r   r$   8   s
    
zFileProxyMixin.readablec             C   s2   | j r
dS t| jdƒr | jjƒ S dt| jddƒkS )NFÚwritableÚwÚmoder   )r#   r%   r   r&   Úgetattr)r   r   r   r   r&   ?   s
    
zFileProxyMixin.writablec             C   s$   | j r
dS t| jdƒr | jjƒ S dS )NFÚseekableT)r#   r%   r   r*   )r   r   r   r   r*   F   s
    
zFileProxyMixin.seekablec             C   s
   t | jƒS )N)Úiterr   )r   r   r   r   Ú__iter__M   s    zFileProxyMixin.__iter__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r&   r*   r,   r   r   r   r   r      s(   r   )F)r   r	   Zdjango.core.exceptionsr   r   r   r   r   r   r   Ú<module>   s   
