summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-04-05 21:23:35 +0200
committerAki <please@ignore.pl>2023-04-05 21:23:35 +0200
commit9578d46e006efed6b0ea465cd4a809214d45a3ac (patch)
tree0e3370b51521962686c0668e18e807b7bca28c9d
parentdca92b16a5adbfea7496d36ced00bf4eb503de20 (diff)
downloadwaterspout-radar-9578d46e006efed6b0ea465cd4a809214d45a3ac.zip
waterspout-radar-9578d46e006efed6b0ea465cd4a809214d45a3ac.tar.gz
waterspout-radar-9578d46e006efed6b0ea465cd4a809214d45a3ac.tar.bz2
Simplified configuration file
-rw-r--r--contrib/waterspout-radar.conf10
-rw-r--r--waterspout_radar/_config.py17
2 files changed, 7 insertions, 20 deletions
diff --git a/contrib/waterspout-radar.conf b/contrib/waterspout-radar.conf
index 441c48e..be204b7 100644
--- a/contrib/waterspout-radar.conf
+++ b/contrib/waterspout-radar.conf
@@ -1,14 +1,8 @@
-[Storage]
+[Waterspout Radar]
db = /srv/waterspout-radar/db.json
+; key = <Your private Windy API key goes here>
[Locations]
;; Put desired locations here, by name or by coords:
; Szczecin
; 54.372, 18.648
-
-[Windy]
-;; Put your private Windy API key here:
-; key = ...
-
-[Web]
-port = 40732
diff --git a/waterspout_radar/_config.py b/waterspout_radar/_config.py
index eaa6c58..7712939 100644
--- a/waterspout_radar/_config.py
+++ b/waterspout_radar/_config.py
@@ -8,18 +8,13 @@ Implements loading and providing the configuration of the radar instance. Usage
An example configuration file looks like this:
- [Storage]
+ [Waterspout Radar]
db = .waterspout/db.json
+ key = <secret key>
[Locations]
New York City
Jersey City
-
- [Windy]
- key = <secret key>
-
- [Web]
- port = 80
"""
import configparser
@@ -29,10 +24,9 @@ import typing
@dataclasses.dataclass
class Config:
+ db: str
key: str
locations: typing.List[str]
- db: str
- port: int
class ConfigError(Exception):
@@ -59,9 +53,8 @@ def load(pathname: str) -> Config:
if required:
errors.append(f"Config is missing required field: {pathname}: {section}: {name}")
- _load_key("Storage", "db", default="radar.json")
- _load_key("Windy", "key", required=True)
- _load_key("Web", "port", type=int)
+ _load_key("Waterspout Radar", "db", default="radar.json")
+ _load_key("Waterspout Radar", "key", required=True)
try:
raw["locations"] = list(config["Locations"])
except KeyError: