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

Method _process

sqlparse/filters/others.py:134–149  ·  view source on GitHub ↗
(tlist)

Source from the content-addressed store, hash-verified

132class SpacesAroundOperatorsFilter:
133 @staticmethod
134 def _process(tlist):
135
136 ttypes = (T.Operator, T.Comparison)
137 tidx, token = tlist.token_next_by(t=ttypes)
138 while token:
139 nidx, next_ = tlist.token_next(tidx, skip_ws=False)
140 if next_ and next_.ttype != T.Whitespace:
141 tlist.insert_after(tidx, sql.Token(T.Whitespace, ' '))
142
143 pidx, prev_ = tlist.token_prev(tidx, skip_ws=False)
144 if prev_ and prev_.ttype != T.Whitespace:
145 tlist.insert_before(tidx, sql.Token(T.Whitespace, ' '))
146 tidx += 1 # has to shift since token inserted before it
147
148 # assert tlist.token_index(token) == tidx
149 tidx, token = tlist.token_next_by(t=ttypes, idx=tidx)
150
151 def process(self, stmt):
152 [self.process(sgroup) for sgroup in stmt.get_sublists()]

Callers

nothing calls this directly

Calls 5

token_next_byMethod · 0.80
token_nextMethod · 0.80
insert_afterMethod · 0.80
token_prevMethod · 0.80
insert_beforeMethod · 0.80

Tested by

no test coverage detected