Commit 9873bd3c authored by sagnowski's avatar sagnowski
Browse files

Improve parsing in isar_bstool.py

parent 4611624e
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -303,13 +303,13 @@ def _codec_from_bytes(bytes_: bytes) -> str:
    if x < len(CODECS):
        return CODECS[x]

    return "UNKNOWN"
    raise IsarBstoolError(f"Unknown codec value in ISAR file header: {x}")


def _codec_to_bytes(codec: str) -> bytes:
    # Refer to ISAR_SPLIT_REND_CODEC enum in C code
    CODECS = {"LCLD": 0, "LC3PLUS": 1, "DEFAULT": 2, "NONE": 3}
    return CODECS.get(codec, 255).to_bytes(4, byteorder="little")
    return CODECS[codec].to_bytes(4, byteorder="little")


def _pose_corr_from_bytes(bytes_: bytes) -> str:
@@ -320,13 +320,13 @@ def _pose_corr_from_bytes(bytes_: bytes) -> str:
    if x < len(POSE_CORR_MODES):
        return POSE_CORR_MODES[x]

    return "UNKNOWN"
    raise IsarBstoolError(f"Unknown pose correction value in ISAR file header: {x}")


def _pose_corr_to_bytes(pose_corr: str) -> bytes:
    # Refer to ISAR_SPLIT_REND_POSE_CORRECTION_MODE enum in C code
    POSE_CORR_MODES = {"NONE": 0, "CLDFB": 1}
    return POSE_CORR_MODES.get(pose_corr, 255).to_bytes(4, byteorder="little")
    return POSE_CORR_MODES[pose_corr].to_bytes(4, byteorder="little")


######################################################################################