]> git.phdru.name Git - sqlconvert.git/blobdiff - mysql2sql/print_tokens.py
Use token_list.flatten() to simplify tree traversing
[sqlconvert.git] / mysql2sql / print_tokens.py
index 2024c67a948b5fa9c61ce8310f8e65160aea83d4..2ed63412bfa77123038b1ea2e90c06e4353e6ad9 100644 (file)
@@ -7,17 +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 not isinstance(token, TokenList):
-            outfile.write(token.normalized)
-        if isinstance(token, TokenList):
-            print_tokens(token, outfile, level+1)
-    if level == 0:
-        outfile.write(';\n')
+def print_tokens(token_list, outfile=sys.stdout):
+    for token in token_list.flatten():
+        outfile.write(token.normalized)
 
 
 def get_tokens_str(token_list):