def __init__(self, seg):
        
        assert type(seg) == tuple, repr(seg)
        assert len(seg) in (2,3), repr(seg)
        
        self.sc, self.offs = seg[:2]
        
        assert type(self.sc) == int, repr(self.sc)
        
        if len(seg)==3:
            assert type(self.offs) == int, repr(self.offs)
            assert self.sc > 0, repr(seg)
            t = seg[2]
            if type(t) == bytes:
                self.text = t
                self.end = None
            else:
                assert type(t) == int, repr(t)
                self.text = None
                self.end = t
        else:
            assert len(seg) == 2, repr(seg)
            if self.offs is not None:
                assert self.sc >= 0, repr(seg)
                assert type(self.offs)==int
            self.text = self.end = None
Create object from line layout segment structure
dataset/ETHPy150Open AnyMesh/anyMesh-Python/example/urwid/text_layout.py/LayoutSegment.__init__