puz.py: python crossword puzzle library (.puz file parser)
==========================================================
Implementation of .puz crossword puzzle file parser based on .puz file format documentation here: http://code.google.com/p/puz/wiki/FileFormat
Examples
--------
Load a puzzle file::
import puz
p = puz.read('testfiles/washpost.puz')
Print clues with answers::
numbering = p.clue_numbering()
print 'Across'
for clue in numbering.across:
answer = ''.join(
p.solution[clue['cell'] + i]
for i in range(clue['len']))
print clue['num'], clue['clue'], '-', answer
print 'Down'
for clue in numbering.down:
answer = ''.join(
p.solution[clue['cell'] + i * numbering.width]
for i in range(clue['len']))
print clue['num'], clue['clue'], '-', answer
Print the grid::
for row in range(p.height):
cell = row * p.width
# Substitute p.solution for p.fill to print the answers
print ' '.join(p.fill[cell:cell + p.width])
Unlock a scrambled solution::
p.unlock_solution(7844)
# p.solution is unscambled
Save a puzzle with modifications::
p.fill = 'LAMB' + p.fill[4:]
p.save('mine.puz')
Notes
-----
The parser is as strict as Across Lite, enforcing internal checksums and magic strings. The parser is designed to round-trip all data in the file, even fields whose utility is unknown. This makes testing easier. It is resilient to garbage at the beginning and end of the file (for example some publishers put the filename on the first line and some files have a \r\n at the end).
In addition to the handful of tests checked in here, the library has been tested on over 9700 crossword puzzles in .puz format drawn from the archives of several publications including The New York Times, The Washington Post, The Onion, and, the Wall Street Journal. As of writing, it can round-trip 100% of them with full fidelity.
Running tests
-------------
`python tests.py`
License
-------
MIT License.
Raw data
{
"_id": null,
"home_page": "https://github.com/alexdej/puzpy",
"name": "puzpy",
"maintainer": "Simeon Visser",
"docs_url": null,
"requires_python": null,
"maintainer_email": "simeonvisser@gmail.com",
"keywords": "puz crosswords crossword puzzle acrosslite xword xwords",
"author": "Alex Dejarnatt",
"author_email": "adejarnatt@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5e/e2/8186d481b80bd58127ada1f61da4e6c2af25ee6fe59ae0f709df24492e21/puzpy-0.2.6.tar.gz",
"platform": null,
"description": "puz.py: python crossword puzzle library (.puz file parser)\n==========================================================\nImplementation of .puz crossword puzzle file parser based on .puz file format documentation here: http://code.google.com/p/puz/wiki/FileFormat\n\nExamples\n--------\nLoad a puzzle file::\n\n import puz\n p = puz.read('testfiles/washpost.puz')\n\nPrint clues with answers::\n\n numbering = p.clue_numbering()\n\n print 'Across'\n for clue in numbering.across:\n answer = ''.join(\n p.solution[clue['cell'] + i]\n for i in range(clue['len']))\n print clue['num'], clue['clue'], '-', answer\n\n print 'Down'\n for clue in numbering.down:\n answer = ''.join(\n p.solution[clue['cell'] + i * numbering.width]\n for i in range(clue['len']))\n print clue['num'], clue['clue'], '-', answer\n\nPrint the grid::\n\n for row in range(p.height):\n cell = row * p.width\n # Substitute p.solution for p.fill to print the answers\n print ' '.join(p.fill[cell:cell + p.width])\n\nUnlock a scrambled solution::\n\n p.unlock_solution(7844)\n # p.solution is unscambled\n\nSave a puzzle with modifications::\n\n p.fill = 'LAMB' + p.fill[4:]\n p.save('mine.puz')\n\nNotes\n-----\nThe parser is as strict as Across Lite, enforcing internal checksums and magic strings. The parser is designed to round-trip all data in the file, even fields whose utility is unknown. This makes testing easier. It is resilient to garbage at the beginning and end of the file (for example some publishers put the filename on the first line and some files have a \\r\\n at the end).\n\nIn addition to the handful of tests checked in here, the library has been tested on over 9700 crossword puzzles in .puz format drawn from the archives of several publications including The New York Times, The Washington Post, The Onion, and, the Wall Street Journal. As of writing, it can round-trip 100% of them with full fidelity.\n\nRunning tests\n-------------\n`python tests.py`\n\nLicense\n-------\nMIT License.\n",
"bugtrack_url": null,
"license": null,
"summary": "python crossword puzzle library",
"version": "0.2.6",
"project_urls": {
"Download": "https://pypi.python.org/pypi/puzpy",
"Homepage": "https://github.com/alexdej/puzpy"
},
"split_keywords": [
"puz",
"crosswords",
"crossword",
"puzzle",
"acrosslite",
"xword",
"xwords"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "29fef31d2bd2de7e74a6826e9f008ca003d00686fd120c3b4c78d23ec3fc87c2",
"md5": "ac002361265b35cec304f17caa7e2fa4",
"sha256": "90faa0e8b5497ed51b57e15911d66351a6bad9665c7a01218c6acd747a9dcd32"
},
"downloads": -1,
"filename": "puzpy-0.2.6-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "ac002361265b35cec304f17caa7e2fa4",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 9691,
"upload_time": "2024-06-13T17:37:46",
"upload_time_iso_8601": "2024-06-13T17:37:46.842698Z",
"url": "https://files.pythonhosted.org/packages/29/fe/f31d2bd2de7e74a6826e9f008ca003d00686fd120c3b4c78d23ec3fc87c2/puzpy-0.2.6-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5ee28186d481b80bd58127ada1f61da4e6c2af25ee6fe59ae0f709df24492e21",
"md5": "547aa55d1873628c12ea2697560ef376",
"sha256": "7809144e07691da44598001090805d99eb1bcf8475908a23638a4061605c4015"
},
"downloads": -1,
"filename": "puzpy-0.2.6.tar.gz",
"has_sig": false,
"md5_digest": "547aa55d1873628c12ea2697560ef376",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10314,
"upload_time": "2024-06-13T17:37:48",
"upload_time_iso_8601": "2024-06-13T17:37:48.046258Z",
"url": "https://files.pythonhosted.org/packages/5e/e2/8186d481b80bd58127ada1f61da4e6c2af25ee6fe59ae0f709df24492e21/puzpy-0.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-13 17:37:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "alexdej",
"github_project": "puzpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "tox",
"specs": []
},
{
"name": "flake8",
"specs": []
}
],
"tox": true,
"lcname": "puzpy"
}