File Guard and Large File Guard for preserving file content
Project description
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
use 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
find some sample.py
code in github repo
code for small files
for small files FileGuard
makes a copy using a TemporaryFile
.
in error case or when calling rollback()
the file is copied back.
refer to sample()
code for large files
for large files LargeFileGuard
provides methods like seek()
and tell()
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.
refer to sample2()
code for belated rollback
in case the rollback of an existing bim file needs to be done at a later point of time
refer to sample3()
code for multiple file rollback
in case rollback multiple files is needed - even if some files are already commited -
refer to sample4()
, and sample5()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyfileguard-0.0.4.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86bd8c47826dc735e80a877c273c024ec1fc59b35a22e0d8e13c1c857ebb052d |
|
MD5 | fc80c53b42d8da09e18709e4d664e8f7 |
|
BLAKE2b-256 | 9793085979823bf04fe869a84ae2c30a1b7d3412090b6f4adf457ef629c0ab12 |
Hashes for pyfileguard-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60a4de9089cdaf81a57a0275c10bcbbe33d319c9217d06436bfb9c2268eb002b |
|
MD5 | bcc740ff07c357b421fed81d787232d3 |
|
BLAKE2b-256 | cbbede40b204ba88208829f76ddb032923a5978506739a2d5b0a7691eaa9cd3b |