]> git.phdru.name Git - sqlconvert.git/commitdiff
Use token_list.flatten() to simplify tree traversing
authorOleg Broytman <phd@phdru.name>
Sun, 14 Aug 2016 11:55:59 +0000 (14:55 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 14 Aug 2016 11:55:59 +0000 (14:55 +0300)
mysql2sql/print_tokens.py

index 5d104c37d0d159e0f4f8e0fdeacc97dcd1523c82..2ed63412bfa77123038b1ea2e90c06e4353e6ad9 100644 (file)
@@ -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):