File Guard and Large File Guard for preserving file content
File Guard and Large File Guard
support for preserving the old content of a file.
support for large files provide access via
seek() to a specific file position.
use in own code
with context and
rollback() to rewind the changes done. exiting the context without raising an error or closing the file will commit the changes to the file finally.
when to use in own code
there are some typical use cases, such as:
- in test scenarios when you need to rollback for the next test case
- when writing changed config files from your code (falls back to old state)
- when randomly accessing larger files in binary mode
sample.py code in github repo
code for small files
for small files
FileGuard makes a copy using a
in error case or when calling
rollback() the file is copied back.
code for large files
for large files
LargeFileGuard provides methods like
to set the file pointer position. when writing to
LargeFileGuard it preserves
the content of the underlying file by writing to a journal or "before-image"
file (also known as copy-on-write).
in error case or by calling
rollback() the changes are rewinded.
code for belated rollback
in case the rollback of an existing bim file needs to be done at a later point of time
code for multiple file rollback
in case rollback multiple files is needed - even if some files are already commited -
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pyfileguard-0.0.4.linux-x86_64.tar.gz (9.4 kB)||File type Source||Python version None||Upload date||Hashes View|
|Filename, size pyfileguard-0.0.4-py3-none-any.whl (6.7 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
Hashes for pyfileguard-0.0.4.linux-x86_64.tar.gz
Hashes for pyfileguard-0.0.4-py3-none-any.whl