"""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