def __init__(self, stream):
        """
        Initialize an instance.

        @param stream: The underlying stream to be read. Should be seekable.
        @type stream: A stream (file-like object).
        """
        encoding = None
        signature = stream.read(4)
        used = -1
        if has_utf32:
            if signature == codecs.BOM_UTF32_LE:
                encoding = 'utf-32le'
            elif signature == codecs.BOM_UTF32_BE:
                encoding = 'utf-32be'
        if encoding is None:
            if signature[:3] == codecs.BOM_UTF8:
                used = 3
                encoding = 'utf-8'
            elif signature[:2] == codecs.BOM_UTF16_LE:
                used = 2
                encoding = 'utf-16le'
            elif signature[:2] == codecs.BOM_UTF16_BE:
                used = 2
                encoding = 'utf-16be'
            else:
                used = 0
        if used >= 0:
            stream.seek(used)
        if encoding:
            reader = codecs.getreader(encoding)
            stream = reader(stream)
        self.stream = stream
        self.encoding = encoding
dataset/ETHPy150Open twitterdev/twitter-for-bigquery/libs/config.py/ConfigInputStream.__init__/original