From c38f021d7cd8edb3316b8b4f4b80838896fe17c4 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Sat, 26 Mar 2022 10:41:11 +0800 Subject: [PATCH] Handle the case where there's no array field in block template dictionary. --- register_printer/data_model/block_template.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/register_printer/data_model/block_template.py b/register_printer/data_model/block_template.py index f356a8a..bf8ef8b 100644 --- a/register_printer/data_model/block_template.py +++ b/register_printer/data_model/block_template.py @@ -32,9 +32,10 @@ def generate_block_template(block_template_dict): ) register.add_field(field) block_template.add_register(register) - for array_dict in block_template_dict["arrays"]: - array = ArrayTemplate.from_dict(array_dict) - block_template.add_array(array) + if "arrays" in block_template_dict: + for array_dict in block_template_dict["arrays"]: + array = ArrayTemplate.from_dict(array_dict) + block_template.add_array(array) return block_template