I've had a brief look at preview.py. That's way beyond my current skill level, so I won't be pursuing that any time soon.
For the EbookScramble exercise, all I had in mind was to provide
- simple selection of a single source file, within calibre via plugin or standalone drag-drop
- ability to change scramble rules - standalone version only, plugin will have fixed MR-agreed rules.
- Scramble Now button - all scrambling work done by container parser methods, no user interaction
- after scrambling (but before final commit), access to a few FYI dialogs, i.e. no user changes.
e.g. a dialog which shows text by container name, before vs. after, side-by-side. So exploded files will need to be in-sync with the parsed items. The FYI dialogs are mainly those I wished I'd had before I started testing. As the work is already done may as well tidy it up and make it available - at least in the standalone version.
- The only user change possible by this point is destination directory for scrambled copy. Basic testing done in calibre plugin version to not allow destination to be a calibre library directory.
- Save & exit - where final container.commit(path_to_scrambled_book) is run.
My gut-feel is that there shouldn't be anything unsafe about the above to warrant needing full Preview-mode compliance. If you strongly beg to differ then I'll need to reconsider what options are included.
Re: item 4. I've done this by creating a container of the source book then cloning it to an unedited backup of the Original. I did have some problems with the clone images which didn't exist if I just created a completely independent 2nd container to hold the Original. However, I
think it's working now. Maybe a clone isn't exactly what I thought it was. For epub/kepub an independent 2nd container would be acceptable but for an azw3 doing all that packing/unpacking twice is less desirable.