From 86cd5e14538aa1a7a39614c62163fb940459d90b Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 14 Aug 2016 14:55:59 +0300 Subject: [PATCH] Use token_list.flatten() to simplify tree traversing --- mysql2sql/print_tokens.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mysql2sql/print_tokens.py b/mysql2sql/print_tokens.py index 5d104c3..2ed6341 100644 --- a/mysql2sql/print_tokens.py +++ b/mysql2sql/print_tokens.py @@ -7,15 +7,11 @@ except ImportError: from StringIO import StringIO except ImportError: from io import StringIO -from sqlparse.sql import TokenList -def print_tokens(token_list, outfile=sys.stdout, level=0): - for token in token_list: - if isinstance(token, TokenList): - print_tokens(token, outfile, level+1) - else: - outfile.write(token.normalized) +def print_tokens(token_list, outfile=sys.stdout): + for token in token_list.flatten(): + outfile.write(token.normalized) def get_tokens_str(token_list): -- 2.39.2