Esempio n. 1
0
    def test_detokenize_base64_live(self):
        for data, expected in self.TEST_CASES:
            output = io.BytesIO()
            detokenize.detokenize_base64_live(self.detok, io.BytesIO(data),
                                              output, '$')

            self.assertEqual(expected, output.getvalue())
Esempio n. 2
0
def _detokenize_serial(databases: Iterable, device: serial.Serial,
                       baudrate: int, show_errors: bool, output: BinaryIO,
                       prefix: str) -> None:
    if output is sys.stdout:
        output = sys.stdout.buffer

    detokenizer = detokenize.Detokenizer(tokens.Database.merged(*databases),
                                         show_errors=show_errors)
    serial_device = serial.Serial(port=device, baudrate=baudrate)

    try:
        detokenize.detokenize_base64_live(detokenizer, serial_device, output,
                                          prefix)
    except KeyboardInterrupt:
        output.flush()