o
    h	                     @   sn   d dl Z d dlZd dlZd dlmZ d dlmZ g dZdadd Z	ddd	Z
dddZedkr5e  dS dS )    N)Path)ZipFile)
dbmcursestkinterr   testtests	idle_testz__phello__.foo.pyz_bootstrap.pyz_bootstrap_external.py c                 C   s   |  |r| t|d  S | S )N)
startswithlen)textprefix r   d/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/utils/_zip.pyremove_prefix    s   
r   c                 C   s8   |t | td  }t|}|jtv rd S || | d S )N/)r   strip_file_dirr   name	DENY_LISTwrite)	file_pathstrip_file_pathzfprepend_str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 ]-}tj|rotj|d dd}t
|D ]}t|td ||d qaqLt|td ||d qLd 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_argsinstall_dirzip_name	strip_dirr   r   r   sortedr    osr   isdirglobr   )parserargszip_file_namer   r   pfilesr   r   r   r   main.   s@   r8   __main__)r
   )r   N)r(   r2   r0   pathlibr   zipfiler   r   r   r   r   r8   __name__r   r   r   r   <module>   s   

'
