MCPcopy
hub / github.com/qodo-ai/qodo-cover / SingletonSettings

Class SingletonSettings

cover_agent/settings/config_loader.py:18–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18class SingletonSettings:
19 _instance = None
20
21 def __new__(cls, *args, **kwargs):
22 if not cls._instance:
23 cls._instance = super(SingletonSettings, cls).__new__(cls, *args, **kwargs)
24 return cls._instance
25
26 def __init__(self):
27 """
28 Initialize the SingletonSettings instance by loading settings from the specified configuration files.
29 Check if the 'settings' attribute is not already set, then construct the paths to the settings files based on the current directory.
30 Ensure that all settings files exist by checking their presence using the 'os.path.exists' function.
31 If any of the settings files are missing, raise a 'FileNotFoundError' with a message indicating the missing file.
32 Finally, initialize the 'settings' attribute with a Dynaconf instance using the specified settings files and configuration options.
33
34 Parameters:
35 self: SingletonSettings
36 The SingletonSettings instance to be initialized.
37
38 Raises:
39 FileNotFoundError: If any of the specified settings files are not found.
40
41 Returns:
42 None
43 """
44 if not hasattr(self, "settings"):
45 # Determine the base directory for bundled app or normal environment
46 base_dir = getattr(sys, "_MEIPASS", dirname(abspath(__file__)))
47
48 settings_files = [join(base_dir, f) for f in SETTINGS_FILES]
49
50 # Ensure all settings files exist
51 for file_path in settings_files:
52 if not exists(file_path):
53 raise FileNotFoundError(f"Settings file not found: {file_path}")
54
55 self.settings = Dynaconf(
56 envvar_prefix=False, merge_enabled=True, settings_files=settings_files
57 )
58
59
60def get_settings() -> Dynaconf:

Callers 1

get_settingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected