`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 compatibility 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.7.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for writer_cm-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 540369d0d0637d86021263cece5a3f2724773f1a91717d19844845f5b59bc280 |
|
MD5 | 507379adba58fa4cbb6a80119b5a6716 |
|
BLAKE2b-256 | a1a9f5002759fd3fc4efa8dc3c74afa16af37f33f97d9dfe586bb783ce59f244 |