From 3f72ae846b3948ffd4b15416c8e84439d015424c Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 29 Jul 2016 09:30:38 +0300 Subject: [PATCH] Use ._pprint_tree() instead of print_subtree() --- mysql2sql/print_tokens.py | 9 --------- scripts/print_subtree.py | 6 +++--- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/mysql2sql/print_tokens.py b/mysql2sql/print_tokens.py index bfcaad9..2024c67 100644 --- a/mysql2sql/print_tokens.py +++ b/mysql2sql/print_tokens.py @@ -10,15 +10,6 @@ except ImportError: from sqlparse.sql import TokenList -def print_subtree(token_list, outfile=sys.stdout, ident=0): - for token in token_list: - outfile.write(" "*ident) - outfile.write(repr(token)) - outfile.write("\n") - if isinstance(token, TokenList): - print_subtree(token, outfile, ident+4) - - def print_tokens(token_list, outfile=sys.stdout, level=0): for token in token_list: if not isinstance(token, TokenList): diff --git a/scripts/print_subtree.py b/scripts/print_subtree.py index d6c3f74..84ea88a 100755 --- a/scripts/print_subtree.py +++ b/scripts/print_subtree.py @@ -4,7 +4,7 @@ from __future__ import print_function import sys from sqlparse import parse from mysql2sql.process_tokens import requote_names -from mysql2sql.print_tokens import print_tokens, print_subtree +from mysql2sql.print_tokens import print_tokens def test(): @@ -18,7 +18,7 @@ def test(): for parsed in parse(query): requote_names(parsed) print_tokens(parsed) - print_subtree(parsed) + parsed._pprint_tree() print("----------") @@ -26,7 +26,7 @@ def main(query): parsed = parse(query)[0] requote_names(parsed) print_tokens(parsed) - print_subtree(parsed) + parsed._pprint_tree() if __name__ == '__main__': if len(sys.argv) != 2: -- 2.39.5