B
    ÛT•\Ö  ã               @   s^   d dl mZmZmZ d dlmZ d dlZddlmZ ddlm	Z	 G dd	„ d	e
ƒZeejd
< dS )é    )Úprint_functionÚdivisionÚabsolute_import)ÚglobNé   )Úcoreé   )Útokenizec               @   sX   e Zd ZdZejZdd„ Zdd„ Zdd„ Zdd	„ Z	ddd„Z
dd„ Zdd„ Zdd„ ZdS )ÚLocalFileSystemz«API spec for the methods a filesystem

    A filesystem must provide these methods, if it is to be registered as
    a backend for dask.

    Implementation for local discc             K   s   t  ¡ | _dS )z¢
        Parameters
        ----------
        storage_options: key-value
            May be credentials, or other configuration specific to the backend.
        N)ÚosÚgetcwdÚcwd)ÚselfZstorage_options© r   ú/lib/python3.7/site-packages/dask/bytes/local.pyÚ__init__   s    zLocalFileSystem.__init__c             C   s(   t j |¡st j | j|¡S t j |¡S )z(Ensure paths are absolute and normalized)r   ÚpathÚisabsÚjoinr   Únormpath)r   r   r   r   r   Ú_normalize_path   s    zLocalFileSystem._normalize_pathc             C   s   t t|  |¡ƒƒS )z*For a template path, return matching files)Úsortedr   r   )r   r   r   r   r   r   "   s    zLocalFileSystem.globc             C   sB   |   |¡}yt |¡ W n$ tk
r<   tj |¡s8t‚Y nX dS )z7Make any intermediate directories to make path writableN)r   r   ÚmakedirsÚOSErrorr   ÚisdirÚAssertionError)r   r   r   r   r   Úmkdirs&   s
    
zLocalFileSystem.mkdirsÚrbc             K   s   t |  |¡|dS )ag  Make a file-like object

        Parameters
        ----------
        mode: string
            normally "rb", "wb" or "ab" or other.
        kwargs: key-value
            Any other parameters, such as buffer size. May be better to set
            these on the filesystem instance, to apply to all files created by
            it. Not used for local.
        )Úmode)Úopenr   )r   r   r   Úkwargsr   r   r   r   .   s    zLocalFileSystem.openc             C   s   |   |¡}t|t |¡jƒS )z3Unique identifier, so we can tell if a file changed)r   r	   r   ÚstatÚst_mtime)r   r   r   r   r   Úukey<   s    
zLocalFileSystem.ukeyc             C   s   t  |  |¡¡jS )z!Size in bytes of the file at path)r   r!   r   Úst_size)r   r   r   r   r   ÚsizeA   s    zLocalFileSystem.sizec             C   s   ddl }|jj ¡ S )z$Get an equivalent pyarrow filesystemr   N)ZpyarrowZ
filesystemr
   Zget_instance)r   Zpar   r   r   Ú_get_pyarrow_filesystemE   s    z'LocalFileSystem._get_pyarrow_filesystemN)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úsepr   r   r   r   r   r#   r%   r&   r   r   r   r   r
   
   s   	
r
   Úfile)Z
__future__r   r   r   r   r   Ú r   Úbaser	   Úobjectr
   Z_filesystemsr   r   r   r   Ú<module>   s   A