<s> """<STR_LIT>""" <EOL> import sys <EOL> class FakeDevice ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . data = b'<STR_LIT>' <EOL> def write ( self , data ) : <EOL> """<STR_LIT>""" <EOL> self . data = data <EOL> class FakeReadDevice ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , data , silent_on_empty = False ) : <EOL> self . data = data <EOL> self . read_index = <NUM_LIT:0> <EOL> self . silent_on_empty = silent_on_empty <EOL> def read ( self , length = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> if self . read_index + length > len ( self . data ) : <EOL> if self . silent_on_empty : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> read_data = self . data [ self . read_index : self . read_index + length ] <EOL> self . read_index += length <EOL> return read_data <EOL> def inWaiting ( self ) : <EOL> """<STR_LIT>""" <EOL> return len ( self . data ) - self . read_index </s>
