Storage API

class flowws.Storage.Storage[source]

Base class for file storage.

Storage objects expose methods for reading and writing of files which could actually be backed by a database or archive file, for example.

open(filename, mode='r', modifiers=[], on_filesystem=False, noop=False)[source]

Open a file stored within this object.

Parameters:
  • filename – Name of the (internal) file
  • mode – One of ‘r’ (read), ‘w’ (write/overwrite), ‘a’ (append) and, optionally, ‘b’ (open in binary mode)
  • modifiers – List of filename modifiers which will be appended to the filename, respecting the file suffix
  • on_filesystem – If True, the file must exist as a real file on the filesystem; otherwise, a python stream object may be returned
  • noop – If True, return a dummy file object instead that does nothing
open_file(full_name, mode)[source]

Open a file stored within this object as a real file on the filesystem.

The default implementation simply copies a stream object onto the filesystem.

open_stream(full_name, mode)[source]

Open a file stored within this object as a stream.

class flowws.DirectoryStorage(root='.', group=None)[source]

Stores files directly on the filesystem.

open_file(full_name, mode)[source]

Open a file stored within this object as a real file on the filesystem.

The default implementation simply copies a stream object onto the filesystem.

open_stream(full_name, mode)[source]

Open a file stored within this object as a stream.

class flowws.GetarStorage(target, group=None)[source]

Class to store files as records of getar-format files.

These can be zip, tar, or sqlite-formatted archives. Note that zip and tar files will currently accumulate copies of files as they are appended to or overwritten.

open_stream(full_name, mode)[source]

Open a file stored within this object as a stream.