squirrel.driver.file_driver
¶
Module Contents¶
Classes¶
Drives the access to a data source. |
-
class
squirrel.driver.file_driver.
FileDriver
(path: str, storage_options: Optional[Dict[str, Any]] = None, **kwargs)¶ Bases:
squirrel.driver.driver.Driver
Drives the access to a data source.
Initializes FileDriver.
- Parameters
-
name
= file¶
-
open
(mode: str = 'r', create_if_not_exists: bool = False, **kwargs) → IO¶ Returns a handler for the file.
Uses
squirrel.fsspec.fs.get_fs_from_url()
to get a filesystem object corresponding to self.path. Simply returns the handler returned from the open() method of the filesystem.- Parameters
mode (str) – IO mode to use when opening the file. Will be forwarded to filesystem.open() method. Defaults to “r”.
create_if_not_exists (bool) – If True, the file will be created if it does not exist (along with the parent directories). This is achieved by providing auto_mkdir=create_if_not_exists as a storage option to the filesystem. No matter what you set in the FileDriver’s storage_options, create_if_not_exists will override the key auto_mkdir. Defaults to False.
**kwargs – Keyword arguments that are passed to the filesystem.open() method.
- Returns
(IO) File handler for the file at self.path.