33
44
55class Methods :
6- def __init__ (self , data_filepath , output_filepath ):
6+ @staticmethod
7+ def write_selection_dataset_to_front_file (
8+ selection_dataset , front_selection_resource_path
9+ ):
10+ with open (front_selection_resource_path , "w" ) as f :
11+ f .write ("export const METHODS = " )
12+ json .dump (selection_dataset , f , indent = 4 )
13+
14+ @staticmethod
15+ def get_dlls_with_all_methods_dict_from_front_options_file (
16+ front_selection_resource_path ,
17+ ):
18+ with open (front_selection_resource_path , "r" ) as f :
19+ content = f .read ()
20+ prefix = "export const METHODS = "
21+ json_str = content [len (prefix ) :]
22+ selection_tree = json .loads (json_str )
23+
24+ dll_methods = defaultdict (list )
25+ for node in selection_tree :
26+ dll_name = node ["title" ] + ".dll"
27+ dll_methods [dll_name ] = []
28+ for child in node ["children" ]:
29+ dll_methods [dll_name ].append (child ["value" ])
30+ return dll_methods
31+
32+ @staticmethod
33+ def parse_dataset_file_for_front_selection (data_filepath ):
734 with open (data_filepath , "r" ) as f :
835 data = json .load (f )
936
10- self .dll_methods = defaultdict (list )
1137 groups = defaultdict (list )
1238 for item in data :
1339 groups [item ["AssemblyFullName" ]].append (item )
14- self .dll_methods [item ["AssemblyFullName" ]] = []
1540
16- tree = []
41+ dataset_tree = []
1742 for assembly , items in groups .items ():
1843 node = {"title" : assembly [:- 4 ], "value" : assembly , "children" : []}
1944 seen_children = set ()
@@ -22,21 +47,18 @@ def __init__(self, data_filepath, output_filepath):
2247 if name in seen_children :
2348 continue
2449 seen_children .add (name )
25- dll_method = f"{ assembly } ,{ name } "
26- self .dll_methods [assembly ].append (dll_method )
27- child_node = {"title" : name , "value" : dll_method }
50+ dll_and_method = f"{ assembly } ,{ name } "
51+ child_node = {"title" : name , "value" : dll_and_method }
2852 node ["children" ].append (child_node )
29- tree .append (node )
30-
31- with open (output_filepath , "w" ) as f :
32- f .write ("export const METHODS = " )
33- json .dump (tree , f , indent = 4 )
53+ dataset_tree .append (node )
54+ return dataset_tree
3455
35- def get_methods_from_selection (self , selection_list ):
36- selected_methods = []
37- for item in selection_list :
38- if item in self .dll_methods .keys ():
39- selected_methods .extend (self .dll_methods [item ])
56+ @staticmethod
57+ def get_launch_info_list_from_selected (dll_methods : defaultdict , selected ):
58+ launch_info_methods = []
59+ for item in selected :
60+ if item in dll_methods .keys ():
61+ launch_info_methods .extend (dll_methods [item ])
4062 else :
41- selected_methods .append (item )
42- return selected_methods
63+ launch_info_methods .append (item )
64+ return launch_info_methods
0 commit comments