Refactor creation of puz files and add optional PUZv2 support #204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Most of the downloaders follow a similar pattern of creating a puzzle file with
puz.Puzzle()
in theirparse_xword
method and returning this puzzle file to the controller. This refactor changes this to make puzzle files attributes of theBaseDownloader
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 importspuz
any more. This enables a potential future PR to allow swapping outpuz
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.