/usr/local/lib/python3.6/site-packages/fsspec/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/fsspec/__pycache__/mapping.cpython-36.pyc (8208B)
3
8%Eg] @ sF d dl Z d dlmZ ddlmZ G dd deZdd Zdd
dZdS )
N)MutableMapping ) url_to_fsc @ s e Zd ZdZd#ddZdd Zd$d d
Zdd Zd
d Zdd Z dd Z
d%ddZd&ddZdd Z
dd Zdd Zdd Zdd Zd!d" ZdS )'FSMapa Wrap a FileSystem instance as a mutable wrapping.
The keys of the mapping become files under the given root, and the
values (which must be bytes) the contents of those files.
Parameters
----------
root: string
prefix for all the files
fs: FileSystem instance
check: bool (=True)
performs a touch at the location, to check for write access.
Examples
--------
>>> fs = FileSystem(**parameters) # doctest: +SKIP
>>> d = FSMap('my-data/path/', fs) # doctest: +SKIP
or, more likely
>>> d = fs.get_mapper('my-data/path/')
>>> d['loc1'] = b'Hello World' # doctest: +SKIP
>>> list(d.keys()) # doctest: +SKIP
['loc1']
>>> d['loc1'] # doctest: +SKIP
b'Hello World'
FNc C s || _ |j|jd| _|d kr*tttf}|| _|rL| j j|sL| j j | |r| j j|sht
d| | j j|d | j j|d d S )N/z@Path %s does not exist. Create with the ``create=True`` keywordz/a)
fs_strip_protocolrstriprootFileNotFoundErrorIsADirectoryErrorNotADirectoryErrormissing_exceptionsexistsmkdir
ValueErrortouchrm)selfr
r checkcreater r 8/usr/local/lib/python3.6/site-packages/fsspec/mapping.py__init__# s$
zFSMap.__init__c C s4 y"| j j| jd | j j| j W n Y nX dS )z0Remove all keys below root - empties out mappingTN)r r r
r )r r r r clear; s
zFSMap.clearraisec s fdd|D } dkr nd}y*j j||dttrJ|d iW n* jk
rv } zt|W Y dd}~X nX fdd j D fd
d t||D S )a Fetch multiple items from the store
If the backend is async-able, this might proceed concurrently
Parameters
----------
keys: list(str)
They keys to be fetched
on_error : "raise", "omit", "return"
If raise, an underlying exception will be raised (converted to KeyError
if the type is in self.missing_exceptions); if omit, keys with exception
will simply not be included in the output; if "return", all keys are
included in the output, but the value will be bytes or an exception
instance.
Returns
-------
dict(key, bytes|exception)
c s g | ]} j |qS r )_key_to_str).0k)r r r
W s z"FSMap.getitems..r return)on_errorr Nc s( i | ] \}}t | jrt n||qS r )
isinstancer KeyError)r r v)r r r
_ s z"FSMap.getitems..c s2 i | ]*\}} d ks$t | t r| |qS )r )r"
BaseException)r keyZk2)r! outr r r% c s )r catr" bytesr r# itemszip)r keysr! keys2Zoeer )r! r( r r getitemsC s
zFSMap.getitemsc s&