Example #1
0
    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))
        metaline.channels = self.factory.realm.active_channels
        if not self.factory.use_blocks:
            if from_ga:
                metaline.line_end = "soft"
            else:
                metaline.line_end = "hard"
                metaline.wrap = True
            self.factory.realm.metalineReceived(metaline)
        else:
            if from_ga:
                # metaline.line_end = 'soft'
                # self.factory.realm.block=self.block_builder
                # metaline.wrap = True
                # for l in self.block_builder:
                #    self.factory.realm.metalineReceived(l)
                # self.factory.realm.metalineReceived(metaline)
                # self.block_builder=[]
                metaline.line_end = "soft"
                metaline.wrap = True
                self.block_builder.append(metaline)
                self.factory.realm.block = self.block_builder
                self.factory.realm.blockReceived(self.block_builder)
                self.block_builder = []

            else:
                metaline.line_end = "hard"
                metaline.wrap = True
                self.block_builder.append(metaline)
Example #2
0
 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)
Example #3
0
def test_removal_of_NUL():
    s = '\000foo\000bar'
    assert make_string_sane(s) == 'foobar'
Example #4
0
def test_FF_removal():
    s = 'foo\014bar'
    assert make_string_sane(s) == 'foobar'
Example #5
0
def test_VT_removal():
    s = 'foo\013\013bar'
    assert make_string_sane(s) == 'foobar'
Example #6
0
def test_HT_then_BS():
    s = 'foo\011\010bar'
    assert make_string_sane(s) == 'foobar'
Example #7
0
def test_HT_replacement():
    s = 'foo\011bar'
    assert make_string_sane(s) == 'foo    bar'
Example #8
0
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'
Example #9
0
def test_backspace_gone_too_far():
    s = 'foo\010\010\010\010'
    assert make_string_sane(s) == ''
Example #10
0
def test_backspace_handling_no_previous_characters_no_blow_up():
    s = '\010'
    assert make_string_sane(s) == ''
Example #11
0
def test_backspace_handling_multiple():
    s = 'foobaz\010\010\010bar'
    res = make_string_sane(s)
    print res
    assert res == 'foobar'
Example #12
0
def test_backspace_handling_normal():
    s = 'fooX\010'
    res = make_string_sane(s)
    print res
    assert res == 'foo'
Example #13
0
def test_removal_of_BEL():
    s = '\007James\007 Bond'
    assert make_string_sane(s) == 'James Bond'