
    %j
                     ^    d dl Z d dlZd dlZd dlmZ d Z G d de          Zd Zd Z	d Z
dS )	    N)ZipFilec                 <    t          t          | |                    S N)_Zipr   )fileobjmodes     T/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/mammoth/zips.pyopen_zipr
      s    &&'''    c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )r   c                     || _         d S r   )	_zip_file)selfzip_files     r	   __init__z_Zip.__init__   s    !r   c                     | S r    )r   s    r	   	__enter__z_Zip.__enter__   s    r   c                 8    | j                                          d S r   )r   close)r   argss     r	   __exit__z_Zip.__exit__   s    r   c                 Z    t          j        | j                            |                    S r   )
contextlibclosingr   openr   names     r	   r   z	_Zip.open   s#    !$."5"5d";";<<<r   c                 ^    	 | j                             |           dS # t          $ r Y dS w xY w)NTF)r   getinfoKeyErrorr   s     r	   existsz_Zip.exists   sD    	N""4(((4 	 	 	55	s    
,,c                 \    | j                             |                              d          S )Nutf8)r   readdecoder   s     r	   read_strz_Zip.read_str    s&    ~""4((//777r   N)	__name__
__module____qualname__r   r   r   r   r"   r'   r   r   r	   r   r      sn        " " "    = = =  8 8 8 8 8r   r   c                    t          | d          }	 t          j                    }t          |d          }	 t          |                                          t          |                                          z  }|D ]:}||v r	||         }n|                    |          }|                    ||           ;	 |                                 n# |                                 w xY w	 |                                 n# |                                 w xY w| 	                    d           |	                    d           t          j        ||            d S )Nrwr   )r   ioBytesIOsetnamelistkeysr%   writestrr   seekshutilcopyfileobj)r   filessourcedestination_fileobjdestinationnamesr   contentss           r	   
update_zipr=   $   sE   Wc""F jll1377		 ))**S->->>E 5 55==$T{HH%{{400H$$T844445 KLLOOOQ
*G44444s#   #C; B C 7C; C""C; ;Dc                 z    |                      dd          }t          |          dk    rd| fS t          |          S )N/    )rsplitlentuple)pathpartss     r	   
split_pathrG   ;   s:    KKQE
5zzQDzU||r   c                      t          t          d |                     }g }|D ]0}|                    d          r|g}|                    |           1d                    |          S )Nr?   )listfilter
startswithappendjoin)r   non_empty_pathsrelevant_pathsrE   s       r	   	join_pathrP   C   ss    6$--..ON ( (??3 	("VNN!!$''''88N###r   )r   r.   r5   zipfiler   r
   objectr   r=   rG   rP   r   r   r	   <module>rS      s        				       ( ( (8 8 8 8 86 8 8 805 5 5.  
$ 
$ 
$ 
$ 
$r   