]> git.phdru.name Git - sqlconvert.git/commitdiff
Use ._pprint_tree() instead of print_subtree()
authorOleg Broytman <phd@phdru.name>
Fri, 29 Jul 2016 06:30:38 +0000 (09:30 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 29 Jul 2016 06:30:38 +0000 (09:30 +0300)
mysql2sql/print_tokens.py
scripts/print_subtree.py

index bfcaad9fca3097757a49a2c4c38037f7ab7c34ec..2024c67a948b5fa9c61ce8310f8e65160aea83d4 100644 (file)
@@ -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):
index d6c3f743810c601a9b7f796f544fc434f402fb54..84ea88a9e39a2d13e5aa8914b8fa18ae22696832 100755 (executable)
@@ -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: