保存配置到文件
(self)
| 178 | } |
| 179 | |
| 180 | def save_config(self): |
| 181 | """保存配置到文件""" |
| 182 | try: |
| 183 | # 确保配置目录存在 |
| 184 | os.makedirs(os.path.dirname(self.config_file), exist_ok=True) |
| 185 | |
| 186 | config_dict = self._config_to_dict(self.config) |
| 187 | with open(self.config_file, 'w', encoding='utf-8') as f: |
| 188 | json.dump(config_dict, f, ensure_ascii=False, indent=2) |
| 189 | logger.info(f"配置已保存到: {self.config_file}") |
| 190 | except Exception as e: |
| 191 | logger.error(f"保存配置失败: {e}") |
| 192 | |
| 193 | def get_ocr_config(self) -> OCRConfig: |
| 194 | """获取OCR配置""" |
no test coverage detected