
    çg                         d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ dddZ	 e j
        d          Z G d	 d
e          ZdS )    N)AbstractArchiveFileSystem)compr)infer_compressionfile	directory)   0   5tarc                   N     e Zd ZdZdZdZdZ	 	 	 	 	 d fd	Zd Zd Z	dd
Z
 xZS )TarFileSystemzzCompressed Tar archives as a file-system (read-only)

    Supports the following formats:
    tar.gz, tar.bz2, tar.xz
     r
   FNc                 d    t                      j        d
i | |pi }t          |t                    r2t	          j        |fd|i|| _        | j                                        }|d }	 t          |d          r|j        }nZt          |d          r|j	        }nBt          |d          r|j
        }n*t          |d          r|                                d         }n4# t          $ r'}t                              d|            Y d }~nd }~ww xY w|/t          |          }t                              d| d|            |t!          |         |          }|| _        || _        t'          j        | j        	          | _        d | _        || _        d | _        |                                  d S )Nprotocoloriginalpathnameinfoz:Unable to determine file name, not inferring compression: zInferred compression z from file name )fileobj )super__init__
isinstancestrfsspecopenofhasattrr   r   r   r   	Exceptionloggerwarningr   r   _fo_reffotarfileTarFiler
   	dir_cacheindex_storeindex_index)
selfr"   r&   target_optionstarget_protocolcompressionkwargsr   ex	__class__s
            V/var/www/html/ai-engine/env/lib/python3.11/site-packages/fsspec/implementations/tar.pyr   zTarFileSystem.__init__   s    	""6"""'-2b# 	 k"QQQ.QQDGB D

 2z** -;DD R(( 	-7DD R(( -7DD R(( -7799V,D   UQSUU       
 /55WKWWQUWWXXX" {#B''B?47333&
s   +A2C 
D(D

Dc                    i }| j         D ]s}|                                }t                              |d         d          |d<   |                                d                             d          }||j        f||<   t|| _        d S )Ntyper   r   /)r
   get_infotypemapgetrstripoffset_datar'   )r)   outtir   r   s        r0   r(   zTarFileSystem._index[   s}    ( 	/ 	/B;;==D";;tF|V<<DL;;==(//44Dr~.CII


    c                    | j         d S d |                     | j                                                  D             | _         | j                                        D ]h}|                                }|d                             d          |d<   t                              |d         d          |d<   || j         |d         <   id S )Nc                     i | ]	}||d dd
S )r   r   )r   sizer2   r   ).0dirnames     r0   
<dictcomp>z+TarFileSystem._get_dirs.<locals>.<dictcomp>l   s4     
 
 
 gq+FF
 
 
r;   r   r3   r2   r   )	r%   _all_dirnamesr
   getnames
getmembersr4   r7   r5   r6   )r)   memberr   s      r0   	_get_dirszTarFileSystem._get_dirsg   s    >%F
 
--dh.?.?.A.ABB
 
 
 h))++ 	0 	0F??$$D<..s33DL";;tF|V<<DL+/DN4<((		0 	0r;   rbc                     |dk    rt          d          | j        |         \  }}|d         dk    rt          d          | j                            |          S )NrG   z#Read-only filesystem implementationr2   r   zCan only handle regular files)
ValueErrorr'   r
   extractfile)r)   r   moder-   detailsoffsets         r0   _openzTarFileSystem._openv   s^    4<<BCCC*T*6?f$$<===x##D)))r;   )r   NNNN)rG   )__name__
__module____qualname____doc__root_markerr   cachabler   r(   rF   rN   __classcell__)r/   s   @r0   r   r      s          KHH @ @ @ @ @ @D	 	 	0 0 0* * * * * * * *r;   r   )loggingr#   r   fsspec.archiver   fsspec.compressionr   fsspec.utilsr   r5   	getLoggerr   r   r   r;   r0   <module>r[      s       4 4 4 4 4 4 $ $ $ $ $ $ * * * * * *{
+
+		5	!	!n* n* n* n* n*- n* n* n* n* n*r;   