U
    8‹Ñh–	  ã                
   @   s~   d dl Z d dlZd dlZd dlmZ d dlmZ ddddddd	d
ddg
Zdadd„ Z	ddd„Z
ddœdd„Zedkrzeƒ  dS )é    N)ÚPath)ÚZipFileÚdbmZcursesÚtkinterÚtestÚtestsZ	idle_testz__phello__.foo.pyz_bootstrap.pyz_bootstrap_external.pyÚ c                 C   s   |   |¡r| t|ƒd … S | S )N)Ú
startswithÚlen)ÚtextÚprefix© r   ú>/tmp/user/2202/pip-unpacked-wheel-bf9o3bgk/torch/utils/_zip.pyÚremove_prefix    s    
r   c                 C   s8   |t | td ƒ }t|ƒ}|jtkr(d S | | |¡ d S )Nú/)r   Ústrip_file_dirr   ÚnameÚ	DENY_LISTÚwrite)Ú	file_pathZstrip_file_pathÚzfÚprepend_strZstripped_file_pathÚpathr   r   r   Úwrite_to_zip&   s
    
r   )Úreturnc                  C   sø   t jdd�} | jdddd� | jddd	d
� | jdddd
� | jddddd� | jdddd
� |  ¡ }|jd |j }|ja|j}t	|dd�}t
|jƒD ]Z}tj |¡rÞtj|d dd�}t
|ƒD ]}t|td ||d� qÂq˜t|td ||d� q˜d S )NzZip py source)ÚdescriptionÚpathsÚ*zPaths to zip.)ÚnargsÚhelpz--install-dirz--install_dirz#Root directory for all output files)r   z--strip-dirz--strip_dirz1The absolute directory we want to remove from zipz--prepend-strz--prepend_strz7A string to prepend onto all paths of a file in the zipr   )r   Údefaultz
--zip-namez
--zip_namezOutput zip namer   Úw)Úmodez/**/*.pyT)Ú	recursive)r   )ÚargparseÚArgumentParserÚadd_argumentÚ
parse_argsZinstall_dirÚzip_nameZ	strip_dirr   r   r   Úsortedr   Úosr   ÚisdirÚglobr   )ÚparserÚargsZzip_file_namer   r   ÚpÚfilesr   r   r   r   Úmain.   sF      ÿýü   ÿ
r1   Ú__main__)r   )r$   r,   r*   Úpathlibr   Úzipfiler   r   r   r   r   r1   Ú__name__r   r   r   r   Ú<module>   s*   ñ
'