From: Oleg Broytman Date: Sun, 14 Aug 2016 11:55:59 +0000 (+0300) Subject: Use token_list.flatten() to simplify tree traversing X-Git-Tag: 0.0.1~32 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=86cd5e14538aa1a7a39614c62163fb940459d90b;p=sqlconvert.git Use token_list.flatten() to simplify tree traversing --- 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):