3
3
import os
4
4
5
5
6
- def write_json (output_path , constant_path , unused_path ) :
6
+ def write_json (output_path : str , constant_path : str , unused_path : str ) -> None :
7
7
"""
8
8
Dient zum Mergen von Unused-Dictionary und Constant-Dictionary und anschließende Erzeugen einer JSON - File,
9
9
die das erzeugte Dictionary beinhaltet.
@@ -15,6 +15,7 @@ def write_json(output_path, constant_path, unused_path):
15
15
# Platzhalter für echte Funktion
16
16
# unused_dict = find_unused(unused_path)
17
17
18
+ # entfernen, wenn Funktion aus Issue 433 fertig
18
19
unused_dict = {
19
20
"sklearn/sklearn.__check_build/raise_build_error" : {
20
21
"target" : "sklearn/sklearn.__check_build/raise_build_error"
@@ -23,6 +24,7 @@ def write_json(output_path, constant_path, unused_path):
23
24
# Platzhalter für echte Funktion
24
25
# constant_dict = find_constant(constant_path)
25
26
27
+ # entfernen, wenn Funktion aus Issue 434 fertig
26
28
constant_dict = {
27
29
"sklearn/sklearn._config/config_context/assume_finite" : {
28
30
"target" : "sklearn/sklearn._config/config_context/assume_finite" ,
@@ -45,22 +47,17 @@ def write_json(output_path, constant_path, unused_path):
45
47
"defaultValue" : "3" ,
46
48
},
47
49
}
48
- result_dict = combine_dictionaries (unused_dict , constant_dict )
49
-
50
- # result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction)
51
- # als 2 Parameter können die Rückgabewerte der Funktionen, die die jw. gefragten Dictionaries sind
52
- # eingesetzt werden; derzeit in Bearbeitung
50
+ result_dict = __combine_dictionaries (unused_dict , constant_dict )
53
51
54
52
with open (os .path .join (output_path , "annotations.json" ), "w" ) as file :
55
- # with open(f"{output_path}\\annotations.json", "w") as file:
56
53
json .dump (
57
54
result_dict ,
58
55
file ,
59
56
indent = 2 ,
60
57
)
61
58
62
59
63
- def combine_dictionaries (unused_dict , constant_dict ) :
60
+ def __combine_dictionaries (unused_dict : dict , constant_dict : dict ) -> dict :
64
61
"""
65
62
Funktion, die die Dictionaries kombiniert
66
63
:param unused_dict : Dictionary der unused annotations
@@ -75,31 +72,31 @@ def combine_dictionaries(unused_dict, constant_dict):
75
72
return result_dict
76
73
77
74
75
+ # sollte, sobald final eingebunden wird entfernt werden, da es nicht weiter benötigt wird, dient zZ. nur zur Anschauung
78
76
if __name__ == "__main__" :
79
77
parser = argparse .ArgumentParser (prog = "combine" )
80
78
79
+ # Argument 1: outputPath
81
80
parser .add_argument (
82
81
"outputPath" ,
83
82
metavar = "output-filepath" ,
84
83
type = str ,
85
84
help = "paste the location of the output file in here " ,
86
85
)
87
- # Argument 1: outputPath
86
+ # Argument 2: inputPath(Pfad einer Constant-Datei)
88
87
parser .add_argument (
89
88
"constantPath" ,
90
89
metavar = "input-filepath" ,
91
90
type = str ,
92
91
help = 'paste the location of the "constant" file in here ' ,
93
92
)
94
- # Argument 2 : inputPath(Pfad einer Constant -Datei)
93
+ # Argument 3 : inputPath(Pfad einer Unused -Datei)
95
94
parser .add_argument (
96
95
"unusedPath" ,
97
96
metavar = "input-filepath" ,
98
97
type = str ,
99
98
help = 'paste the location of the "unused" file in here ' ,
100
99
)
101
- # Argument 3: inputPath(Pfad einer Unused-Datei)
100
+ # Erzeuge kombinierte JSON-Datei jeweils aus der Constant- und der Unused-Dictionary
102
101
args = parser .parse_args () # Argumente werden auf Nutzen als Parameter vorbereitet
103
102
write_json (args .outputPath , args .constantPath , args .unusedPath )
104
-
105
- # Erzeuge kombinierte JSON-Datei jw. aus der Constant- und der Unused-Dictionary
0 commit comments