Fix yaml parsing
This commit is contained in:
@@ -334,12 +334,9 @@ class CustomSettings(object):
|
|||||||
|
|
||||||
|
|
||||||
def load_yaml(path):
|
def load_yaml(path):
|
||||||
try:
|
if os.path.exists(Path(path)):
|
||||||
return yaml.load(path, Loader=yaml.SafeLoader)
|
with open(path, "r", encoding="utf-8") as f:
|
||||||
except yaml.YAMLError as exc:
|
return yaml.load(f, Loader=yaml.SafeLoader)
|
||||||
if os.path.exists(Path(path)):
|
elif urllib.parse.urlparse(path).scheme in ['http', 'https']:
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader)
|
||||||
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)
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,11 @@ import yaml
|
|||||||
|
|
||||||
|
|
||||||
def get_weights(path):
|
def get_weights(path):
|
||||||
try:
|
if os.path.exists(Path(path)):
|
||||||
return yaml.load(path, Loader=yaml.SafeLoader)
|
with open(path, "r", encoding="utf-8") as f:
|
||||||
except yaml.YAMLError as exc:
|
return yaml.load(f, Loader=yaml.SafeLoader)
|
||||||
if os.path.exists(Path(path)):
|
elif urllib.parse.urlparse(path).scheme in ['http', 'https']:
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader)
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
def roll_settings(weights):
|
def roll_settings(weights):
|
||||||
|
|||||||
Reference in New Issue
Block a user