{ "info": { "author": "Brett Bates", "author_email": "b@bmb.io", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Games/Entertainment :: Board Games" ], "description": "# PGN Parser\n\nA Python library for parsing pgn files into a python friendly format.\n\nThe parser is built using [canopy](http://canopy.jcoglan.com/), the rest is Python.\n\nThe PGN spec is based on (and thanks to) the spec at [saremba.de](http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm).\n\n## Setup\n### Installing\n\nMake sure you have python 3 installed.\n\n```\npip install pgn_parser\n```\n\nThen import like so:\n\n```\nfrom pgn_parser import pgn, parser\n```\n\n\n### Testing\n\nThe tests are written using pytest and behave, these must be installed first:\n```\npip install pytest behave\n```\n\nFor running unit tests:\n```\npytest\n```\n\nFor running behavioural tests:\n```\nbehave\n```\n\n\n### Building pip distributables\n\n```\nmake build\n```\n\n## Using\n### Parsing a pgn file\nTo parse a pgn, you just give the string to the parser.parse along with the Actions()\nwhich the parser uses to create python structures.\n```Python\n>>> from pgn_parser import parser, pgn\n\n>>> game = parser.parse(\"1. e4 e5\", actions=pgn.Actions())\n>>> print(game.move(1))\n1. e4 e5\n>>> print(game.move(1).black.san)\ne5\n```\n\n### Games\nAfter parsing a game, it will be structured into the following classes which are \nnested in eachother:\n\nGame: Container for the whole game\nTo get a specific move (5 here) from a game\n```Python\ngame.move(5)\n```\n\nTo retrieve the Movetext\n```\ngame.movetext\n```\n\nTo access the TagPairs\n```\ngame.tag_pairs\n```\n\nTo access the final score\n```\ngame.score\n```\n\nMovetext: The container of all the moves, e.g \"1. c4 c5 2. e4 e5\"\nIt is just a list so can be iterated over to retrieve the moves.\nBe warned, Movetext[0] will be the first move parsed, whether 1. or 31. so \nuse Game.move() if you want a movenumber\n\nMove: A move is a move number, optionally a white Ply and or a black Ply\n\nPly: Is the unit of moving, in standard algebraic notation (SAN), \ne.g. the black ply from \"1.e4 e5\" is e5\n\nTagPairs: An ordered dictionary of all TagPair objects.\nThese are ordered so it keeps the order read in, but will change to \nseven tag roster order if printed/stringified.\n\n\n### TagPairs\nTo store meta data about a game you do so in TagPairs\n\nThe header of a pgn file \n```PGN\n[\"Site\" \"github.com\"]\n```\n\nIs represented like so in python\n```Python\ngame.tag_pairs[\"Site'] == \"github.com\"\n```\n\n\n### Moves\nEach move has a move number and two ply's, white and black. \nEach ply can be anything from empty to having comments, variations and \n[nags](https://en.wikipedia.org/wiki/Numeric_Annotation_Glyphs).\n\n```PGN\nmoves = \"1. e4 $1 {a comment} (1.d5)\"\n```\n\nIs represented like so:\n```Python\nm1 = game.move(1)_\n\nassert m1.white.san == \"e4\"\nassert m1.white.comment == \"a comment\"\nassert m1.white.nags[0] == \"$1\"\nassert m1.white.variations[0].move(1).white.san == \"d5\"\n```\n\nIf a ply is empty, then its san will be represented \"\".\n\n\n### Limitations\nNo support for RAV style variations\nNo support for multiple games in one parse, must be single games\nDoesn't attempt to parse turn times as this is not in the original spec and I am\nnot sure what to support.\n\n## Authors\n\n* **Brett Bates** - *Initial work* - [github](https://github.com/brettbates)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brettbates/pgn_parser", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pgn-parser", "package_url": "https://pypi.org/project/pgn-parser/", "platform": "", "project_url": "https://pypi.org/project/pgn-parser/", "project_urls": { "Homepage": "https://github.com/brettbates/pgn_parser" }, "release_url": "https://pypi.org/project/pgn-parser/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "PGN Parser is for parsing .pgn chess files", "version": "1.0.1" }, "last_serial": 4923176, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "3f711bd3d1c218ef921a268f875fc8a7", "sha256": "c2ff6879076903a81d564bebd605a5ef778f0551bb5b3b69527d6b1dbf0225ef" }, "downloads": -1, "filename": "pgn_parser-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3f711bd3d1c218ef921a268f875fc8a7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14742, "upload_time": "2019-03-11T00:28:27", "url": "https://files.pythonhosted.org/packages/0f/a7/ae755b969a0375deffd37e4556f37433c0858120088ba5e919ab8bcc74f3/pgn_parser-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "afe7fb7b49b044767903f58d21e6c8bd", "sha256": "fd8c267dc4fc2b8e6d2efa1e011049fd6e8bd34efcaaee6ea71fb712defb253b" }, "downloads": -1, "filename": "pgn-parser-1.0.0.tar.gz", "has_sig": false, "md5_digest": "afe7fb7b49b044767903f58d21e6c8bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10475, "upload_time": "2019-03-11T00:28:29", "url": "https://files.pythonhosted.org/packages/0e/7f/24fb88d5c6f5630a56e65939261103b8f716d4cfc7fd4afad9fcb3d44205/pgn-parser-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "88da55bc5ab9ac752ce3bf6badd0db5b", "sha256": "157f46a1be220db35b02045ae0b93bdae3460950c60c90d3a1e6786bcc243391" }, "downloads": -1, "filename": "pgn_parser-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "88da55bc5ab9ac752ce3bf6badd0db5b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14752, "upload_time": "2019-03-11T00:34:46", "url": "https://files.pythonhosted.org/packages/08/38/3c369311bf00566c1e8f0354fc530edb916110b0af4c9c04f08096ed66bb/pgn_parser-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f81a65fbd3dbc1db7217aa5f9b7ed78a", "sha256": "3fd07407b05ebddda3044acf16db7a54e217bf904a280349e4cc8a59a9787f01" }, "downloads": -1, "filename": "pgn-parser-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f81a65fbd3dbc1db7217aa5f9b7ed78a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10476, "upload_time": "2019-03-11T00:34:48", "url": "https://files.pythonhosted.org/packages/a0/2b/e2cbc26b4119b6b64bbda7de5fa5702609c41755dc656055ba32764ce041/pgn-parser-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "88da55bc5ab9ac752ce3bf6badd0db5b", "sha256": "157f46a1be220db35b02045ae0b93bdae3460950c60c90d3a1e6786bcc243391" }, "downloads": -1, "filename": "pgn_parser-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "88da55bc5ab9ac752ce3bf6badd0db5b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14752, "upload_time": "2019-03-11T00:34:46", "url": "https://files.pythonhosted.org/packages/08/38/3c369311bf00566c1e8f0354fc530edb916110b0af4c9c04f08096ed66bb/pgn_parser-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f81a65fbd3dbc1db7217aa5f9b7ed78a", "sha256": "3fd07407b05ebddda3044acf16db7a54e217bf904a280349e4cc8a59a9787f01" }, "downloads": -1, "filename": "pgn-parser-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f81a65fbd3dbc1db7217aa5f9b7ed78a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10476, "upload_time": "2019-03-11T00:34:48", "url": "https://files.pythonhosted.org/packages/a0/2b/e2cbc26b4119b6b64bbda7de5fa5702609c41755dc656055ba32764ce041/pgn-parser-1.0.1.tar.gz" } ] }