diff options
| author | Frederick Muriuki Muriithi | 2026-01-26 14:47:50 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-01-26 14:47:50 -0600 |
| commit | b807626b37e9ac743287bfc7e092e71d77da5c26 (patch) | |
| tree | 9fc550f625cd6bee094e1bc16396c727c819cb03 /uploader/configutils.py | |
| parent | 5705666ac0025ecc83c9cdb4ee0ebf94983ee069 (diff) | |
| download | gn-uploader-b807626b37e9ac743287bfc7e092e71d77da5c26.tar.gz | |
Provide some utilities to fetch common config variables.
Diffstat (limited to 'uploader/configutils.py')
| -rw-r--r-- | uploader/configutils.py | 13 |
1 files changed, 13 insertions, 0 deletions
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 |
