style: format all Python files with Black
Apply Black formatter to the entire codebase for consistent code style. Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
负责加载、合并和验证配置,优先从环境变量加载。
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from typing import Any, Dict
|
||||
@@ -27,7 +28,9 @@ class ConfigLoader:
|
||||
"""配置加载器"""
|
||||
|
||||
@staticmethod
|
||||
def load(config_file: str = "config/user_settings.json", use_env: bool = True) -> AppConfig:
|
||||
def load(
|
||||
config_file: str = "config/user_settings.json", use_env: bool = True
|
||||
) -> AppConfig:
|
||||
"""
|
||||
加载配置
|
||||
|
||||
@@ -111,18 +114,36 @@ class ConfigLoader:
|
||||
"ERP_IGNORE_HTTPS_ERRORS": config.erp.ignore_https_errors,
|
||||
"ERP_AUTO_CLOSE_BROWSER": config.erp.auto_close_browser,
|
||||
# 数据库配置
|
||||
"DB_TYPE": config.database.db_type.value if isinstance(config.database.db_type, DatabaseType) else config.database.db_type,
|
||||
"DB_TYPE": (
|
||||
config.database.db_type.value
|
||||
if isinstance(config.database.db_type, DatabaseType)
|
||||
else config.database.db_type
|
||||
),
|
||||
"DB_SERVER": config.database.server,
|
||||
"DB_NAME": config.database.database,
|
||||
"DB_USERNAME": config.database.username,
|
||||
"DB_PASSWORD": config.database.password,
|
||||
# SQL Server 特定配置
|
||||
"DB_SQLSERVER_DRIVER": config.database.sqlserver.driver if config.database.sqlserver else "ODBC Driver 18 for SQL Server",
|
||||
"DB_TRUST_SERVER_CERTIFICATE": config.database.sqlserver.trust_server_certificate if config.database.sqlserver else "yes",
|
||||
"DB_SQLSERVER_DRIVER": (
|
||||
config.database.sqlserver.driver
|
||||
if config.database.sqlserver
|
||||
else "ODBC Driver 18 for SQL Server"
|
||||
),
|
||||
"DB_TRUST_SERVER_CERTIFICATE": (
|
||||
config.database.sqlserver.trust_server_certificate
|
||||
if config.database.sqlserver
|
||||
else "yes"
|
||||
),
|
||||
# MySQL 特定配置
|
||||
"DB_MYSQL_HOST": config.database.mysql.host if config.database.mysql else "",
|
||||
"DB_MYSQL_PORT": config.database.mysql.port if config.database.mysql else 3306,
|
||||
"DB_MYSQL_CHARSET": config.database.mysql.charset if config.database.mysql else "utf8mb4",
|
||||
"DB_MYSQL_HOST": (
|
||||
config.database.mysql.host if config.database.mysql else ""
|
||||
),
|
||||
"DB_MYSQL_PORT": (
|
||||
config.database.mysql.port if config.database.mysql else 3306
|
||||
),
|
||||
"DB_MYSQL_CHARSET": (
|
||||
config.database.mysql.charset if config.database.mysql else "utf8mb4"
|
||||
),
|
||||
# 路径配置
|
||||
"PATH_DATA_DIR": config.paths.data_dir,
|
||||
"PATH_PRODUCTION_ID_FILE": config.paths.production_id_file,
|
||||
@@ -199,7 +220,9 @@ class ConfigLoader:
|
||||
sqlserver_dict = database_dict.get("sqlserver", {})
|
||||
sqlserver_config = SQLServerConfig(
|
||||
driver=sqlserver_dict.get("driver", "ODBC Driver 18 for SQL Server"),
|
||||
trust_server_certificate=sqlserver_dict.get("trust_server_certificate", "yes"),
|
||||
trust_server_certificate=sqlserver_dict.get(
|
||||
"trust_server_certificate", "yes"
|
||||
),
|
||||
)
|
||||
|
||||
# 解析 MySQL 配置
|
||||
@@ -243,16 +266,18 @@ class ConfigLoader:
|
||||
verbose=extraction_dict.get("verbose", True),
|
||||
auto_convert=extraction_dict.get("auto_convert", True),
|
||||
merge_batches=extraction_dict.get("merge_batches", True),
|
||||
enable_db_persistence=extraction_dict.get("enable_db_persistence", False),
|
||||
enable_db_persistence=extraction_dict.get(
|
||||
"enable_db_persistence", False
|
||||
),
|
||||
),
|
||||
validation=ValidationConfig(
|
||||
data_source=validation_dict.get("data_source", "database_full"),
|
||||
use_database=validation_dict.get("use_database", True),
|
||||
batch_size=validation_dict.get("batch_size", 2000),
|
||||
enable_crud_operations=validation_dict.get("enable_crud_operations", False),
|
||||
enable_crud_operations=validation_dict.get(
|
||||
"enable_crud_operations", False
|
||||
),
|
||||
default_manager=validation_dict.get("default_manager", ""),
|
||||
match_mode=validation_dict.get("match_mode", "substring"),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user