summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/main.py b/main.py
index aac9e51..c7bdd43 100644
--- a/main.py
+++ b/main.py
@@ -13,14 +13,14 @@ def get_location(args):
config = ConfigParser()
config_location = xdg_config_home().joinpath("auto-dark-mode", "config")
- with open(config_location) as stream:
- config.read_string("[auto-dark-mode]\n" + stream.read())
- config.read(config_location)
-
try:
+ with open(config_location) as stream:
+ config.read_string("[auto-dark-mode]\n" + stream.read())
+ config.read(config_location)
+
latitude = config.getfloat("auto-dark-mode", "latitude")
longitude = config.getfloat("auto-dark-mode", "longitude")
- except NoOptionError:
+ except (FileNotFoundError, NoOptionError):
sys.exit(
f"Please supply latitude and longitude with the --latitude and --longitude flags, or set them in {config_location}"
)