summaryrefslogtreecommitdiff
path: root/waterspout_radar
diff options
context:
space:
mode:
Diffstat (limited to 'waterspout_radar')
-rw-r--r--waterspout_radar/_config.py5
-rw-r--r--waterspout_radar/cli.py6
2 files changed, 7 insertions, 4 deletions
diff --git a/waterspout_radar/_config.py b/waterspout_radar/_config.py
index 7712939..222f023 100644
--- a/waterspout_radar/_config.py
+++ b/waterspout_radar/_config.py
@@ -33,6 +33,11 @@ class ConfigError(Exception):
"Raised when configuration could not be loaded or was malformed."
+def effective_pathname(pathname: str = None) -> str:
+ "Pathname of the configuration file based on optional *pathname*, environment, and default."
+ return pathname or os.getenv("WATERSPOUT_RADAR_CONFIG") or "waterspout-radar.conf"
+
+
def load(pathname: str) -> Config:
"Loads configuration from a file at *pathname*. May raise ConfigError when content does not meet expectations."
config = configparser.ConfigParser(allow_no_value=True)
diff --git a/waterspout_radar/cli.py b/waterspout_radar/cli.py
index 24f9e53..b8fb041 100644
--- a/waterspout_radar/cli.py
+++ b/waterspout_radar/cli.py
@@ -5,11 +5,9 @@ from . import _config, _radar, _storage
def main():
parser = argparse.ArgumentParser()
- parser.add_argument(
- "-c", "--config", default="radar.conf",
- help="Pathname of the instance configuration file (default: %(default)s)")
+ parser.add_argument("-c", "--config", help="Overrides configuration file pathname.")
args = parser.parse_args()
- config = _config.load(args.config)
+ config = _config.load(_config.effective_pathname(args.config))
storage = _storage.Storage(config.db)
storage.extend(_radar.calculate(config))
for prediction in sorted(storage, key=lambda x: (x.time, x.swi)):