U
    xÊ¹jk	  ã                   @   s4   d dl Z d dlmZ d dlmZ G dd„ deƒZdS )é    N)ÚAbstractFileSystem)Útokenizec                   @   s>   e Zd ZdZdd„ ZeZdd„ Zdd„ Zdd	„ Zddd„Z	dS )ÚAbstractArchiveFileSystema(  
    A generic superclass for implementing Archive-based filesystems.

    Currently, it is shared amongst
    :class:`~fsspec.implementations.zip.ZipFileSystem`,
    :class:`~fsspec.implementations.libarchive.LibArchiveFileSystem` and
    :class:`~fsspec.implementations.tar.TarFileSystem`.
    c                 C   s   dt | ƒj› dt| ƒ› d�S )Nz<Archive-like object z at ú>)ÚtypeÚ__name__Úid©Úself© r   úM/var/www/html/bwave/python/venv/lib/python3.8/site-packages/fsspec/archive.pyÚ__str__   s    z!AbstractArchiveFileSystem.__str__c                 C   s   t || j| jƒS ©N)r   ÚfoÚprotocol)r
   Úpathr   r   r   Úukey   s    zAbstractArchiveFileSystem.ukeyc                    s:   t |ƒdkrtƒ S ‡ fdd„|D ƒˆ jh }|ˆ  |¡B S )z²Returns *all* directory names for each path in paths, including intermediate
        ones.

        Parameters
        ----------
        paths: Iterable of path strings
        r   c                    s   h | ]}ˆ   |¡’qS r   )Z_parent)Ú.0r   r	   r   r   Ú	<setcomp>$   s     z:AbstractArchiveFileSystem._all_dirnames.<locals>.<setcomp>)ÚlenÚsetZroot_markerÚ_all_dirnames)r
   ÚpathsÚdirnamesr   r	   r   r      s    z'AbstractArchiveFileSystem._all_dirnamesc                 K   sh   |   ¡  |  |¡}|dkr,| jr,ddddœS || jkr@| j| S |d | jkr\| j|d  S t|ƒ‚d S )N>   Ú ú/r   Ú	directoryr   )Únamer   Úsizer   )Ú	_get_dirsZ_strip_protocolÚ	dir_cacheÚFileNotFoundError)r
   r   Úkwargsr   r   r   Úinfo'   s    


zAbstractArchiveFileSystem.infoTc           
   	   K   sì   |   ¡  i }| j ¡ D ]ª\}}| d¡}d|krB| dd¡d }nd}|| d¡kr^|||< qtdd„ t| d¡dg| d¡ d¡ ƒD ƒƒr| d¡ dd¡d }||kr|dddœ}	|	||< q|ràt	| 
¡ t d	¡d
�}	|	S t	|ƒS d S )Nr   é   r   r   c                 s   s   | ]\}}||kV  qd S r   r   )r   ÚaÚbr   r   r   Ú	<genexpr>>   s   ÿz/AbstractArchiveFileSystem.ls.<locals>.<genexpr>r   )r   r   r   r   )Úkey)r   r    ÚitemsÚrstripÚrsplitÚallÚzipÚsplitÚstripÚsortedÚvaluesÚoperatorÚ
itemgetter)
r
   r   Údetailr"   r   ÚpÚfÚrootZppathÚoutr   r   r   Úls3   s(    

 þ
zAbstractArchiveFileSystem.lsN)T)
r   Ú
__module__Ú__qualname__Ú__doc__r   Ú__repr__r   r   r#   r9   r   r   r   r   r      s   	r   )r2   Zfsspecr   Zfsspec.utilsr   r   r   r   r   r   Ú<module>   s   