Coverage for src / local_deep_research / defaults / __init__.py: 89%

19 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-14 23:55 +0000

1""" 

2Default configuration module for Local Deep Research. 

3 

4This module is responsible for loading and initializing default 

5configuration files and resources used throughout the application. 

6""" 

7 

8from loguru import logger 

9from pathlib import Path 

10 

11 

12# Define the path to the package's defaults directory 

13DEFAULTS_DIR = Path(__file__).parent 

14 

15# Default files available in this package 

16DEFAULT_FILES = { 

17 "main.toml": DEFAULTS_DIR / "main.toml", 

18 "search_engines.toml": DEFAULTS_DIR / "search_engines.toml", 

19} 

20 

21 

22def get_default_file_path(filename): 

23 """Get the path to a default configuration file.""" 

24 if filename in DEFAULT_FILES: 

25 return DEFAULT_FILES[filename] 

26 return None 

27 

28 

29def list_default_files(): 

30 """List all available default configuration files.""" 

31 return list(DEFAULT_FILES.keys()) 

32 

33 

34def ensure_defaults_exist(): 

35 """Verify that all expected default files exist in the package.""" 

36 missing = [] 

37 for filename, filepath in DEFAULT_FILES.items(): 

38 if not filepath.exists(): 38 ↛ 37line 38 didn't jump to line 37 because the condition on line 38 was always true

39 missing.append(filename) 

40 

41 if missing: 41 ↛ 46line 41 didn't jump to line 46 because the condition on line 41 was always true

42 logger.warning( 

43 f"The following default files are missing from the package: {', '.join(missing)}" 

44 ) 

45 return False 

46 return True