U
    Hd1                     @   s   d dl m Z  d dlZd dlZd dlZd dlZd dlZeeZd dl	m
Z
 d dlmZ d dlmZ d dlZdZdd Zdd	d
Zdd ZdS )    )	unidecodeN)Pool)partial)BeautifulSoupzstatic/subtitles/c                 C   s"   t | } tdd| } d|  d S )Nz[^0-9a-zA-Z._-]+ z^[0-9a-zA-Z._-]+$)r   resub)filename r   0/var/www/html/TranscriptSport/interface/utils.pyfilename_to_regex   s    r   c                 C   s~   t j| \}}ttj dd dddddd}|d krf| dt	 j
 d| | S t	 j
 d| | S )N.r    _:-)ospathsplitextstrdatetimenowsplitreplaceuuiduuid4hex)r
   suffixZ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)   )N)r   r   r   r   r   logging	getLogger__file__loggermultiprocessingr   	functoolsr   Zbs4r   STATIC_FILESr   r    r)   r   r   r   r   <module>   s   

