atomic writing

def write(self):
        '''atomic writing'''
        tmp_file, tmp_fname = tempfile.mkstemp()
        os.close(tmp_file)
        shutil.copystat(self.file_name, tmp_fname)
        self.config.write(open(tmp_fname, 'w'))
        shutil.move(tmp_fname, self.file_name)