Skip to content

Commit

Permalink
DFReader.py: emit enumeration value name when verbose-dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Jul 3, 2024
1 parent 5bfad6c commit b287f4f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DFReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit b287f4f

Please sign in to comment.