def test_indented(self):
        sw = StringWriter()
        i = Indentable()

        write(i, sw, 'aaa')
        i.indent()
        new_line(i, sw, 'bbb')
        new_line(i, sw, 'bbb')
        i.indent()
        new_line(i, sw, 'ccc')
        new_line(i, sw, 'ccc')
        i.outdent()
        new_line(i, sw, 'bbb')
        new_line(i, sw, 'bbb')
        i.outdent()
        new_line(i, sw, 'aaa')

        ex = StringWriter()
        ex.write('aaa\n')
        ex.write('  bbb\n')
        ex.write('  bbb\n')
        ex.write('    ccc\n')
        ex.write('    ccc\n')
        ex.write('  bbb\n')
        ex.write('  bbb\n')
        ex.write('aaa')

        self.assertEqual(ex.__str__(), sw.__str__())
Exemple #2
0
def myWidgetB(assembly, model, ctx, **kw):
    def write(msg): assembly.write(msg)
    def indent(): assembly.indent()
    def outdent(): assembly.outdent()
    
    write('Widget D\n')
    indent()
    write('Attr1: %s\n' % model.attr1())
    write('Attr2: %s\n' % model.attr2())
    outdent()
    write('End widget D\n')
    if not kw.get('last'):
        write(',\n')
def bbb(assembly, model, ctx, **kw):
    def write(msg):
        assembly.write(msg)

    def indent():
        assembly.indent()

    def outdent():
        assembly.outdent()

    write('bbb\n')
    write('bbb\n')
    write('bbb\n')
    if not kw.get('last'):
        write(',\n')
    def test_write(self):
        sw = StringWriter()
        i = Indentable()
        write(i, sw, 'aaa')

        self.assertEqual('aaa', sw.__str__())

        write(i, sw, 'bbb')
        self.assertEqual('aaabbb', sw.__str__())

        write(i, sw, 'ccc', 'ddd')
        self.assertEqual('aaabbbcccddd', sw.__str__())
def myWidgetB(assembly, model, ctx, **kw):
    def write(msg):
        assembly.write(msg)

    def container(cont):
        ctx.wite_container(assembly, model, cont)

    def indent():
        assembly.indent()

    def outdent():
        assembly.outdent()

    write('Widget F\n')
    write('Attr1: %s\n' % (model.attr1() if model.attr1() != None else ''))
    write('Attr2: %s\n' % (model.attr2() if model.attr2() != None else ''))
    write('Container A [\n')
    indent()
    container('A')
    outdent()
    write('] Container A\n')
    write('Container B [\n')
    indent()
    container('B')
    outdent()
    write('] Container B\n')
    write('End widget F\n')
Exemple #6
0
def myWidgetB(assembly, model, ctx, **kw):
    def write(msg):
        assembly.write(msg)

    def indent():
        assembly.indent()

    def outdent():
        assembly.outdent()

    write('AAA\n')
    indent()
    write('BBB\n')
    write('BBB\n')
    indent()
    write('CCC\n')
    write('CCC\n')
    outdent()
    write('BBB\n')
    write('BBB\n')
    outdent()
    write('AAA\n')
    if not kw.get('last'):
        write(',\n')
Exemple #7
0
def myWidgetA(assembly, model, ctx, **kw):
    def write(msg):
        assembly.write(msg)

    def indent():
        assembly.indent()

    def outdent():
        assembly.outdent()

    write('aaa\n')
    indent()
    write('bbb\n')
    write('bbb\n')
    indent()
    write('ccc\n')
    write('ccc\n')
    outdent()
    write('bbb\n')
    write('bbb\n')
    outdent()
    write('aaa\n')
    if not kw.get('last'):
        write(',\n')