{"id":34108128,"url":"https://github.com/brettbates/pgn_parser","last_synced_at":"2026-04-07T17:31:48.007Z","repository":{"id":52697395,"uuid":"174876062","full_name":"brettbates/pgn_parser","owner":"brettbates","description":"A Python Parser for .pgn chess games.","archived":false,"fork":false,"pushed_at":"2021-04-20T19:31:07.000Z","size":101,"stargazers_count":12,"open_issues_count":10,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-17T01:26:31.873Z","etag":null,"topics":["chess","games","parser","pgn","pgn-parser","pgn-reader","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brettbates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-10T20:18:54.000Z","updated_at":"2024-12-27T18:57:09.000Z","dependencies_parsed_at":"2022-08-13T02:01:24.076Z","dependency_job_id":null,"html_url":"https://github.com/brettbates/pgn_parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/brettbates/pgn_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettbates%2Fpgn_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettbates%2Fpgn_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettbates%2Fpgn_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettbates%2Fpgn_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brettbates","download_url":"https://codeload.github.com/brettbates/pgn_parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettbates%2Fpgn_parser/sbom","scorecard":{"id":252493,"data":{"date":"2025-08-11","repo":{"name":"github.com/brettbates/pgn_parser","commit":"554d20d92ae7b625c0d2c02ae825f85b0225fc5b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/pythonpackage.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpackage.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/brettbates/pgn_parser/pythonpackage.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpackage.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/brettbates/pgn_parser/pythonpackage.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/pythonpackage.yml:28","Warn: pipCommand not pinned by hash: .github/workflows/pythonpackage.yml:29","Warn: pipCommand not pinned by hash: .github/workflows/pythonpackage.yml:32","Warn: pipCommand not pinned by hash: .github/workflows/pythonpackage.yml:35","Warn: pipCommand not pinned by hash: .github/workflows/pythonpackage.yml:39","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2020-92 / GHSA-hj5v-574p-mj7c","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T08:50:45.864Z","repository_id":52697395,"created_at":"2025-08-17T08:50:45.864Z","updated_at":"2025-08-17T08:50:45.864Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31522252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess","games","parser","pgn","pgn-parser","pgn-reader","python"],"created_at":"2025-12-14T18:13:52.817Z","updated_at":"2026-04-07T17:31:47.991Z","avatar_url":"https://github.com/brettbates.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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\u003e\u003e\u003e from pgn_parser import parser, pgn\n\n\u003e\u003e\u003e game = parser.parse(\"1. e4 e5\", actions=pgn.Actions())\n\u003e\u003e\u003e print(game.move(1))\n1. e4 e5\n\u003e\u003e\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettbates%2Fpgn_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrettbates%2Fpgn_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettbates%2Fpgn_parser/lists"}