Skip to content

Commit

Permalink
bitfield parsing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpdx committed Oct 19, 2024
1 parent c3ddef4 commit fbe50fa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions oresat_configs/_yaml_to_od.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ def _parse_bit_definitions(obj: Union[IndexObject, SubindexObject]) -> dict[str,
elif isinstance(bits, list):
bit_defs[name] = list(sorted(bits))
elif isinstance(bits, str) and "-" in bits:
low, high = bits.split("-")
low, high = (low, high) if low < high else (high, low)
bit_defs[name] = list(range(int(low), int(high) + 1))
sorted_bit_defs_keys = sorted(bit_defs, key=lambda k: max(bit_defs.get(k)))
bits_ints = [int(i) for i in bits.split("-")]
bit_defs[name] = list(range(min(bits_ints), max(bits_ints) + 1))
sorted_bit_defs_keys = sorted(bit_defs, key=lambda k: max(bit_defs[k]))
return {key: bit_defs[key] for key in sorted_bit_defs_keys}


Expand Down

0 comments on commit fbe50fa

Please sign in to comment.