MCPcopy
hub / github.com/andialbrecht/sqlparse / imt

Function imt

sqlparse/utils.py:81–105  ·  view source on GitHub ↗

Helper function to simplify comparisons Instance, Match and TokenType :param token: :param i: Class or Tuple/List of Classes :param m: Tuple of TokenType & Value. Can be list of Tuple for multiple :param t: TokenType or Tuple/List of TokenTypes :return: bool

(token, i=None, m=None, t=None)

Source from the content-addressed store, hash-verified

79
80
81def imt(token, i=None, m=None, t=None):
82 """Helper function to simplify comparisons Instance, Match and TokenType
83 :param token:
84 :param i: Class or Tuple/List of Classes
85 :param m: Tuple of TokenType & Value. Can be list of Tuple for multiple
86 :param t: TokenType or Tuple/List of TokenTypes
87 :return: bool
88 """
89 if token is None:
90 return False
91 if i and isinstance(token, i):
92 return True
93 if m:
94 if isinstance(m, list):
95 if any(token.match(*pattern) for pattern in m):
96 return True
97 elif token.match(*m):
98 return True
99 if t:
100 if isinstance(t, list):
101 if any(token.ttype in ttype for ttype in t):
102 return True
103 elif token.ttype in t:
104 return True
105 return False
106
107
108def consume(iterator, n):

Callers 11

matcherMethod · 0.90
token_next_byMethod · 0.90
get_parametersMethod · 0.90
matchFunction · 0.90
valid_prevFunction · 0.90
postFunction · 0.90
valid_nextFunction · 0.90
validFunction · 0.90
group_overFunction · 0.90
group_commentsFunction · 0.90
group_orderFunction · 0.90

Calls 1

matchMethod · 0.80

Tested by

no test coverage detected