Metadata-Version: 2.1
Name: openz
Version: 0.1.2
Summary: 
Home-page: https://github.com/Cologler/openz-python
License: MIT
Author: Cologler
Author-email: skyoflw@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: filelock (>=3.12.0,<4.0.0)
Requires-Dist: nanoid (>=2.0.0,<3.0.0)
Requires-Dist: portalocker (>=2.7.0,<3.0.0)
Description-Content-Type: text/markdown

# openz

[![Python Testing](https://github.com/Cologler/openz-python/actions/workflows/testing.yml/badge.svg)](https://github.com/Cologler/openz-python/actions/workflows/testing.yml)

A strange file opener.

## Usage

``` python
from openz import open_for_write, try_rollback

with open_for_write(
            path,
            text_mode=True,
            overwrite=True,
            with_atomicwrite=True,
            with_lockfile=True,
            with_exclusive=False, # unable work with `with_atomicwrite`
            with_backup=True
        ) as fp:

    fp.write('content')
```

### Restore data from crash

Make sure set `with_backup=True` and `backup_for_fault=True`:

``` python
with open_for_write(path, with_backup=True, backup_for_fault=True) as fp:
    ...
```

Then you can restore it from the backup:

``` python
try_rollback(path)
```

