##// END OF EJS Templates
atomictempfile: rewrite docstring to clarify rename() vs. close().
Greg Ward -
r14008:da65edca default
parent child Browse files
Show More
@@ -719,12 +719,15 b' def mktempcopy(name, emptyok=False, crea'
719 return temp
719 return temp
720
720
721 class atomictempfile(object):
721 class atomictempfile(object):
722 """file-like object that atomically updates a file
722 '''writeable file object that atomically updates a file
723
723
724 All writes will be redirected to a temporary copy of the original
724 All writes will go to a temporary copy of the original file. Call
725 file. When rename is called, the copy is renamed to the original
725 rename() when you are done writing, and atomictempfile will rename
726 name, making the changes visible.
726 the temporary copy to the original name, making the changes visible.
727 """
727
728 Unlike other file-like objects, close() discards your writes by
729 simply deleting the temporary file.
730 '''
728 def __init__(self, name, mode='w+b', createmode=None):
731 def __init__(self, name, mode='w+b', createmode=None):
729 self.__name = name # permanent name
732 self.__name = name # permanent name
730 self._tempname = mktempcopy(name, emptyok=('w' in mode),
733 self._tempname = mktempcopy(name, emptyok=('w' in mode),
General Comments 0
You need to be logged in to leave comments. Login now