Skip to content

Commit

Permalink
Fix errors extracting data from 3.9 gamestate (#113)
Browse files Browse the repository at this point in the history
* Fix errors extracting data from 3.9 gamestate

* Fix #111
  • Loading branch information
MichaelMakesGames authored Nov 7, 2023
1 parent 779c6a4 commit a497887
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit a497887

Please sign in to comment.