Skip to main content

Replay Parsing for Tournament Replay Packs

This is a script for parsing tournament replay packs. It recursively searches sub-directories for replay files, then parses the replays using the Zephyrus Replay Parser.

You can inject a function to analyze output data. Analyzed data is aggregated and stored, then exported as JSON.

Information from directory names such as group, BoX and player names can be also be parsed and associated with replay data.

Installation and Usage

This script is hosted on PyPI and can be installed with pip

pip install recursive_parse

The recursive_parse function is imported by default

import recursive_parse

Required Arguments

There are 2 required keyword arguments for the function: sub_dir and data_function.

sub_dir specifies the relative path of the replays you want to parse from the location of the script

dir/
  analysis.py <-- recursive_parse called here
  replays/
    ...

sub_dir = 'replays'

data_function is a function supplied by the user to analyze output data from parsed replays. Returned data is appended to a list which is exported as JSON after all replays have been parsed.

You can access all the information available from parsed replay (players, timeline, stats, metadata) as well as enclosed information in your supplied function via kwargs. This includes default values and any information parsed from directory names.

Defaults currently available are ignore_units and merge_units.

ignore_units is a list of temporary unit which are usually not wanted.

merge_units is a dictionary in the format of <unit name>: <changed name>. It can be used to merge information from different unit modes or to re-name a unit, such as LurkerMP --> Lurker.

Optional Arguments

recursive_parse takes 2 optional keyword arguments: player_match and identifiers. Both are RegEx patterns that parse information from directory names.

player_match is specifically for parsing player names from directories. It takes a list of tuples of RegEx patterns and the type of search to perform.

Ex: (<pattern>, <search type>)

You can choose between search or split for search type, but the last pattern must be a split to separate the player names.

The default patterns are:

standard_player_match = [
    ('\\w+ +[v,V][s,S]\\.? +\\w+', 'search'),
    ('.vs\\.?.', 'split'),
]

identifiers is for parsing information from directory names. It contains a list of tuples of RegEx patterns and the chosen name of the pattern. It has no default patterns.

Ex: (<pattern name>, <pattern>)

The list of tuples can be accessed through kwargs['identifier'] in your data_function.

Example

The hsc_analysis.py file is an example of usage for replay files from HSC XX.

The parse_data function loops through each player's units and buildings that were created during the game and records information about the unit/building and game. It also indentifies and stores groups that players were in.

Exporting Data

Data is exported as JSON to a JSON file by default, but you can use the json_to_csv.py file to create a CSV file from the JSON data.

In future there will be an option to define a data schema as an argument for recursive_parse.

Metadata

Release files for recursive-parse 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recursive-parse 0.0.2
File Size Uploaded Provenance Actions
recursive-parse-0.0.2.tar.gz 5.3 kB Without provenance Details for recursive-parse-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for recursive-parse 0.0.2
File Interpreter ABI Platform Actions
recursive_parse-0.0.2-py3-none-any.whl Python 3 none any Details for recursive_parse-0.0.2-py3-none-any.whl

Total release size: 12.7 kB

Release files / recursive-parse-0.0.2.tar.gz

Download URL recursive-parse-0.0.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5fdf6b7b68aebf224094df84a9d0d966b1bc569d7c7953a1719d9bd42cba555a
BLAKE2b-256 checksum
How to use checksums
cee00ad8f9cad0b979b18ce21a4c93e4291ff60bdd9213c3ad476495c686ee95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

Release files / recursive_parse-0.0.2-py3-none-any.whl

Download URL recursive_parse-0.0.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9a6c152dfc3265dac6578eaaeeab78d8445ba46795d6f6fd6e8047081320008
BLAKE2b-256 checksum
How to use checksums
0d6888706d4326c41aaab7448e7c12a309a20d7293c50773b979e49e3ce29d3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

Security for recursive-parse 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page