@@ -121,9 +121,9 @@ def generate_config_files(experiment: ExperimentData):
121
121
122
122
for permutation in permutations :
123
123
configItems = {}
124
- configItems .update (constants )
125
124
for name , value in permutation .items ():
126
125
configItems [name ] = value
126
+ configItems .update (constants )
127
127
configDict [f'config{ configIdNumber } ' ] = ConfigData (data = configItems )
128
128
explogger .info (f'Generated config { configIdNumber } ' )
129
129
configIdNumber += 1
@@ -147,12 +147,20 @@ def create_config_from_data(experiment: ExperimentData, configNum: int):
147
147
raise GladosInternalError (msg ) from err
148
148
149
149
os .chdir ('configFiles' )
150
- outputConfig = configparser .ConfigParser ()
151
- outputConfig .optionxform = str # type: ignore # Must use this to make the file case sensitive, but type checker is unhappy without this ignore rule
152
- outputConfig ["DEFAULT" ] = configData
150
+ # DONE: Change to custom function to create ini file
151
+ configFileLines = ["[DEFAULT]" ]
152
+ for line in experiment .dumbTextArea .split ('\n ' ):
153
+ configFileLines .append (line .replace ('\n ' , '' ))
154
+
155
+ for key , value in configData .items ():
156
+ if "{" + key + "}" in experiment .dumbTextArea :
157
+ for i , line in enumerate (configFileLines ):
158
+ configFileLines [i ] = line .replace ("{" + key + "}" , str (value ))
159
+ else :
160
+ configFileLines .append (f"{ key } = { value } " )
161
+
153
162
with open (f'{ configNum } .ini' , 'w' , encoding = "utf8" ) as configFile :
154
- outputConfig .write (configFile )
155
- configFile .write (experiment .dumbTextArea )
163
+ configFile .write ('\n ' .join (configFileLines ))
156
164
configFile .close ()
157
165
explogger .info (f"Wrote config{ configNum } to a file" )
158
166
os .chdir ('..' )
0 commit comments