Coverage for app/venv/lib/python3.14/site-packages/weblate/utils/data.py: 88%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 07:15 +0000

1# Copyright © Michal Čihař <michal@weblate.org> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5"""Data files helpers.""" 

6 

7from __future__ import annotations 

8 

9import os 

10from pathlib import Path 

11 

12from django.conf import settings 

13 

14 

15def data_dir(component, *args): 

16 """Return path to data dir for given component.""" 

17 # TODO: remove once all users are migrated to data_path 

18 if component == "cache" and settings.CACHE_DIR: 18 ↛ 19line 18 didn't jump to line 19 because the condition on line 18 was never true

19 return os.path.join(settings.CACHE_DIR, *args) 

20 return os.path.join(settings.DATA_DIR, component, *args) 

21 

22 

23def data_path(component: str) -> Path: 

24 """Return path to data dir for given component.""" 

25 if component == "cache" and settings.CACHE_DIR: 

26 # Honor cache directory if configured, legacy setups have it 

27 # as a subdirectory of the data directory. 

28 return Path(settings.CACHE_DIR) 

29 return Path(settings.DATA_DIR) / component