U
    Td                     @   sH   d dl m Z  d dlZd dlZd dlZd dlZdd Zdd Zdd ZdS )	    )	unidecodeNc                 C   s"   t | } tdd| } d|  d S )Nz[^0-9a-zA-Z._-]+ z^[0-9a-zA-Z._-]+$)r   resub)filename r   3/var/www/html/subscibe_interface/interface/utils.pyfilename_to_regex   s    r
   c                 C   sX   t j| \}}ttj dd dddddd}t	 j
 d| | S )N.r    _:-)ospathsplitextstrdatetimenowsplitreplaceuuiduuid4hex)r   Zfilecharextr   r   r   r	   generate_name   s    0r   c              	   C   sV   t |t| d:}t| tkr0||   n|  D ]}|| q8W 5 Q R X d S )Nzwb+)openr   typewriteencodechunks)filer   r   destinationchunkr   r   r	   handle_uploaded_file   s
    r%   )r   r   r   r   r   r
   r   r%   r   r   r   r	   <module>   s   	