MCPcopy Index your code
hub / github.com/BasicProtein/AugmentCode-Free / main

Function main

main.py:19–117  ·  view source on GitHub ↗

主函数 - 启动GUI应用程序

()

Source from the content-addressed store, hash-verified

17from pathlib import Path
18
19def main():
20 """主函数 - 启动GUI应用程序"""
21 # 强化路径设置 - 确保跨平台兼容
22 current_dir = Path(__file__).resolve().parent
23 current_dir_str = str(current_dir)
24
25 # 清理并重新设置Python路径
26 if current_dir_str in sys.path:
27 sys.path.remove(current_dir_str)
28 sys.path.insert(0, current_dir_str)
29
30 # 确保工作目录正确
31 os.chdir(current_dir)
32
33 try:
34 # 导入配置和语言管理
35 from config_manager import get_config_manager
36 from language_manager import get_language_manager, get_text
37
38 # 如果没有在ImportError中初始化,在这里初始化
39 if 'config_manager' not in locals():
40 config_manager = get_config_manager()
41 language_manager = get_language_manager(config_manager)
42
43 print("=" * 50)
44 print(get_text("console.starting"))
45 print("=" * 50)
46 print()
47
48 # 导入并启动PyQt6 GUI
49 from gui_qt6.main_window import main as gui_main
50
51 print(get_text("console.gui_starting"))
52 print(get_text("console.gui_tip"))
53 print()
54
55 # 启动PyQt6 GUI
56 exit_code = gui_main()
57 sys.exit(exit_code)
58
59 except ImportError as e:
60 print(f"❌ 导入错误: {e}")
61 print()
62 print("🔧 正在尝试自动修复...")
63
64 # 尝试多种路径修复方案
65 possible_paths = [
66 current_dir,
67 current_dir.parent,
68 Path.cwd(),
69 Path(__file__).parent
70 ]
71
72 fixed = False
73 for path in possible_paths:
74 try:
75 path_str = str(path.resolve())
76 if path_str not in sys.path:

Callers 1

main.pyFile · 0.70

Calls 3

get_config_managerFunction · 0.90
get_language_managerFunction · 0.90
get_textFunction · 0.90

Tested by

no test coverage detected