<s> from __future__ import unicode_literals <EOL> from codecs import getincrementaldecoder <EOL> import os <EOL> __all__ = ( <EOL> '<STR_LIT>' , <EOL> ) <EOL> class PosixStdinReader ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , stdin_fd , errors = '<STR_LIT:ignore>' ) : <EOL> assert isinstance ( stdin_fd , int ) <EOL> self . stdin_fd = stdin_fd <EOL> self . errors = errors <EOL> self . _stdin_decoder_cls = getincrementaldecoder ( '<STR_LIT:utf-8>' ) <EOL> self . _stdin_decoder = self . _stdin_decoder_cls ( errors = errors ) <EOL> self . closed = False <EOL> def read ( self , count = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> if self . closed : <EOL> return b'<STR_LIT>' <EOL> try : <EOL> data = os . read ( self . stdin_fd , count ) <EOL> if data == b'<STR_LIT>' : <EOL> self . closed = True <EOL> return '<STR_LIT>' <EOL> except OSError : <EOL> data = b'<STR_LIT>' <EOL> return self . _stdin_decoder . decode ( data ) </s>
