Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors extracting data from 3.9 gamestate #113

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You can also access the dashboard by opening [http://localhost:28053](http://loc
### Build it yourself
- Get Python 3.10 (it may work on other versions too)
- (Recommended) create & activate a virtual environment
- `pip install .`
- `pip install .` (If you get a ModuleNotFoundError for importing stellarisdashboard, try instead `pip install -e .`)
- `pip install maturin` and `maturin develop -r` in `stellarisdashboard/parsing/rust_parser`
- `stellarisdashboard`

Expand Down
2 changes: 1 addition & 1 deletion stellarisdashboard/parsing/rust_parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fn parse_str(input: &str) -> IResult<&str, &str> {
}

fn _is_valid_unquoted_str_char(c: char) -> bool {
c.is_ascii_alphanumeric() || c == '_' || c == ':' || c == '.'
c.is_ascii_alphanumeric() || c == '_' || c == ':' || c == '.' || c == '@'
}

fn parse_unquoted_str(input: &str) -> IResult<&str, &str> {
Expand Down
6 changes: 4 additions & 2 deletions stellarisdashboard/parsing/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,9 @@ def extract_data_from_gamestate(self, dependencies):

for country_id, country_model in self._countries_dict.items():
country_dict = self._gamestate_dict["country"][country_id]
country_sectors = country_dict.get("sectors", {}).get("owned", [])
# some countries have an empty object for "sectors", which gets parsed as an empty list
# so we need to wrap that in dict()
country_sectors = dict(country_dict.get("sectors", {})).get("owned", [])
unprocessed_systems = set(
s.system_id_in_game for s in self._systems_by_owner.get(country_id, [])
)
Expand Down Expand Up @@ -2702,7 +2704,7 @@ def extract_data_from_gamestate(self, dependencies):
envoy = leaders[envoy_id_ingame]
country = envoy.country
target_country = None
location = raw_leader_dict.get("location")
location = raw_leader_dict.get("location", {})
assignment = location.get("assignment")
description = None
if assignment == "improve_relations":
Expand Down
Loading