Esempio n. 1
0
def _decode_section_divider(data):
    data_length = len(data)
    blend_mode = None
    sub_type = None

    fp = io.BytesIO(data)
    tp = read_fmt("I", fp)[0]
    if not SectionDivider.is_known(tp):
        warnings.warn("Unknown section divider type (%s)" % tp)

    if data_length >= 12:
        sig = fp.read(4)
        if sig != b"8BIM":
            raise Error("Invalid signature in section divider block (%r)" % sig)

        blend_mode = fp.read(4)
        if not BlendMode.is_known(blend_mode):
            warnings.warn("Unknown section divider blend mode (%s)" % blend_mode)

        if data_length >= 16:
            sub_type = read_fmt("I", fp)[0]
            if not SectionDividerSub.is_known(sub_type):
                warnings.warn("Unknown section divider sub-type (%s)" % sub_type)

    return Divider(tp, blend_mode, sub_type)