'Raises error, IOError, EOFError'

def __init__(self, fileobj=None):

    self.packets = []
    if (fileobj is None):
        return
    self.offset = fileobj.tell()
    header = fileobj.read(27)
    if (len(header) == 0):
        raise EOFError
    try:
        (oggs, self.version, self.__type_flags, self.position, self.serial, self.sequence, crc, segments) = struct.unpack('<4sBBqIIiB', header)
    except struct.error:
        raise error(('unable    to    read    full    header;    got    %r' % header))
    if (oggs != 'OggS'):
        raise error(('read    %r,    expected    %r,    at    0x%x' % (oggs, 'OggS', (fileobj.tell() - 27))))
    if (self.version != 0):
        raise error(('version    %r    unsupported' % self.version))
    total = 0
    lacings = []
    lacing_bytes = fileobj.read(segments)
    if (len(lacing_bytes) != segments):
        raise error(('unable    to    read    %r    lacing    bytes' % segments))
    for c in bytearray(lacing_bytes):
        total += c
        if (c < 255):
            lacings.append(total)
            total = 0
    if total:
        lacings.append(total)
        self.complete = False
    self.packets = [fileobj.read(l) for l in lacings]
    if ([len(p) for p in self.packets] != lacings):
        raise error('unable    to    read    full    data')
