class_docstr:     Records a sequence of strings (from a string buffer). These can then be
      compared to another sequence of strings, and if the two sequences don't
      match a mismatch exception is raised.
  
      Example:
         # Create a Record object and store 'hello world' inside it
         output = cStringIO.StringIO()
         recorder = Record(file_object=output, replay=False)
         recorder.handle_line('hello world 
  ')
  
         # Store the previous output
         output_value = output.getvalue()
         output = cStringIO.StringIO(output_value)
  
         # Create another Record object, now in playback mode, and set
         # it to the previous sequence of strings
         playback_checker = Record(file_object=output,  replay=True)
  
         # Check if it matches the previous one
         playback_checker.handle_line('hello world 
  ')
  
         # Now check if it the next item matches something else. This will
         # throw an exception because there is no next item
         playback_checker.handle_line('hello new world 
  ')
      
class_docstr_tok: ["Records","a","sequence","of","strings","(","from","a","string","buffer",")",".","These","can","then","be","compared","to","another","sequence","of","strings",",","and","if","the","two","sequences","don't","match","a","mismatch","exception","is","raised",".","Example",":","#","Create","a","Record","object","and","store","'hello","world","'","inside","it","output","=","cStringIO.StringIO","(",")","recorder","=","Record","(","file_object=output",",","replay=False",")","recorder.handle_line","(","'hello","world","'",")","#","Store","the","previous","output","output_value","=","output.getvalue","(",")","output","=","cStringIO.StringIO","(","output_value",")","#","Create","another","Record","object",",","now","in","playback","mode",",","and","set","#","it","to","the","previous","sequence","of","strings","playback_checker","=","Record","(","file_object=output",",","replay=True",")","#","Check","if","it","matches","the","previous","one","playback_checker.handle_line","(","'hello","world","'",")","#","Now","check","if","it","the","next","item","matches","something","else",".","This","will","#","throw","an","exception","because","there","is","no","next","item","playback_checker.handle_line","(","'hello","new","world","'",")"]
docstr: If not in playback mode, it records a new string. If in playback mode,
  it compares the current string to the next element in the sequence.
  If these are identical the element is removed and otherwise a mismatch
  exception is raised.
  
  Parameters
  ----------
  line : string
      The string to record.
docstr_tok: ["If","not","in","playback","mode",",","it","records","a","new","string",".","If","in","playback","mode",",","it","compares","the","current","string","to","the","next","element","in","the","sequence",".","If","these","are","identical","the","element","is","removed","and","otherwise","a","mismatch","exception","is","raised",".","Parameters","--","--","--","--","--","line",":","string","The","string","to","record","."]
code: def handle_line(self, line):
      """
      If not in playback mode, it records a new string. If in playback mode,
      it compares the current string to the next element in the sequence.
      If these are identical the element is removed and otherwise a mismatch
      exception is raised.
  
      Parameters
      ----------
      line : string
          The string to record.
      """
  
      assert line.endswith("\n")
      assert line[:-2].find("\n") == -1
      if self.replay:
          old_line = self.f.readline()
          if old_line != line:
              msg = "Replay detected mismatch.\n"
              msg += " I wanted to write:\n"
              if len(line) > 100:
                  msg += line[0:100] + "..."
              else:
                  msg += line
              msg += "\nwhen previous job wrote:\n"
              if len(old_line) > 100:
                  msg += old_line[0:100] + "..."
              else:
                  msg += old_line
              raise MismatchError(msg)
      else:
          self.f.write(line)
  
file_path: Theano/theano/tests/record.py
imports: from __future__ import absolute_import, print_function, division
  from theano.compile import Mode
  import theano
  from theano.printing import hex_digest
label_desc: Use image node_id 2 for calling the Record obj's underlying member method code with example usage: obj.handle_line(line) without return types