MCPcopy Create free account
hub / github.com/ipython/ipython / find

Method find

IPython/core/inputtransformer2.py:247–263  ·  view source on GitHub ↗

Find the first system assignment (a = !foo) in the cell.

(cls, tokens_by_line)

Source from the content-addressed store, hash-verified

245 """Transformer for assignments from system commands (a = !foo)"""
246 @classmethod
247 def find(cls, tokens_by_line):
248 """Find the first system assignment (a = !foo) in the cell.
249 """
250 for line in tokens_by_line:
251 assign_ix = _find_assign_op(line)
252 if (assign_ix is not None) \
253 and not line[assign_ix].line.strip().startswith('=') \
254 and (len(line) >= assign_ix + 2) \
255 and (line[assign_ix + 1].type == tokenize.ERRORTOKEN):
256 ix = assign_ix + 1
257
258 while ix < len(line) and line[ix].type == tokenize.ERRORTOKEN:
259 if line[ix].string == '!':
260 return cls(line[ix].start)
261 elif not line[ix].string.isspace():
262 break
263 ix += 1
264
265 def transform(self, lines: List[str]):
266 """Transform a system assignment found by the ``find()`` classmethod.

Callers

nothing calls this directly

Calls 1

_find_assign_opFunction · 0.85

Tested by

no test coverage detected