From 6455cad3610b7764fa0c793c620c5b4331e2bb7f Mon Sep 17 00:00:00 2001 From: codemann8 Date: Wed, 17 Aug 2022 14:09:02 -0500 Subject: [PATCH] Fixed Mystery to detect Windows Paths over URLs --- Mystery.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Mystery.py b/Mystery.py index e1be0eb7..d313ac4e 100644 --- a/Mystery.py +++ b/Mystery.py @@ -4,6 +4,8 @@ import RaceRandom as random import urllib.request import urllib.parse import yaml +import os +from pathlib import Path from DungeonRandomizer import parse_cli from Main import main as DRMain @@ -107,10 +109,11 @@ def main(): def get_weights(path): try: - if urllib.parse.urlparse(path).scheme: + if os.path.exists(Path(path)): + with open(path, "r", encoding="utf-8") as f: + return yaml.load(f, Loader=yaml.SafeLoader) + elif urllib.parse.urlparse(path).scheme in ['http', 'https']: return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader) - with open(path, 'r', encoding='utf-8') as f: - return yaml.load(f, Loader=yaml.SafeLoader) except Exception as e: raise Exception(f'Failed to read weights file: {e}')