py2store.persisters.local_files¶
base classes to work with local files
-
class
py2store.persisters.local_files.
DirReader
(rootdir)[source]¶ KV Reader whose keys (AND VALUES) are directory full paths of the subdirectories of rootdir.
-
class
py2store.persisters.local_files.
DirpathFormatKeys
(path_format: str, max_levels: int = inf)[source]¶
-
class
py2store.persisters.local_files.
FileReader
(rootdir)[source]¶ KV Reader whose keys are paths and values are: - Another FileReader if a path points to a directory - The bytes of the file if the path points to a file.
-
class
py2store.persisters.local_files.
FilepathFormatKeys
(path_format: str, max_levels: int = inf)[source]¶
-
class
py2store.persisters.local_files.
LocalFileRWD
(mode='', **open_kwargs)[source]¶ A class providing get, set and delete functionality using local files as the storage backend.
-
class
py2store.persisters.local_files.
LocalFileStreamGetter
(**open_kwargs)[source]¶ A class to get stream objects of local open files. The class can only get keys, and only to read, write (destructive or append).
>>> from tempfile import mkdtemp >>> import os >>> rootdir = mkdtemp() >>> >>> appendable_stream = LocalFileStreamGetter(mode='a+') >>> reader = PathFormatPersister(rootdir) >>> filepath = os.path.join(rootdir, 'tmp.txt') >>> >>> with appendable_stream[filepath] as fp: ... fp.write('hello') 5 >>> print(reader[filepath]) hello >>> with appendable_stream[filepath] as fp: ... fp.write(' world') 6 >>> >>> print(reader[filepath]) hello world
-
class
py2store.persisters.local_files.
PathFormatPersister
(path_format, max_levels: int = inf, mode='', **open_kwargs)[source]¶
-
class
py2store.persisters.local_files.
PrefixedDirpathsRecursive
[source]¶ Keys collection for local files, where the keys are full filepaths RECURSIVELY under a given root dir _prefix. This mixin adds iteration (__iter__), length (__len__), and containment (__contains__(k)).
-
class
py2store.persisters.local_files.
PrefixedFilepaths
[source]¶ Keys collection for local files, where the keys are full filepaths DIRECTLY under a given root dir _prefix. This mixin adds iteration (__iter__), length (__len__), and containment (__contains__(k)).