-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpath_manager_factory.py
More file actions
46 lines (37 loc) · 1.37 KB
/
path_manager_factory.py
File metadata and controls
46 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
路径管理器工厂
根据编译工具类型创建相应的路径管理器
"""
from typing import Union
from lib_IAR.path_manager import IARPathManager
from lib_MDK.path_manager import MDKPathManager
class PathManagerFactory:
"""路径管理器工厂类"""
@staticmethod
def create_path_manager(compile_tool: str, project_path: str = None) -> Union[IARPathManager, MDKPathManager]:
"""
根据编译工具类型创建相应的路径管理器
Args:
compile_tool: 编译工具类型 ('IAR' 或 'MDK')
project_path: 项目路径
Returns:
Union[IARPathManager, MDKPathManager]: 相应的路径管理器实例
Raises:
ValueError: 当编译工具类型不支持时
"""
if compile_tool.upper() == 'IAR':
return IARPathManager(project_path)
elif compile_tool.upper() == 'MDK':
return MDKPathManager(project_path)
else:
raise ValueError(f"不支持的编译工具类型: {compile_tool}。支持的类型: IAR, MDK")
@staticmethod
def get_supported_tools() -> list:
"""
获取支持的编译工具列表
Returns:
list: 支持的编译工具列表
"""
return ['IAR', 'MDK']