From b807626b37e9ac743287bfc7e092e71d77da5c26 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 26 Jan 2026 14:47:50 -0600 Subject: Provide some utilities to fetch common config variables. --- uploader/configutils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 uploader/configutils.py (limited to 'uploader/configutils.py') diff --git a/uploader/configutils.py b/uploader/configutils.py new file mode 100644 index 0000000..7cdb8b2 --- /dev/null +++ b/uploader/configutils.py @@ -0,0 +1,13 @@ +"""Functions to fetch settings.""" +from pathlib import Path + +def fetch_setting(app, setting): + """Fetch a specified configuration `setting` from the `app` object.""" + return app.config[setting] + +def uploads_dir(app) -> Path: + """Fetch the uploads directory""" + _dir = Path(fetch_setting(app, "UPLOADS_DIR")).absolute() + assert _dir.exists() and _dir.is_dir(), ( + f"'{_dir}' needs to be an existing directory.") + return _dir -- cgit 1.4.1