From 2bec95b4f8ce15942f6a9f6207394f5378448456 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 23 Mar 2020 07:59:55 +0100 Subject: [PATCH] make get_options a bit more refined --- Utils.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Utils.py b/Utils.py index f1fe61bd..456e7d28 100644 --- a/Utils.py +++ b/Utils.py @@ -172,20 +172,16 @@ def get_public_ipv4() -> str: return ip -_options = None - - def get_options() -> dict: - global _options - if _options: - return _options - else: + if not hasattr(get_options, "options"): locations = ("options.yaml", "host.yaml", local_path("options.yaml"), local_path("host.yaml")) for location in locations: if os.path.exists(location): with open(location) as f: - _options = parse_yaml(f.read()) - return _options - raise FileNotFoundError(f"Could not find {locations[1]} to load options.") + get_options.options = parse_yaml(f.read()) + break + else: + raise FileNotFoundError(f"Could not find {locations[1]} to load options.") + return get_options.options