Skip to content

Writeable file object that atomically updates a file.

Notifications You must be signed in to change notification settings

sat2707/atomicfile

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AtomicFile

Writeable file object that atomically updates a file.

All writes will go to a temporary file. Call close() explicitly when you are done writing, and AtomicFile will rename the temporary copy to the original name, making the changes visible. If the object is destroyed without being closed, all your writes are discarded.

AtomicFile is friendly to with statement.

from atomicfile import AtomicFile

with AtomicFile("panic.txt", "w") as f:
    f.write(json.dumps(big_data_array_100MB, sort_keys=True, indent=4))

Install

To install AtomicFile, simply:

pip install atomicfile

About

Writeable file object that atomically updates a file.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 87.9%
  • Shell 12.1%