about summary refs log tree commit diff
path: root/uploader/configutils.py
blob: 7cdb8b28f8d9b857a8b06b2b1a7133c9526e5c22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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