samedi 20 juin 2020

Is there a Python module that handles safe update/writing of multiple files?

I assume that there is some graceful design pattern for a program which may modify or write more than one file when run to:

  1. Write some number of temporary files… creating the expected output files as part of what the program does.
  2. If the process breaks or exits unexpectedly while creating files, no harm no foul: existing files are as they were when the user called the program.
  3. Move/write any existing files being edited/created to temporary storage.
  4. Move/copy the temporary files from step 1 to where output expects them to be.
  5. Confirm they are there (maybe checksum them as part of that confirmation?).
  6. Maybe moving old files back if the confirmation on the new files broke somehow?
  7. Delete temporary files, and call it done.

Is this kind of thing packed up nicely in a Python 3.x module? (And is there a common name for this kind of design pattern?)

I am not a CS type, and not a professional developer, so Answers For Newbs-level language is welcome.

Aucun commentaire:

Enregistrer un commentaire