-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtools_dict.py
42 lines (31 loc) · 1.11 KB
/
tools_dict.py
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
#!/usr/bin/python3
# coding=utf-8
import os
import configparser
import json
styleIniPath = os.path.dirname(os.path.abspath(__file__))
styleIniPath = f"{styleIniPath}\config\config.ini"
conf_style = configparser.ConfigParser()
conf_style.read(filenames=styleIniPath, encoding="utf-8")
funlist = conf_style.get("tool", "funList")
funlist = json.loads(funlist)
def tools_root_path():
rootPath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
return rootPath
def toolsDir(type_mark=funlist[0][1]):
tools_dict = {}
tool_type_root_dir = tools_root_path()
tool_type_dir = sorted([
i for i in os.listdir(tool_type_root_dir)
if (os.path.isdir(f"{tool_type_root_dir}\{i}")
and i.count(type_mark) == 1)
])
for toolType in tool_type_dir:
tools = sorted([
i for i in os.listdir(f'{tool_type_root_dir}\{toolType}')
if os.path.isdir(f'{tool_type_root_dir}\{toolType}\{i}')
])
tools_dict[toolType] = tools
return tools_dict
if __name__ == '__main__':
print(toolsDir())