Exemplo n.º 1
0
def file(input_file: IO, out: Output) -> Iterator[Tuple[str, wl.Message]]:
    parse = True
    while True:
        try:
            line = input_file.readline()
        except KeyboardInterrupt:
            break
        if line == '':
            break
        line = line.strip()  # be sure to strip after the empty check
        try:
            conn_id, msg = message(line)
            if parse:
                yield conn_id, msg
        except RuntimeError as e:
            out.unprocessed(str(e))
        except:
            import traceback
            out.show(traceback.format_exc())
            parse = False
Exemplo n.º 2
0
 def test_no_unprocessed_if_disabled(self):
     o = Output(True, False, self.out, self.err)
     o.unprocessed('abc')
     self.assertEqual(self.out.buffer, '')
     self.assertEqual(self.err.buffer, '')
Exemplo n.º 3
0
 def test_unprocessed(self):
     o = Output(True, True, self.out, self.err)
     o.unprocessed('abc')
     self.assertIn('abc', self.out.buffer)
     self.assertEqual(self.err.buffer, '')