about summary refs log tree commit diff
path: root/uploader/configutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/configutils.py')
-rw-r--r--uploader/configutils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/uploader/configutils.py b/uploader/configutils.py
new file mode 100644
index 0000000..c5db50b
--- /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_DIRECTORY")).absolute()
+    assert _dir.exists() and _dir.is_dir(), (
+        f"'{_dir}' needs to be an existing directory.")
+    return _dir