Files
markbench-tests/zdeprecated/F1_23/f1_23_utils.py
j-lin-lmg 9f48268433 Non game harness update initial (#142)
Naming Scheme rework for non-game harnesses
2025-05-27 11:09:21 -07:00

25 lines
922 B
Python

"""Utility functions supporting F1 23 test script."""
import os
import re
def get_resolution() -> tuple[int]:
"""Gets resolution width and height from local xml file created by game."""
username = os.getlogin()
config_path = f"C:\\Users\\{username}\\Documents\\My Games\\F1 23\\hardwaresettings"
config_filename = "hardware_settings_config.xml"
resolution = re.compile(r"<resolution width=\"(\d+)\" height=\"(\d+)\"")
cfg = f"{config_path}\\{config_filename}"
height = 0
width = 0
with open(cfg, encoding="utf-8") as file:
lines = file.readlines()
for line in lines:
height_match = resolution.search(line)
width_match = resolution.search(line)
if height_match is not None:
height = height_match.group(2)
if width_match is not None:
width = width_match.group(1)
return (width, height)