Exemplo n.º 1
0
    def test_parse(self):
        self.assertEquals(parse.parse('\x01y\x03print\x04'), yellow('print'))

        self.assertEquals(
            parse.parse('\x01y\x03print\x04\x01c\x03 \x04\x01g\x031\x04\x01c'
                        '\x03 \x04\x01Y\x03+\x04\x01c\x03 \x04\x01g\x032\x04'),
            yellow('print') + cyan(' ') + green('1') + cyan(' ') +
            bold(yellow('+')) + cyan(' ') + green(u'2'))
Exemplo n.º 2
0
    def test_parse(self):
        self.assertEqual(parse.parse('\x01y\x03print\x04'), yellow('print'))

        self.assertEqual(
            parse.parse('\x01y\x03print\x04\x01c\x03 \x04\x01g\x031\x04\x01c'
                        '\x03 \x04\x01Y\x03+\x04\x01c\x03 \x04\x01g\x032\x04'),
            yellow('print') + cyan(' ') + green('1') + cyan(' ') +
            bold(yellow('+')) + cyan(' ') + green(u'2'))
Exemplo n.º 3
0
    def test_parse(self):
        self.assertEqual(parse.parse("\x01y\x03print\x04"), yellow("print"))

        self.assertEqual(
            parse.parse("\x01y\x03print\x04\x01c\x03 \x04\x01g\x031\x04\x01c"
                        "\x03 \x04\x01Y\x03+\x04\x01c\x03 \x04\x01g\x032\x04"),
            yellow("print") + cyan(" ") + green("1") + cyan(" ") +
            bold(yellow("+")) + cyan(" ") + green("2"),
        )
Exemplo n.º 4
0
    def format(self, tokensource, outfile):
        o = ""

        for token, text in tokensource:
            while token not in self.f_strings:
                token = token.parent
            o += "{}\x03{}\x04".format(self.f_strings[token], text)
        outfile.write(parse(o.rstrip()))
Exemplo n.º 5
0
    def format(self, tokensource, outfile):
        o = ''

        for token, text in tokensource:
            while token not in self.f_strings:
                token = token.parent
            o += "%s\x03%s\x04" % (self.f_strings[token], text)
        outfile.write(parse(o.rstrip()))