MCPcopy Create free account
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 # Restrict file permissions (owner read/write only)
87 try:
88 CREDENTIALS_FILE.chmod(0o600)
89 except OSError:
90 pass
91
92 def load(self) -> bool:
93 """
94 Load configuration from file and keyring.
95
96 Returns:
97 True if configuration exists, False otherwise
98 """
99 # Load from JSON file
100 if not CONFIG_FILE.exists():
101 return False
102
103 try:
104 content = safe_read(CONFIG_FILE)
105 data = json.loads(content)
106
107 # Validate version
108 if data.get("version") != CONFIG_VERSION:
109 # Could implement migration here
110 pass
111
112 self._config = Configuration.from_dict(data)
113
114 # Load API key from keyring, falling back to file
115 if self._keyring_available:
116 try:
117 self._api_key = keyring.get_password(KEYRING_SERVICE, KEYRING_API_KEY_ACCOUNT)
118 except (KeyringError, Exception):
119 pass
120 if self._api_key is None:
121 self._api_key = self._load_api_key_from_file()
122
123 return True
124 except (json.JSONDecodeError, FileSystemError) as e:

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