Skip to content

Commit

Permalink
fixed server_cvar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pnxenopoulos committed Aug 12, 2024
1 parent 80d1b74 commit c99a1a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11"] # Add 3.12 when pxr updates
python-version: ["3.10", "3.11", "3.12"] # Add 3.12 when pxr updates
timeout-minutes: 15
steps:
- name: Checkout awpy library
Expand Down
28 changes: 9 additions & 19 deletions awpy/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"has_defuser",
"has_helmet",
"flash_duration",
"accuracy_penalty",
"zoom_lvl",
"ping",
]
Expand Down Expand Up @@ -177,26 +178,15 @@ def _parse_demo(self) -> None:
self._debug(
f"Found the following game events: {self.parser.list_game_events()}"
)

for event_name in self.parser.list_game_events():
self._parse_single_event(event_name)

def _parse_single_event(self, event_name: str) -> None:
"""Parse a single event from the demo file.
Args:
event_name (str): The name of the event to parse.
"""
if not self.parser:
no_parser_error_msg = "No parser found!"
raise ValueError(no_parser_error_msg)

try:
self.events[event_name] = self.parser.parse_event(
event_name, player=self.player_props, other=self.other_props
game_events = self.parser.list_game_events()
game_events = [e for e in game_events if e != "server_cvar"]
self.events = dict(
self.parser.parse_events(
game_events,
player=self.player_props,
other=self.other_props,
)
except Exception as e:
self._warn(f"Error parsing {event_name}: {e}")
)

def _parse_events(self) -> None:
"""Process the raw parsed data."""
Expand Down
8 changes: 6 additions & 2 deletions tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def hltv_events() -> dict[str, pd.DataFrame]:
Link: https://www.hltv.org/stats/matches/mapstatsid/170716/spirit-vs-mouz
"""
parser = DemoParser("tests/spirit-vs-mouz-m1-vertigo.dem")
game_events = parser.list_game_events()
game_events = [e for e in game_events if e != "server_cvar"]
return dict(
parser.parse_events(
parser.list_game_events(),
game_events,
player=[
"X",
"Y",
Expand Down Expand Up @@ -89,9 +91,11 @@ def faceit_events() -> dict[str, pd.DataFrame]:
Link: https://www.faceit.com/en/cs2/room/1-a568cd9f-8817-4410-a3f3-2270f89135e2
"""
parser = DemoParser("tests/faceit-fpl-1-a568cd9f-8817-4410-a3f3-2270f89135e2.dem")
game_events = parser.list_game_events()
game_events = [e for e in game_events if e != "server_cvar"]
return dict(
parser.parse_events(
parser.list_game_events(),
game_events,
player=[
"X",
"Y",
Expand Down

0 comments on commit c99a1a5

Please sign in to comment.