def _repr_pretty_(self, p, cycle): if cycle: p.text(repr(self)) else: blend_mode = self.blend_mode if blend_mode is not None: blend_mode = BlendMode.name_of(blend_mode) sub_type = self.sub_type if sub_type is not None: sub_type = SectionDividerSub.name_of(sub_type) p.begin_group(2, "Divider(") p.begin_group(0) p.break_() p.text("type = %s," % SectionDivider.name_of(self.type)) p.break_() p.text("blend_mode = %s," % blend_mode) p.break_() p.text("sub_type = %s" % sub_type) p.end_group(2) p.break_() p.end_group(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)
def __repr__(self): blend_mode = self.blend_mode if blend_mode is not None: blend_mode = BlendMode.name_of(blend_mode) sub_type = self.sub_type if sub_type is not None: sub_type = SectionDividerSub.name_of(sub_type) return "Divider(type=%s, blend_mode=%s, sub_type=%s)" % ( SectionDivider.name_of(self.type), blend_mode, sub_type, )