style: normalize code formatting across the codebase
- Standardize quote style (single to double quotes) - Improve code formatting consistency - Apply formatting to utilities, GUI components, and tools - Update imports and docstrings for consistency Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ from config.schema import (
|
||||
DatabaseConfig,
|
||||
PathConfig,
|
||||
ExtractionConfig,
|
||||
AppConfig
|
||||
AppConfig,
|
||||
)
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ DEFAULT_APP_CONFIG = AppConfig(
|
||||
verbose=True,
|
||||
auto_convert=True,
|
||||
merge_batches=True,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -28,10 +28,12 @@ class ConfigLoader:
|
||||
"""
|
||||
if os.path.exists(config_file):
|
||||
try:
|
||||
with open(config_file, 'r', encoding='utf-8') as f:
|
||||
with open(config_file, "r", encoding="utf-8") as f:
|
||||
loaded_settings = json.load(f)
|
||||
# 合并默认配置和加载的配置
|
||||
merged_settings = ConfigLoader._merge_settings(DEFAULT_SETTINGS_DICT, loaded_settings)
|
||||
merged_settings = ConfigLoader._merge_settings(
|
||||
DEFAULT_SETTINGS_DICT, loaded_settings
|
||||
)
|
||||
return ConfigLoader._dict_to_config(merged_settings)
|
||||
except (json.JSONDecodeError, IOError) as e:
|
||||
print(f"加载配置文件失败: {e},使用默认配置")
|
||||
@@ -57,7 +59,7 @@ class ConfigLoader:
|
||||
# 确保配置目录存在
|
||||
os.makedirs(os.path.dirname(config_file), exist_ok=True)
|
||||
|
||||
with open(config_file, 'w', encoding='utf-8') as f:
|
||||
with open(config_file, "w", encoding="utf-8") as f:
|
||||
json.dump(config.to_dict(), f, ensure_ascii=False, indent=2)
|
||||
return True
|
||||
except IOError as e:
|
||||
@@ -79,7 +81,11 @@ class ConfigLoader:
|
||||
result = defaults.copy()
|
||||
|
||||
for key, value in loaded.items():
|
||||
if key in result and isinstance(result[key], dict) and isinstance(value, dict):
|
||||
if (
|
||||
key in result
|
||||
and isinstance(result[key], dict)
|
||||
and isinstance(value, dict)
|
||||
):
|
||||
result[key] = ConfigLoader._merge_settings(result[key], value)
|
||||
else:
|
||||
result[key] = value
|
||||
@@ -117,20 +123,26 @@ class ConfigLoader:
|
||||
username=database_dict.get("username", ""),
|
||||
password=database_dict.get("password", ""),
|
||||
driver=database_dict.get("driver", "ODBC Driver 18 for SQL Server"),
|
||||
trust_server_certificate=database_dict.get("trust_server_certificate", "yes"),
|
||||
trust_server_certificate=database_dict.get(
|
||||
"trust_server_certificate", "yes"
|
||||
),
|
||||
),
|
||||
paths=PathConfig(
|
||||
data_dir=paths_dict.get("data_dir", ""),
|
||||
production_id_file=paths_dict.get("production_id_file", ""),
|
||||
default_output=paths_dict.get("default_output", "离散备料计划维护_合并.xlsx"),
|
||||
validation_output=paths_dict.get("validation_output", "物料状态校验结果.xlsx"),
|
||||
default_output=paths_dict.get(
|
||||
"default_output", "离散备料计划维护_合并.xlsx"
|
||||
),
|
||||
validation_output=paths_dict.get(
|
||||
"validation_output", "物料状态校验结果.xlsx"
|
||||
),
|
||||
),
|
||||
extraction=ExtractionConfig(
|
||||
batch_size=extraction_dict.get("batch_size", 100),
|
||||
verbose=extraction_dict.get("verbose", True),
|
||||
auto_convert=extraction_dict.get("auto_convert", True),
|
||||
merge_batches=extraction_dict.get("merge_batches", True),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from pathlib import Path
|
||||
@dataclass
|
||||
class ERPConfig:
|
||||
"""ERP 系统配置"""
|
||||
|
||||
url: str
|
||||
username: str
|
||||
password: str
|
||||
@@ -35,6 +36,7 @@ class ERPConfig:
|
||||
@dataclass
|
||||
class DatabaseConfig:
|
||||
"""数据库配置"""
|
||||
|
||||
server: str
|
||||
database: str
|
||||
username: str
|
||||
@@ -59,6 +61,7 @@ class DatabaseConfig:
|
||||
@dataclass
|
||||
class PathConfig:
|
||||
"""文件路径配置"""
|
||||
|
||||
data_dir: str
|
||||
production_id_file: str
|
||||
default_output: str = "离散备料计划维护_合并.xlsx"
|
||||
@@ -77,6 +80,7 @@ class PathConfig:
|
||||
@dataclass
|
||||
class ExtractionConfig:
|
||||
"""数据提取配置"""
|
||||
|
||||
batch_size: int = 100
|
||||
verbose: bool = True
|
||||
auto_convert: bool = True
|
||||
@@ -95,6 +99,7 @@ class ExtractionConfig:
|
||||
@dataclass
|
||||
class AppConfig:
|
||||
"""应用总配置"""
|
||||
|
||||
erp: ERPConfig
|
||||
database: DatabaseConfig
|
||||
paths: PathConfig
|
||||
@@ -139,5 +144,5 @@ class AppConfig:
|
||||
"verbose": self.extraction.verbose,
|
||||
"auto_convert": self.extraction.auto_convert,
|
||||
"merge_batches": self.extraction.merge_batches,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user