{"id":18928122,"url":"https://github.com/hearthsim/python-hslog","last_synced_at":"2025-04-05T00:06:16.270Z","repository":{"id":19970354,"uuid":"88407746","full_name":"HearthSim/python-hslog","owner":"HearthSim","description":"Python module to parse Hearthstone Power.log files","archived":false,"fork":false,"pushed_at":"2025-03-12T10:51:12.000Z","size":215,"stargazers_count":69,"open_issues_count":6,"forks_count":13,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-28T23:07:21.597Z","etag":null,"topics":["hearthstone","log-parser","parsing","regex"],"latest_commit_sha":null,"homepage":"https://hearthsim.info","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/HearthSim.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-16T11:04:03.000Z","updated_at":"2025-03-20T10:41:04.000Z","dependencies_parsed_at":"2024-06-20T21:57:28.947Z","dependency_job_id":"ff613f73-4da6-4a54-8d83-e2be82cfa60c","html_url":"https://github.com/HearthSim/python-hslog","commit_stats":{"total_commits":147,"total_committers":4,"mean_commits":36.75,"dds":0.6462585034013606,"last_synced_commit":"39369f015e380e94086dae42b4a3bd2fb3fb5400"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2Fpython-hslog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2Fpython-hslog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2Fpython-hslog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HearthSim%2Fpython-hslog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HearthSim","download_url":"https://codeload.github.com/HearthSim/python-hslog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266563,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["hearthstone","log-parser","parsing","regex"],"created_at":"2024-11-08T11:23:00.948Z","updated_at":"2025-04-05T00:06:16.250Z","avatar_url":"https://github.com/HearthSim.png","language":"Python","readme":"# hslog\n\n[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/HearthSim/python-hslog/ci.yml?branch=main)](https://github.com/HearthSim/python-hslog/actions/workflows/ci.yml)\n[![PyPI](https://img.shields.io/pypi/v/hslog.svg)](https://pypi.org/project/hslog/)\n\nhslog is a powerful Hearthstone Power.log deserializer.\n\n\n## Concepts\n\nThe data read from Power.log is deserialized into packets.\nThe log is read line by line using a regex-based approach, with packets\naccumulating data when they span over multiple lines.\nThe `BLOCK_START` and `BLOCK_END` packets are serialized into a Block packet,\nwhich is nestable.\nWe call the totality of the packets for a game the \"Packet Tree\".\n\n\n## Exporting a PacketTree\n\nThe `PacketTree` object makes it easy to recursively iterate over, which in\nturn makes it very easy to export into various other formats. The `.export()`\nmethod on `PacketTree` will natively export the entire tree to a `Game` entity,\nusing the `hearthstone.entities` module by default.\n\nThis is achieved through a very flexible class-based Exporter system, which can\nbe found in `hslog.export`.\nThe syntax to call an exporter directly is: `MyExporter(packet_tree).export()`.\n\nThe base logic for the Exporter is in the `BaseExporter` class.\nCalling `export()` will iterate over each packet and call `export_packet(packet)`\non them. That method will look at the packet's type, get the matching method in\nthe `self.dispatch` dict (populated by `get_dispatch_dict()`) and call it on it.\n\nThis is the default dispatch lookup:\n\n* `CreateGame` -\u003e `handle_create_game()`\n* `CreateGame.Player`: `handle_player()`\n* `Block`: `handle_block`\n* `FullEntity`: `handle_full_entity`\n* `HideEntity`: `handle_hide_entity`\n* `ShowEntity`: `handle_show_entity`\n* `ChangeEntity`: `handle_change_entity`\n* `TagChange`: `handle_tag_change`\n* `MetaData`: `handle_metadata`\n* `Choices`: `handle_choices`\n* `SendChoices`: `handle_send_choices`\n* `ChosenEntities`: `handle_chosen_entities`\n* `Options`: `handle_options`\n* `Option`: `handle_option`\n* `SendOption`: `handle_send_option`\n* `ResetGame`: `handle_reset_game`\n* `SubSpell`: `handle_sub_spell`\n\nAll of the methods in the dispatch dict should be implemented.\n\n\n### Exporting the game state\n\nThe default exporter used by `PacketTree` is the `EntityTreeExporter`. It\ncreates an \"Entity Tree\" by simulating each packet in its handler. Choices,\nOptions and MetaData packets are ignored.\n\nThe entity tree is a `hearthstone.entities.Game` object. It contains a list of\nentities in the `entities` attribute, which themselves have tags in their `tags`\nattribute.\n\nThe export fully simulates every available packet. The game state at the end of\nthe export is therefore the state of the game at the end of the parsed log file.\n\n\n### Exporting the friendly player\n\nConceptually, a game does not have a friendly player. We can think of a game as\nthe server-side object, which is sent to two separate players.\nHowever, a Power.log file *does* have a friendly player: The bottom player, whose\ncards are revealed.\n\nThe `FriendlyPlayerExporter` class allows exporting the friendly player. The\nexporter works by looking through the initial tag changes and full entity\npackets, attempting to figure out which \"side\" is getting cards revealed that\ncould only happen if the player is friendly.\n\nThis behaviour is undefined when the log contains a \"double-spectate\" (both sides\nof the games spectated at the same time).\n\n\n## License\n\nThis project is licensed under the MIT license. The full license text is\navailable in the LICENSE file.\n\n\n## Community\n\nThis is a [HearthSim](https://hearthsim.info) project.\n[Join the HearthSim developer community](https://hearthsim.info/join/) to participate.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhearthsim%2Fpython-hslog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhearthsim%2Fpython-hslog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhearthsim%2Fpython-hslog/lists"}