@@ -215,7 +215,7 @@ def write_json(messages, modules, extra_inputs: list[str], filename: str, stable
215215
216216
217217def read_stable (stable_filenames : list [str ]):
218- stable_catalog = dict ()
218+ stable_catalog = dict (messages = [], modules = [] )
219219 for filename in stable_filenames :
220220 with open (filename , "r" ) as f :
221221 stable_catalog .update (json .load (f ))
@@ -397,10 +397,12 @@ def main():
397397 args = parse_cmdline ()
398398
399399 stable_catalog = read_stable (args .stable_json )
400+ stable_messages = stable_catalog .get ("messages" , [])
401+ stable_modules = stable_catalog .get ("modules" , [])
400402 try :
401403 stable_ids = (
402- {stable_msg_key (msg ): msg ["id" ] for msg in stable_catalog [ "messages" ] },
403- {m ["string" ]: m ["id" ] for m in stable_catalog [ "modules" ] },
404+ {stable_msg_key (msg ): msg ["id" ] for msg in stable_messages },
405+ {m ["string" ]: m ["id" ] for m in stable_modules },
404406 )
405407 modules , messages = read_input (args .input , stable_ids )
406408 except Exception as e :
@@ -411,9 +413,7 @@ def main():
411413
412414 stable_output = dict (messages = [], modules = [])
413415 if not args .forget_old_ids :
414- stable_output = dict (
415- messages = stable_catalog ["messages" ], modules = stable_catalog ["modules" ]
416- )
416+ stable_output = dict (messages = stable_messages , modules = stable_modules )
417417
418418 if args .json_output is not None :
419419 write_json (messages , modules , args .json_input , args .json_output , stable_output )
0 commit comments