scistag.filestag.file_sink.FileSink¶
- class FileSink(target, **params)[source]¶
Bases:
objectA file sink is the abstract base class for a file storage container target, eg.g. for storing files in a batch process such as converting a large set of images and storing them in an output directory, archive or cloud storage.
- Parameters
target (
str) – The storage targetparams – Additional parameters
Methods
This function should be called when ever you finished adding all files to the file sink to finalize it (e.g.
Stores a single file in the file sink
Creates a file source with given target.
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
The sink's storage target
Defines if the file sink was finalized (e.g.
- _store_int(filename, data, overwrite, options=None)[source]¶
The internal storage function to be implemented for the different kinds of target types.
- Parameters
filename (str) – The name of the file to be stored
data (bytes) – The data to be stored
options (FileStorageOptions | None) – Advanced storage and file options
- Return type
- Returns
True on success
- close()[source]¶
This function should be called when ever you finished adding all files to the file sink to finalize it (e.g. a zip archive)
Alternatively you can create and fill the sink within a with block such as
- store(filename, data, overwrite=True, options=None)[source]¶
Stores a single file in the file sink
- Parameters
filename (str) – The file’s name
data (bytes) – The data to be stored
overwrite (bool) – Defines if the file may be overwritten if it does already exist.
options (FileStorageOptions | None) – Advanced storage and file options
- Return type
- Returns
True on success
- static with_target(target, **params)[source]¶
Creates a file source with given target.
- Parameters
target (
str) –The target cloud storage or zip archive at which the data shall be stored.
Supported types (as of now) are: - “azure://DefaultEndpoints…” to store data in a
FileSinkAzureStorage
”zip://” w/o a filename to create a memory zip
params – Further parameters to be passed on
- Returns
The FileSink instance
- _closed¶
Defines if the file sink was finalized (e.g. a zip archive closed)
- _target¶
The sink’s storage target