def __init__(self, fp, filename=None, *, spoiler=False):
    self.fp = fp
    if isinstance(fp, io.IOBase):
        if (not (fp.seekable() and fp.readable())):
            raise ValueError('File buffer {!r} must be seekable and readable'.format(fp))
        self.fp = fp
        self._original_pos = fp.tell()
        self._owner = False
    else:
        self.fp = open(fp, 'rb')
        self._original_pos = 0
        self._owner = True
    self._closer = self.fp.close
    self.fp.close = (lambda : None)
    if (filename is None):
        if isinstance(fp, str):
            (_, self.filename) = os.path.split(fp)
        else:
            self.filename = getattr(fp, 'name', None)
    else:
        self.filename = filename
    if (spoiler and (self.filename is not None) and (not self.filename.startswith('SPOILER_'))):
        self.filename = ('SPOILER_' + self.filename)
def __init__(self, fp, filename=None, *, spoiler=False):
    self.fp = fp
    if isinstance(fp, io.IOBase):
        if (not (fp.seekable() and fp.readable())):
            raise ValueError('File buffer {!r} must be seekable and readable'.format(fp))
        self.fp = fp
        self._original_pos = fp.tell()
        self._owner = False
    else:
        self.fp = open(fp, 'rb')
        self._original_pos = 0
        self._owner = True
    self._closer = self.fp.close
    self.fp.close = (lambda : None)
    if (filename is None):
        if isinstance(fp, str):
            (_, self.filename) = os.path.split(fp)
        else:
            self.filename = getattr(fp, 'name', None)
    else:
        self.filename = filename
    if (spoiler and (self.filename is not None) and (not self.filename.startswith('SPOILER_'))):
        self.filename = ('SPOILER_' + self.filename)