xword-dl icon indicating copy to clipboard operation
xword-dl copied to clipboard

Refactor creation of puz files and add optional PUZv2 support

Open afontenot opened this issue 6 months ago • 1 comments

Most of the downloaders follow a similar pattern of creating a puzzle file with puz.Puzzle() in their parse_xword method and returning this puzzle file to the controller. This refactor changes this to make puzzle files attributes of the BaseDownloader class, which the downloaders then use as needed.

This has several benefits:

  • The Puzzle interface is now abstract, from the point of view of the downloaders. None of them imports puz any more. This enables a potential future PR to allow swapping out puz for a compatible implementation, e.g. one that would create files in a different format like .ipuz (libipuz).

  • As part of this PR, we add a flag -2 --v2 that creates PUZ v2.0 files, rather than the 1.x version. Not all software supports these files, and this is not enabled by default, but for software that does (Gnome Crosswords is an example), we don't have to strip out e.g. emojis, which are becoming increasingly common in online crosswords.

afontenot avatar Aug 06 '24 18:08 afontenot