@@ -215,7 +215,7 @@ def write_json(messages, modules, extra_inputs: list[str], filename: str, stable
215
215
216
216
217
217
def read_stable (stable_filenames : list [str ]):
218
- stable_catalog = dict ()
218
+ stable_catalog = dict (messages = [], modules = [] )
219
219
for filename in stable_filenames :
220
220
with open (filename , "r" ) as f :
221
221
stable_catalog .update (json .load (f ))
@@ -397,10 +397,12 @@ def main():
397
397
args = parse_cmdline ()
398
398
399
399
stable_catalog = read_stable (args .stable_json )
400
+ stable_messages = stable_catalog .get ("messages" , [])
401
+ stable_modules = stable_catalog .get ("modules" , [])
400
402
try :
401
403
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 },
404
406
)
405
407
modules , messages = read_input (args .input , stable_ids )
406
408
except Exception as e :
@@ -411,9 +413,7 @@ def main():
411
413
412
414
stable_output = dict (messages = [], modules = [])
413
415
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 )
417
417
418
418
if args .json_output is not None :
419
419
write_json (messages , modules , args .json_input , args .json_output , stable_output )
0 commit comments