How to use the pglast.printer.NODE_PRINTERS.pop function in pglast

To help you get started, we’ve selected a few pglast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lelit / pglast / tests / test_printer.py View on Github external
result = output(root)
        assert result == """\
bar = a({x0, y0}
      * {x1,{x2, y2} / {x3,{x4, y4} / {x5, y5}}})"""

        output = printer.IndentedStream()
        output.test_child_z_is_expression = False
        output.test_child_z_list_sep = '//'
        result = output(root)
        assert result == """\
bar = a({x0, y0}
      * {x1,   {x2, y2}
            // {x3,   {x4, y4}
                   // {x5, y5}}})"""
    finally:
        printer.NODE_PRINTERS.pop('TestRoot', None)
        printer.NODE_PRINTERS.pop('TestChild', None)
        printer.NODE_PRINTERS.pop('TestNiece', None)
github lelit / pglast / tests / test_printer.py View on Github external
assert result == """\
bar = a({x0, y0}
      * {x1,{x2, y2} / {x3,{x4, y4} / {x5, y5}}})"""

        output = printer.IndentedStream()
        output.test_child_z_is_expression = False
        output.test_child_z_list_sep = '//'
        result = output(root)
        assert result == """\
bar = a({x0, y0}
      * {x1,   {x2, y2}
            // {x3,   {x4, y4}
                   // {x5, y5}}})"""
    finally:
        printer.NODE_PRINTERS.pop('TestRoot', None)
        printer.NODE_PRINTERS.pop('TestChild', None)
        printer.NODE_PRINTERS.pop('TestNiece', None)
github lelit / pglast / tests / test_printer.py View on Github external
else:
                    output.print_list(node.z, '/', standalone_items=False)
            output.write('}')

        output = printer.RawStream()
        output.test_child_z_is_expression = True
        result = output(root)
        assert result == 'bar = a({x0, y0} * {x1,{x2, y2} + {x3,{x4, y4} + {x5, y5}}})'

        output = printer.RawStream()
        output.test_child_z_is_expression = False
        result = output(root)
        assert result == 'bar = a({x0, y0} * {x1,{x2, y2} / {x3,{x4, y4} / {x5, y5}}})'
    finally:
        printer.NODE_PRINTERS.pop('TestRoot', None)
        printer.NODE_PRINTERS.pop('TestChild', None)
        printer.NODE_PRINTERS.pop('TestNiece', None)
github lelit / pglast / tests / test_printer.py View on Github external
        @printer.node_printer('RawStmt')
        def raw_stmt(node, output):
            output.write('Yeah')

        output = printer.IndentedStream()
        result = output('SELECT 1; SELECT 2')
        assert result == 'Yeah;\n\nYeah'

        output = printer.IndentedStream(separate_statements=False)
        result = output('SELECT 1; SELECT 2')
        assert result == 'Yeah;\nYeah'
    finally:
        if raw_stmt_printer is not None:
            printer.NODE_PRINTERS['RawStmt'] = raw_stmt_printer
        else:
            printer.NODE_PRINTERS.pop('RawStmt', None)
github lelit / pglast / tests / test_printer.py View on Github external
def test_raw_stream_with_sql():
    raw_stmt_printer = printer.NODE_PRINTERS.pop('RawStmt', None)
    try:
        @printer.node_printer('RawStmt')
        def raw_stmt(node, output):
            output.write('Yeah')

        output = printer.RawStream()
        result = output('SELECT 1; SELECT 2')
        assert result == 'Yeah; Yeah'
    finally:
        if raw_stmt_printer is not None:
            printer.NODE_PRINTERS['RawStmt'] = raw_stmt_printer
        else:
            printer.NODE_PRINTERS.pop('RawStmt', None)
github lelit / pglast / tests / test_printer.py View on Github external
def test_separate_statements():
    """Separate statements by ``separate_statements`` (int) newlines."""
    raw_stmt_printer = printer.NODE_PRINTERS.pop('RawStmt', None)
    try:
        @printer.node_printer('RawStmt')
        def raw_stmt(node, output):
            output.write('Yeah')

        output = printer.IndentedStream(separate_statements=2)
        result = output('SELECT 1; SELECT 2')
        assert result == 'Yeah;\n\n\nYeah'
    finally:
        if raw_stmt_printer is not None:
            printer.NODE_PRINTERS['RawStmt'] = raw_stmt_printer
        else:
            printer.NODE_PRINTERS.pop('RawStmt', None)
github lelit / pglast / tests / test_printer.py View on Github external
output.print_list(node.z, '/', standalone_items=False)
            output.write('}')

        output = printer.RawStream()
        output.test_child_z_is_expression = True
        result = output(root)
        assert result == 'bar = a({x0, y0} * {x1,{x2, y2} + {x3,{x4, y4} + {x5, y5}}})'

        output = printer.RawStream()
        output.test_child_z_is_expression = False
        result = output(root)
        assert result == 'bar = a({x0, y0} * {x1,{x2, y2} / {x3,{x4, y4} / {x5, y5}}})'
    finally:
        printer.NODE_PRINTERS.pop('TestRoot', None)
        printer.NODE_PRINTERS.pop('TestChild', None)
        printer.NODE_PRINTERS.pop('TestNiece', None)
github lelit / pglast / tests / test_printer.py View on Github external
def test_indented_stream_with_sql():
    raw_stmt_printer = printer.NODE_PRINTERS.pop('RawStmt', None)
    try:
        @printer.node_printer('RawStmt')
        def raw_stmt(node, output):
            output.write('Yeah')

        output = printer.IndentedStream()
        result = output('SELECT 1; SELECT 2')
        assert result == 'Yeah;\n\nYeah'

        output = printer.IndentedStream(separate_statements=False)
        result = output('SELECT 1; SELECT 2')
        assert result == 'Yeah;\nYeah'
    finally:
        if raw_stmt_printer is not None:
            printer.NODE_PRINTERS['RawStmt'] = raw_stmt_printer
        else:
github lelit / pglast / tests / test_printer.py View on Github external
output.print_list(node.z, '+')
                else:
                    output.print_list(node.z, '/', standalone_items=False)
            output.write('}')

        output = printer.RawStream()
        output.test_child_z_is_expression = True
        result = output(root)
        assert result == 'bar = a({x0, y0} * {x1,{x2, y2} + {x3,{x4, y4} + {x5, y5}}})'

        output = printer.RawStream()
        output.test_child_z_is_expression = False
        result = output(root)
        assert result == 'bar = a({x0, y0} * {x1,{x2, y2} / {x3,{x4, y4} / {x5, y5}}})'
    finally:
        printer.NODE_PRINTERS.pop('TestRoot', None)
        printer.NODE_PRINTERS.pop('TestChild', None)
        printer.NODE_PRINTERS.pop('TestNiece', None)
github lelit / pglast / tests / test_printer.py View on Github external
def test_raw_stream_with_sql():
    raw_stmt_printer = printer.NODE_PRINTERS.pop('RawStmt', None)
    try:
        @printer.node_printer('RawStmt')
        def raw_stmt(node, output):
            output.write('Yeah')

        output = printer.RawStream()
        result = output('SELECT 1; SELECT 2')
        assert result == 'Yeah; Yeah'
    finally:
        if raw_stmt_printer is not None:
            printer.NODE_PRINTERS['RawStmt'] = raw_stmt_printer
        else:
            printer.NODE_PRINTERS.pop('RawStmt', None)