-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneverhood
43 lines (33 loc) · 1.05 KB
/
neverhood
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python3
import appdirs
import pathlib
import shutil
import subprocess
import sys
ARGS = sys.argv[1:]
SCUMMVM = '/usr/bin/scummvm'
GAMENAME = 'neverhood-win'
CONFIG_NAME = 'neverhood.ini'
USER_CONFIG_DIR = pathlib.Path(appdirs.user_config_dir())
USER_CONFIG = USER_CONFIG_DIR / CONFIG_NAME
SITE_CONFIG_DIR = pathlib.Path(appdirs.site_config_dir())
SITE_CONFIG = SITE_CONFIG_DIR / CONFIG_NAME
def is_config_option_used():
if '--config' in ARGS:
return True
for arg in ARGS:
if arg.startswith(('-c', '--config=')):
return True
return False
def run_neverhood():
command = [SCUMMVM] + ARGS
if not is_config_option_used():
if not USER_CONFIG.exists():
USER_CONFIG_DIR.mkdir(parents=True, exist_ok=True)
print(f'Copying {SITE_CONFIG} to {USER_CONFIG}')
shutil.copy(SITE_CONFIG, USER_CONFIG)
command.append(f'--config={USER_CONFIG}')
command.append(GAMENAME)
return subprocess.run(command).returncode
if __name__ == '__main__':
sys.exit(run_neverhood())