def safe_dump(data, abspath, pk_protocol=py23.pk_protocol, enable_verbose=True):
    """A stable version of :func:`dump`, this method will silently overwrite 
    existing file.
    
    There's a issue with :func:`dump`: If your program is interrupted while 
    writing, you got an incomplete file, and you also lose the original file.
    So this method write pickle to a temporary file first, then rename to what
    you expect, and silently overwrite old one. This way can guarantee atomic 
    write.
    
    **中文文档**

    在对文件进行写入时, 如果程序中断, 则会留下一个不完整的文件。如果使用了覆盖式
    写入, 则我们即没有得到新文件, 同时也丢失了原文件。所以为了保证写操作的原子性
    (要么全部完成, 要么全部都不完成), 更好的方法是: 首先将文件写入一个临时文件中, 
    完成后再讲文件重命名, 覆盖旧文件。这样即使中途程序被中断, 也仅仅是留下了一个
    未完成的临时文件而已, 不会影响原文件。
    """
    abspath = lower_ext(str(abspath))
    abspath_temp = "%s.tmp" % abspath
    dump(data, abspath_temp,
         pk_protocol=pk_protocol, enable_verbose=enable_verbose)
    shutil.move(abspath_temp, abspath)
def safe_dump ( data , abspath , pk_protocol = py23 . pk_protocol , enable_verbose = True ) : abspath = lower_ext ( str ( abspath ) ) abspath_temp = "%s.tmp" % abspath dump ( data , abspath_temp , pk_protocol = pk_protocol , enable_verbose = enable_verbose ) shutil . move ( abspath_temp , abspath )
A stable version of :func:`dump`, this method will silently overwrite 
    existing file.
    
    There's a issue with :func:`dump`: If your program is interrupted while 
    writing, you got an incomplete file, and you also lose the original file.
    So this method write pickle to a temporary file first, then rename to what
    you expect, and silently overwrite old one. This way can guarantee atomic 
    write.
    
    **中文文档**

    在对文件进行写入时, 如果程序中断, 则会留下一个不完整的文件。如果使用了覆盖式
    写入, 则我们即没有得到新文件, 同时也丢失了原文件。所以为了保证写操作的原子性
    (要么全部完成, 要么全部都不完成), 更好的方法是: 首先将文件写入一个临时文件中, 
    完成后再讲文件重命名, 覆盖旧文件。这样即使中途程序被中断, 也仅仅是留下了一个
    未完成的临时文件而已, 不会影响原文件。