philhanna / crossword

Crossword puzzle editor
MIT License
2 stars 0 forks source link

Make crossword classes serializable as Python statements necessary to recreate them #153

Closed philhanna closed 1 year ago

philhanna commented 1 year ago

Requirements

Rather than serializing objects as JSON, why not serialize them as the Python statements necessary to recreate them? This would involve:

philhanna commented 1 year ago

These files use the to_json method:

$ grep -rl to_json | grep -v venv
crossword/ui/uigrid.py
crossword/ui/puzzle_from_acrosslite.py
crossword/ui/uiword.py
crossword/ui/uipuzzle.py
crossword/ui/puzzle_import.py
crossword/cells/numbered_cell.py
crossword/grids/grid.py
crossword/puzzles/puzzle.py
tests/cells/test_numbered_cell.py
tests/grids/test_grid_rotate.py
tests/grids/test_grid.py
tests/puzzles/test_puzzle.py
tests/puzzles/test_puzzle_replace_grid.py
tests/puzzles/test_puzzle_undo.py
migration/restore_from_backup.py
$ 

These files use the from_json method:

$ grep -rl from_json | grep -v venv
create_test_data.py
crossword/ui/puzzle_export.py
crossword/ui/uigrid.py
crossword/ui/uiword.py
crossword/ui/uipuzzle.py
crossword/ui/puzzle_import.py
crossword/ui/uipublish.py
crossword/cells/numbered_cell.py
crossword/grids/grid.py
crossword/puzzles/puzzle.py
tests/cells/test_numbered_cell.py
tests/grids/test_grid.py
tests/puzzles/test_number_clues.py
tests/puzzles/test_puzzle.py
tests/puzzles/test_puzzle_replace_grid.py
migration/create_backup.py
$ 

I replaced the NumberedCell.from_json method usage with use of the NumberedCell constructor.