svisser / crossword

Python library for handling crossword puzzles
http://pypi.python.org/pypi/crossword
MIT License
44 stars 7 forks source link

Serialization via puz produces invalid file #3

Open rcoh opened 5 years ago

rcoh commented 5 years ago

The puzpy module relies on .fill being set to a string the same length as solution (width*height). This library doesn't set it which leads to corrupted files. Workaround:

puz = crossword.to_puz(crossword_obj)
puz.fill = ' ' * (crossword_obj.height * crossword_obj.width)
# workaround for a separate Python 3+ compatibility issue in puzpy
puz.preamble = b''
return puz.tobytes()
svisser commented 5 years ago

Thanks for reporting this, it's indeed possible (likely) that this was missed when implementing this library. I'd have to look into it and create a fix for it.

Pull requests are welcome as well!

rcoh commented 5 years ago

In the same vein, clues can't be '' or Acrosslite will hard-crash. (many other readers are fine with it though)