cloud_fs.cloud_fs.FileSystem
- class FileSystem(path, anon=False, profile=None, **kwargs)[source]
Bases:
object
Class to abstract file location and allow file-system commands that are
- Parameters
path (str) – S3 object path or file path
anon (bool, optional) – Whether to use anonymous credentials, by default False
profile (str, optional) – AWS credentials profile, by default None
Methods
Copy file(s) from src_path to dst_path.
Copy file to given destination
Check if file path exists
Find all file paths matching the given pattern
Check if path is a directory
Check if path is a file
List everyting under given path
Make desired directory and any intermediate directories
Move file or all files in directory to given destination
Open S3 object and return a file-like object
Delete file or files in given directory
Get file size in bytes
Recursively search directory and all sub-directories
Attributes
File path to perform filesystem operation on
- property path
File path to perform filesystem operation on
- Returns
str
- cp(dst, **kwargs)[source]
Copy file to given destination
- Parameters
dst (str) – Destination path
kwargs (dict) – kwargs for s3fs.S3FileSystem.copy
- glob(**kwargs)[source]
Find all file paths matching the given pattern
- Parameters
kwargs (dict) – kwargs for s3fs.S3FileSystem.glob
- Returns
list
- mkdirs(**kwargs)[source]
Make desired directory and any intermediate directories
- Parameters
kwargs (dict) – kwargs for s3fs.S3FileSystem.mkdirs
- mv(dst, **kwargs)[source]
Move file or all files in directory to given destination
- Parameters
dst (str) – Destination path
kwargs (dict) – kwargs for s3fs.S3FileSystem.mv
- open(mode='rb', **kwargs)[source]
Open S3 object and return a file-like object
- Parameters
mode (str) – Mode with which to open the s3 object
kwargs (dict) – kwargs for s3fs.S3FileSystem.open
- Returns
Return a file-like object from the filesystem
- rm(**kwargs)[source]
Delete file or files in given directory
- Parameters
kwargs (dict) – kwargs for s3fs.S3FileSystem.rm
- walk()[source]
Recursively search directory and all sub-directories
- Returns
path (str) – Root path
directory (list) – All directories in path
file (list) – All files in path
- classmethod copy(src_path, dst_path, anon=False, profile=None, **kwargs)[source]
Copy file(s) from src_path to dst_path. Either can be local or in the cloud.
- Parameters
src_path (str) – Source path to copy file(s) from, can be local or in the cloud
dst_path (str) – Destination path to copy file(s) to, can be local or in the cloud
anon (bool, optional) – Whether to use anonymous credentials, by default False
profile (str, optional) – AWS credentials profile, by default None