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

Method token_first

sqlparse/sql.py:249–262  ·  view source on GitHub ↗

Returns the first child token. If *skip_ws* is ``True`` (the default), whitespace tokens are ignored. if *skip_cm* is ``True`` (default: ``False``), comments are ignored too.

(self, skip_ws=True, skip_cm=False)

Source from the content-addressed store, hash-verified

247 return None, None
248
249 def token_first(self, skip_ws=True, skip_cm=False):
250 """Returns the first child token.
251
252 If *skip_ws* is ``True`` (the default), whitespace
253 tokens are ignored.
254
255 if *skip_cm* is ``True`` (default: ``False``), comments are
256 ignored too.
257 """
258 # this on is inconsistent, using Comment instead of T.Comment...
259 def matcher(tk):
260 return not ((skip_ws and tk.is_whitespace)
261 or (skip_cm and imt(tk, t=T.Comment, i=Comment)))
262 return self._token_matching(matcher)[1]
263
264 def token_next_by(self, i=None, m=None, t=None, idx=-1, end=None):
265 idx += 1

Callers 3

test_tokenlist_firstFunction · 0.80
test_issue34Function · 0.80
get_typeMethod · 0.80

Calls 1

_token_matchingMethod · 0.95

Tested by 2

test_tokenlist_firstFunction · 0.64
test_issue34Function · 0.64