Filesystem#
- class blocks.filesystem.base.FileSystem(**storage_options)[source]#
Bases:
object
Filesystem for manipulating files in the cloud
This supports operations on local files and any other protocol supported by fsspec. This is a wrapper to fsspec which provides backwards compatibility for blocks filesystems and a simplified interface.
- Parameters
- storage_options: Mapping[str, Mapping[str, Any]]
Additional options passed to each filesystem for each protocol e.g. {‘gs’: {‘project’: ‘example’}} to set the gs filesytem project to example
Methods
copy
(sources, dest[, recursive])Copy the files in sources to dest
cp
(sources, dest[, recursive])Copy the files in sources to dest
isdir
(path)Check if the path is a directory
ls
(path)List files correspond to path, including glob wildcards
mkdir
(path)Make directory at path
open
(path[, mode])Return a file-like object from the filesystem
remove
(paths[, recursive])Remove the files at paths
rm
(paths[, recursive])Remove the files at paths
- copy(sources, dest, recursive=False)[source]#
Copy the files in sources to dest
- Parameters
- sourceslist of str
The list of paths to copy
- deststr
The destination(s) for the copy of source(s)
- recursivebool
If true, recursively copy any directories
- cp(sources, dest, recursive=False)#
Copy the files in sources to dest
- Parameters
- sourceslist of str
The list of paths to copy
- deststr
The destination(s) for the copy of source(s)
- recursivebool
If true, recursively copy any directories
- ls(path)[source]#
List files correspond to path, including glob wildcards
- Parameters
- pathstr
The path to the file or directory to list; supports wildcards
- open(path, mode='rb', **kwargs)[source]#
Return a file-like object from the filesystem
The resultant instance must function correctly in a context
with
block.- Parameters
- path: str
Target file
- mode: str like ‘rb’, ‘w’
See builtin
open()
- kwargs:
Forwarded to the filesystem implementation
- remove(paths, recursive=False)[source]#
Remove the files at paths
- Parameters
- pathslist of str
The paths to remove
- recursivebool, default False
If true, recursively remove any directories
- rm(paths, recursive=False)#
Remove the files at paths
- Parameters
- pathslist of str
The paths to remove
- recursivebool, default False
If true, recursively remove any directories