From e0d031a3913eb292b21d270f6a9351d34074f590 Mon Sep 17 00:00:00 2001 From: Rahix Date: Sat, 11 May 2019 20:34:51 +0200 Subject: [PATCH] svdpatch: Fix field modifications Signed-off-by: Rahix --- patch/svdpatch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/patch/svdpatch.py b/patch/svdpatch.py index 4e47ada..7fa5183 100644 --- a/patch/svdpatch.py +++ b/patch/svdpatch.py @@ -9,6 +9,7 @@ To be integrated into the build system, support for an input / output svd argume Additional changes: - Support for _replace_enum to overwrite existing + - Fix field modifications not being able to add new elements """ import copy @@ -221,7 +222,10 @@ def process_register_modify(rtag, fspec, fmod): for ftag in iter_fields(rtag, fspec): for (key, value) in fmod.items(): try: - ftag.find(key).text = str(value) + tag = ftag.find(key) + if tag is None: + tag = ET.SubElement(ftag, key) + tag.text = str(value) except AttributeError: raise SvdPatchError('invalid attribute {!r} for ' 'register {}, field {}' -- 2.48.1