Skip to content

Commit

Permalink
treewide: update format
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed Sep 29, 2024
1 parent 573da0d commit 6c45ced
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
18 changes: 10 additions & 8 deletions .github/scripts/check_verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@

# 'gui' is a virtual verb for opening the Winetricks GUI
# 'vd=1280x720' is a setting for the virtual desktop and valid
whitelist_verbs = { 'gui', 'vd=1280x720' }
whitelist_verbs = {'gui', 'vd=1280x720'}


def extract_verbs_from_glob(path_glob: iglob) -> set[str]:
"""Simply strip the extension from all found files."""
return {
file.stem
for file in path_glob
}
return {file.stem for file in path_glob}


def find_verbs(root: Path) -> set[str]:
Expand All @@ -27,7 +25,9 @@ def find_verbs(root: Path) -> set[str]:

for fix in game_fixes:
f = fix.read_text()
r = re.finditer(r"util\.protontricks\s*\(\s*('|\")(?P<verb>.*)\1\s*\)", f, re.MULTILINE)
r = re.finditer(
r"util\.protontricks\s*\(\s*('|\")(?P<verb>.*)\1\s*\)", f, re.MULTILINE
)
for match in r:
verbs.add(match.group('verb'))

Expand All @@ -53,7 +53,9 @@ def find_valid_verbs(root: Path) -> set[str]:

# Execute winetricks, suppress output
print(f'Executing winetricks, using tmp path "{tmp_dir}" - this may take a moment.')
subprocess.run([wt_path, '--no-clean', 'list-all'], env=env, stdout=subprocess.DEVNULL)
subprocess.run(
[wt_path, '--no-clean', 'list-all'], env=env, stdout=subprocess.DEVNULL
)

# Get all verbs
vars_glob = tmp_dir.glob('**/*.vars')
Expand Down Expand Up @@ -85,7 +87,7 @@ def main() -> None:
print(f'WARNING: The following local verbs are unused: {unused_local_verbs}')

# Compare the results
#FIXME: Implement a more robust mechanism for "setting" type verbs (eg. "vd")
# FIXME: Implement a more robust mechanism for "setting" type verbs (eg. "vd")
invalid_verbs = verbs - (valid_verbs | valid_verbs_local | whitelist_verbs)
if invalid_verbs:
raise ValueError(f'The following verbs are invalid: {invalid_verbs}')
Expand Down
1 change: 1 addition & 0 deletions gamefixes-steam/1245620.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from protonfixes import util


def main() -> None:
game_dir = Path(util.get_game_install_path()) / 'Game'
# Create the DLC.bdt file if it doesn't already exist, which is known to fix Easy AntiCheat not working for players that don't own the DLC
Expand Down
3 changes: 2 additions & 1 deletion gamefixes-steam/2322010.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

from protonfixes import util


def main() -> None:
util.set_environment('SteamDeck', '1')
util.set_environment('SteamDeck', '1')
4 changes: 2 additions & 2 deletions gamefixes-steam/271590.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def main() -> None:
"""Game fix for GTAV"""
# Rockstar reads SteamAppId and tries to init Steam API
# We want to avoid this when running from Epic for example
game_id = os.environ.get("UMU_ID")
game_id = os.environ.get('UMU_ID')
if game_id and not game_id.isnumeric():
util.del_environment("SteamAppId")
util.del_environment('SteamAppId')
1 change: 1 addition & 0 deletions gamefixes-steam/49900.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from protonfixes import util


def main() -> None:
"""Installs XNA 3.1 to avoid crash when loading levels"""
util.protontricks('xna31')
5 changes: 2 additions & 3 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,14 @@ def patch_libcuda() -> bool:
# Use subprocess.run with capture_output and explicit encoding handling
try:
result = subprocess.run(
[ldconfig_path, '-p'],
capture_output=True,
check=True
[ldconfig_path, '-p'], capture_output=True, check=True
)
# Decode the output using utf-8 with fallback to locale preferred encoding
try:
output = result.stdout.decode('utf-8')
except UnicodeDecodeError:
import locale

encoding = locale.getpreferredencoding(False)
output = result.stdout.decode(encoding, errors='replace')
except subprocess.CalledProcessError as e:
Expand Down

0 comments on commit 6c45ced

Please sign in to comment.