MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / load

Method load

codewiki/cli/config_manager.py:88–121  ·  view source on GitHub ↗

Load configuration from file and keyring. Returns: True if configuration exists, False otherwise

(self)

Source from the content-addressed store, hash-verified

86 pass
87
88 def load(self) -> bool:
89 """
90 Load configuration from file and keyring.
91
92 Returns:
93 True if configuration exists, False otherwise
94 """
95 # Load from JSON file
96 if not CONFIG_FILE.exists():
97 return False
98
99 try:
100 content = safe_read(CONFIG_FILE)
101 data = json.loads(content)
102
103 # Validate version
104 if data.get('version') != CONFIG_VERSION:
105 # Could implement migration here
106 pass
107
108 self._config = Configuration.from_dict(data)
109
110 # Load API key from keyring, falling back to file
111 if self._keyring_available:
112 try:
113 self._api_key = keyring.get_password(KEYRING_SERVICE, KEYRING_API_KEY_ACCOUNT)
114 except (KeyringError, Exception):
115 pass
116 if self._api_key is None:
117 self._api_key = self._load_api_key_from_file()
118
119 return True
120 except (json.JSONDecodeError, FileSystemError) as e:
121 raise ConfigurationError(f"Failed to load configuration: {e}")
122
123 def save(
124 self,

Callers 9

saveMethod · 0.95
config_setFunction · 0.95
config_showFunction · 0.95
config_validateFunction · 0.95
config_agentFunction · 0.95
generate_commandFunction · 0.95
_load_configFunction · 0.95
load_jsonMethod · 0.80

Calls 5

safe_readFunction · 0.90
ConfigurationErrorClass · 0.90
getMethod · 0.80
from_dictMethod · 0.45

Tested by

no test coverage detected