about summary refs log tree commit diff
path: root/uploader/configutils.py
blob: c5db50b8835bf318959cf14725f9e3c00f556c10 (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_DIRECTORY")).absolute()
    assert _dir.exists() and _dir.is_dir(), (
        f"'{_dir}' needs to be an existing directory.")
    return _dir