This class is backend storage of PotatoEgg.
None of the methods which do something on the file check that
file exists and they return an Exception if it doesn't. It is
your responsibility to check existance of a file or directory
with Storage.exists
.
base
, db_path
, properties
)base
: A string representing the "root" of Storage and must be
an existing directory. If it is a relative path, it will be converted
to an absolute one.db_path
: A string which is path to an LMDB database.
If it doesn't exist there, one will be created. It might be inside
the root. In that case it is your responsibility to take care of this
and prevent unwanted access.properties
: An iterator containing strings which are valid properies
a file can have.path
which defaults to root
which is sorted(ascending order unless reverse
is True
) and contains
regular files and directories only(should we include other types like
character and block devices or sockets or Doors if on Solaris?)Writes the given file on storage in the given path
.
Deletes the file in path
along with all its properties
if the file already exists
path
must be an instance of string.file
must be either an instance of bytes
(NOT string) or an object
which has a read(number_of_bytes)
method. In the second case, data
is read using the said method in 64KiB chunks and transferred to storage.properties
defaults to an empty dictionary. It must be a
dictionary-like object which its keys are valid properties a file
might have. The file will be initialized with these after creation.Returns a string containing hexadecimal digest of SHA1 hashsum of file.
Removes the given file in storage will all its properties.
Returns True
if file exists and False
otherwise.
Returns an integer indicating size of file in bytes.
Moves the file to its new location. Can be used for renaming also.
Returns property value of the given file which can be any Python object
and returns None
if such a property does not exist.
Sets the Python object value
as value of the valid property property_
.
If the given property already exists with some value, that will be
replaced.