SNIClient: make SNI finder a bit smarter
This commit is contained in:
parent
6b852d6e1a
commit
93ac018400
11
SNIClient.py
11
SNIClient.py
|
@ -523,10 +523,13 @@ def launch_sni(ctx: Context):
|
||||||
if not os.path.isdir(sni_path):
|
if not os.path.isdir(sni_path):
|
||||||
sni_path = Utils.local_path(sni_path)
|
sni_path = Utils.local_path(sni_path)
|
||||||
if os.path.isdir(sni_path):
|
if os.path.isdir(sni_path):
|
||||||
for file in os.listdir(sni_path):
|
dir_entry: os.DirEntry
|
||||||
lower_file = file.lower()
|
for dir_entry in os.scandir(sni_path):
|
||||||
if (lower_file.startswith("sni.") and not lower_file.endswith(".proto")) or lower_file == "sni":
|
if dir_entry.is_file():
|
||||||
sni_path = os.path.join(sni_path, file)
|
lower_file = dir_entry.name.lower()
|
||||||
|
if (lower_file.startswith("sni.") and not lower_file.endswith(".proto")) or (lower_file == "sni"):
|
||||||
|
sni_path = dir_entry.path
|
||||||
|
break
|
||||||
|
|
||||||
if os.path.isfile(sni_path):
|
if os.path.isfile(sni_path):
|
||||||
snes_logger.info(f"Attempting to start {sni_path}")
|
snes_logger.info(f"Attempting to start {sni_path}")
|
||||||
|
|
|
@ -97,7 +97,7 @@ def create():
|
||||||
os.makedirs(os.path.join(target_folder, 'player-settings'), exist_ok=True)
|
os.makedirs(os.path.join(target_folder, 'player-settings'), exist_ok=True)
|
||||||
|
|
||||||
with open(os.path.join(target_folder, 'player-settings', game_name + ".json"), "w") as f:
|
with open(os.path.join(target_folder, 'player-settings', game_name + ".json"), "w") as f:
|
||||||
f.write(json.dumps(player_settings, indent=2, separators=(',', ': ')))
|
json.dump(player_settings, f, indent=2, separators=(',', ': '))
|
||||||
|
|
||||||
if not world.hidden:
|
if not world.hidden:
|
||||||
weighted_settings["baseOptions"]["game"][game_name] = 0
|
weighted_settings["baseOptions"]["game"][game_name] = 0
|
||||||
|
@ -107,4 +107,4 @@ def create():
|
||||||
weighted_settings["games"][game_name]["gameLocations"] = tuple(world.location_names)
|
weighted_settings["games"][game_name]["gameLocations"] = tuple(world.location_names)
|
||||||
|
|
||||||
with open(os.path.join(target_folder, 'weighted-settings.json'), "w") as f:
|
with open(os.path.join(target_folder, 'weighted-settings.json'), "w") as f:
|
||||||
f.write(json.dumps(weighted_settings, indent=2, separators=(',', ': ')))
|
json.dump(weighted_settings, f, indent=2, separators=(',', ': '))
|
||||||
|
|
Loading…
Reference in New Issue