/usr/local/lib/python3.6/site-packages/datasets/filesystems/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/datasets/filesystems/__pycache__/compression.cpython-36.pyc (6142B)
3
<%EgV @ s d dl Z d dlmZ d dlZd dlmZ d dlmZ G dd deZG dd deZ G d d
d
eZ
G dd deZG d
d deZG dd deZ
dS ) N)Optional)AbstractArchiveFileSystem)DEFAULT_BLOCK_SIZEc s e Zd ZU dZdZdZedZedZedee e e e
d fdd
Ze fddZ
d d
Zeddd
ZdeedddZ ZS )BaseCompressedFileFileSystemzFRead contents of compressed file as a filesystem with one file inside. N)fotarget_protocoltarget_optionsc s t j| f| tj|fd|| jd|p*i | _tjj| jjj dd | _
d| j
krn| j
d| j
jd n| j
| _d| _
dS )a
The compressed file system can be instantiated from any compressed file.
It reads the contents of compressed file as a filesystem with one file inside, as if it was an archive.
The single file inside the filesystem is named after the compresssed file,
without the compression extension at the end of the filename.
Args:
fo (:obj:``str``): Path to compressed file. Will fetch file using ``fsspec.open()``
mode (:obj:``str``): Currently, only 'rb' accepted
target_protocol(:obj:``str``, optional): To override the FS protocol inferred from a URL.
target_options (:obj:``dict``, optional): Kwargs passed when instantiating the target FS.
rb)modeprotocolcompressionz::r .N)super__init__fsspecopenr
fileospathbasenamesplitcompressed_namerindexuncompressed_name dir_cache)selfr r r kwargs) __class__ J/usr/local/lib/python3.6/site-packages/datasets/filesystems/compression.pyr s z%BaseCompressedFileFileSystem.__init__c s t j|jdS )N/)r _strip_protocollstrip)clsr )r r r r" 0 s z,BaseCompressedFileFileSystem._strip_protocolc C s8 | j d kr4| jjj| jjd| ji}|d |i| _ d S )Nname)r r fsinfor r )r fr r r _get_dirs5 s
z&BaseCompressedFileFileSystem._get_dirs)r c C s | j j j S )N)r r read)r r r r r cat: s z BaseCompressedFileFileSystem.catr
T)r r c K s6 | j |}|dkr,td| d| jj d| jj S )Nr
zTried to read with mode z on file z opened with mode 'rb')r"
ValueErrorr r r )r r r
block_sizeZ
autocommitZ
cache_optionsr r r r _open= s
z"BaseCompressedFileFileSystem._open)r NN)r
NTN)__name__
__module____qualname____doc__Zroot_markerr strr
extensionr dictr classmethodr" r) r+ r.
__classcell__r r )r r r s
r c @ s e Zd ZdZdZdZdZdS )
Bz2FileSystemz?Read contents of BZ2 file as a filesystem with one file inside.bz2z.bz2N)r/ r0 r1 r2 r r
r4 r r r r r8 L s r8 c @ s e Zd ZdZdZdZdZdS )GzipFileSystemz@Read contents of GZIP file as a filesystem with one file inside.gzipz.gzN)r/ r0 r1 r2 r r
r4 r r r r r: T s r: c @ s e Zd ZdZdZdZdZdS )
Lz4FileSystemz?Read contents of LZ4 file as a filesystem with one file inside.Zlz4z.lz4N)r/ r0 r1 r2 r r
r4 r r r r r<