Coverage for app_modules/paths.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-20 00:55 +0200

1""" 

2paths.py 

3 

4Purpose: 

5 Centralize project paths used by the Flask application so that modules do not 

6 compute their own base directories. This simplifies maintenance and allows a 

7 single point of change if the layout evolves. 

8 

9Exports: 

10 - ROOT_DIR: Absolute path to repository root (where `app.py` resides) 

11 - STATIC_PATH: Absolute path to `static/` 

12 - DB_PATH: Absolute path to the SQLite database file `theialogin.db` 

13""" 

14 

15import os 

16 

17 

18ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) 

19# app_modules/ -> project root is one directory up 

20ROOT_DIR = os.path.dirname(ROOT_DIR) 

21STATIC_PATH = os.path.join(ROOT_DIR, 'static') 

22# Allow overriding DB path via environment (useful in Apache/mod_wsgi environments) 

23DB_PATH = os.getenv('DATABASE_PATH') or os.path.join(ROOT_DIR, 'theialogin.db') 

24 

25# Real path to User-photos directory; allow overriding when it is a symlink to 

26# an external volume to keep deletion security checks correct under mod_wsgi. 

27USER_PHOTOS_REAL = os.getenv('USER_PHOTOS_DIR_REAL') or os.path.realpath( 

28 os.path.join(STATIC_PATH, 'User-photos') 

29) 

30 

31