`writer-cm` is a context manager allowing you to atomically write files given a file path.
Project description
writer-cm
writer-cm
is a context manager allowing you to atomically write files given a file path.
Features
- Cross-platform atomic file writes powered by python-atomicwrites.
- Interface using a file path instead of a file handle, for more compatible with external libraries (e.g.
pandas.to_pickle
). - Automatically create missing directories and set their permissions.
- Automatically set the file permissions.
How?
from writer_cm import writer_cm
with writer_cm("file.txt") as temp:
with open(temp, mode="w") as fh:
fh.write("foo")
with open("file.txt") as fh:
assert fh.read() == "foo"
# Specify overwrite=True
with writer_cm("file.txt", overwrite=True) as temp:
with open(temp, mode="w") as fh:
fh.write("bar")
with open("file.txt") as fh:
assert fh.read() == "bar"
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
writer-cm-0.0.6.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for writer_cm-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bc7de9bd3c1e576beeff1765fd8d5b07c1b6376a63d401c716b70c4248abc9d |
|
MD5 | e33f61f0e6ac76463159fc682041c4e2 |
|
BLAKE2b-256 | e8fdaf027a76396686ef6b196671a48f5f9be76d9cf023dd92ac942fbb23cf37 |