diff --git a/rf2settings/rfactor.py b/rf2settings/rfactor.py index f64a812..551ff57 100644 --- a/rf2settings/rfactor.py +++ b/rf2settings/rfactor.py @@ -1,6 +1,5 @@ import json import logging -import sys from configparser import ConfigParser from pathlib import Path, WindowsPath import subprocess @@ -61,7 +60,10 @@ def get_location(cls, dev: Optional[bool] = False): class RfactorPlayer: resolution_key = 'resolution_settings' - config_parser_args = {'inline_comment_prefixes': '//', 'default_section': 'COMPONENTS'} + config_parser_args = {'inline_comment_prefixes': ('//', ), + 'comment_prefixes': ('#', ';', '//'), + 'default_section': 'COMPONENTS', + } class Options: def __init__(self): @@ -217,7 +219,7 @@ def _write_video_config(self, preset: BasePreset): try: # - Write config with open(self.ini_file, 'w') as f: - self.ini_config.write(f) + self.ini_config.write(f, space_around_delimiters=False) # - Restore first ini comment line with open(self.ini_file, 'r') as f: @@ -230,10 +232,6 @@ def _write_video_config(self, preset: BasePreset): # - Remove trailing new line character f_lines[-1] = f_lines[-1].rstrip('\n') - # - Remove spaced assign - for idx, line in enumerate(f_lines): - f_lines[idx] = line.replace(' = ', '=') - # - Write modified config with open(self.ini_file, 'w') as f: f.writelines(f_lines) @@ -468,7 +466,7 @@ def run_config(self) -> bool: return False executable = self.location / "Bin64" / "rF Config.exe" - p = subprocess.Popen(executable, cwd=self.location, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + p = subprocess.Popen(executable.as_posix(), cwd=self.location, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE) out, errs = p.communicate() if p.returncode != 0: