def _handle_line(self, line, from_ga): """Clean the line, split out the colour codes, and feed it to the realm as a metaline. """ line = line.decode(self.factory.encoding) metaline = self._colourparser.parseline(make_string_sane(line)) if from_ga: metaline.line_end = 'soft' else: metaline.line_end = 'hard' metaline.wrap = True self.factory.realm.metalineReceived(metaline)
def test_FF_removal(): s = 'foo\014bar' assert make_string_sane(s) == 'foobar'
def test_removal_of_NUL(): s = '\000foo\000bar' assert make_string_sane(s) == 'foobar'
def test_HT_then_BS(): s = 'foo\011\010bar' assert make_string_sane(s) == 'foobar'
def test_VT_removal(): s = 'foo\013\013bar' assert make_string_sane(s) == 'foobar'
def test_backspace_no_interference(): #XXX um. Is this even right? s = 'fooX\000\010' res = make_string_sane(s) print res assert res == 'foo'
def test_HT_replacement(): s = 'foo\011bar' assert make_string_sane(s) == 'foo bar'
def test_backspace_gone_too_far(): s = 'foo\010\010\010\010' assert make_string_sane(s) == ''
def test_backspace_handling_no_previous_characters_no_blow_up(): s = '\010' assert make_string_sane(s) == ''
def test_backspace_handling_multiple(): s = 'foobaz\010\010\010bar' res = make_string_sane(s) print res assert res == 'foobar'
def test_backspace_handling_normal(): s = 'fooX\010' res = make_string_sane(s) print res assert res == 'foo'
def test_removal_of_BEL(): s = '\007James\007 Bond' assert make_string_sane(s) == 'James Bond'