classes.py
: Refactor how raw_bytes
is constructed
This commit is contained in:
parent
d7a817b9ea
commit
5e52e5c71d
@ -336,18 +336,17 @@ class FumenHeader:
|
|||||||
@property
|
@property
|
||||||
def raw_bytes(self) -> bytes:
|
def raw_bytes(self) -> bytes:
|
||||||
"""Represent the header values as a string of raw bytes."""
|
"""Represent the header values as a string of raw bytes."""
|
||||||
value_list = []
|
format_string, value_list = '', []
|
||||||
format_string = self.order
|
|
||||||
for byte_field in fields(self):
|
for byte_field in fields(self):
|
||||||
value = getattr(self, byte_field.name)
|
value = getattr(self, byte_field.name)
|
||||||
if byte_field.name == "order":
|
if byte_field.name == "order":
|
||||||
pass
|
format_string = value + format_string
|
||||||
elif byte_field.name == "b000_b431_timing_windows":
|
elif byte_field.name == "b000_b431_timing_windows":
|
||||||
value_list.extend(list(value))
|
|
||||||
format_string += "f" * len(value)
|
format_string += "f" * len(value)
|
||||||
|
value_list.extend(list(value))
|
||||||
else:
|
else:
|
||||||
value_list.append(value)
|
|
||||||
format_string += "i"
|
format_string += "i"
|
||||||
|
value_list.append(value)
|
||||||
raw_bytes = struct.pack(format_string, *value_list)
|
raw_bytes = struct.pack(format_string, *value_list)
|
||||||
assert len(raw_bytes) == 520
|
assert len(raw_bytes) == 520
|
||||||
return raw_bytes
|
return raw_bytes
|
||||||
|
Loading…
Reference in New Issue
Block a user