]> git.phdru.name Git - sqlconvert.git/blobdiff - mysql2sql/process_tokens.py
Exclude ez_setup.py from flake8 testing
[sqlconvert.git] / mysql2sql / process_tokens.py
index 70dadb23bf6080b7764154e8ef3356763e552e37..ac9930eb81963b1e0c376ff67af035aaaca37679 100644 (file)
@@ -1,14 +1,12 @@
 
 from sqlparse.sql import TokenList
-from sqlparse.tokens import Name
+from sqlparse.tokens import Name, Error
 
 
 def requote_names(token_list):
     """Remove backticks, quote non-lowercase identifiers"""
-    for token in token_list:
-        if isinstance(token, TokenList):
-            requote_names(token)
-        elif token.ttype is Name:
+    for token in token_list.flatten():
+        if token.ttype is Name:
             value = token.value
             if (value[0] == "`") and (value[-1] == "`"):
                 value = value[1:-1]
@@ -16,3 +14,11 @@ def requote_names(token_list):
                 token.normalized = token.value = value
             else:
                 token.normalized = token.value = '"%s"' % value
+
+
+def find_error(token_list):
+    """Find an error"""
+    for token in token_list.flatten():
+        if token.ttype is Error:
+            return True
+    return False