U
    Mh	                  
   @   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testZ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   B/var/www/html/venv/lib/python3.8/site-packages/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|rtj|d dd}t
|D ]}t|td ||d qqt|td ||d qd 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         
r0   __main__)r   )r#   r+   r)   pathlibr   zipfiler   r   r   r   r   r0   __name__r   r   r   r   <module>   s*   
'