snakeoil.fileutils module¶
file related operations, mainly reading
- class snakeoil.fileutils.AtomicWriteFile(fp, binary=False, perms=None, uid=-1, gid=-1)[source]¶
Bases:
AtomicWriteFile_mixin
File class that stores the changes in a tempfile.
Upon invocation of the close method, this class will use
os.rename()
to atomically replace the destination.Similar to file protocol behavior, except that close must be called for the changes to be made live,
If along the way it’s decided that these changes should be discarded, invoke
AtomicWriteFile.discard()
; this will close the file without updating the target.If this object falls out of memory without ever being discarded nor closed, the contents are discarded and a warning is issued.
- class snakeoil.fileutils.AtomicWriteFile_mixin(fp, binary=False, perms=None, uid=-1, gid=-1)[source]¶
Bases:
object
File class that stores the changes in a tempfile.
Upon invocation of the close method, this class will use
os.rename()
to atomically replace the destination.Similar to file protocol behavior, except that close must be called for the changes to be made live,
If along the way it’s decided that these changes should be discarded, invoke
AtomicWriteFile.discard()
; this will close the file without updating the target.If this object falls out of memory without ever being discarded nor closed, the contents are discarded and a warning is issued.