Load configuration from file and keyring. Returns: True if configuration exists, False otherwise
(self)
| 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, |
no test coverage detected