From d496685f33ccc91abbdfcad82c89ea21b26eb186 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 3 Jul 2024 12:21:00 +1000 Subject: [PATCH] DFReader.py: emit enumeration value name when verbose-dumping --- DFReader.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/DFReader.py b/DFReader.py index e8870cf62..4f8f50711 100644 --- a/DFReader.py +++ b/DFReader.py @@ -383,6 +383,20 @@ def dump_verbose(self, f): except UnicodeDecodeError: f.write(" %s: %s" % (c, to_string(val))) + # see if this is an enumeration entry, emit enumeration + # entry name if it is + if c in field_metadata_by_name: + fm = field_metadata_by_name[c] + fm_enum = getattr(fm, "enum", None) + if fm_enum is not None: + enum_entry_name = "?????" # default, "not found" value + for entry in fm_enum.iterchildren(): + if int(entry.value) == int(val): + enum_entry_name = entry.get('name') + break + + f.write(f" ({enum_entry_name})") + # Append the unit to the output unit = self.fmt.get_unit(c) if unit.startswith("rad"):