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

Method find

IPython/core/inputtransformer2.py:215–224  ·  view source on GitHub ↗

Find the first magic assignment (a = %foo) in the cell.

(cls, tokens_by_line)

Source from the content-addressed store, hash-verified

213 """Transformer for assignments from magics (a = %foo)"""
214 @classmethod
215 def find(cls, tokens_by_line):
216 """Find the first magic assignment (a = %foo) in the cell.
217 """
218 for line in tokens_by_line:
219 assign_ix = _find_assign_op(line)
220 if (assign_ix is not None) \
221 and (len(line) >= assign_ix + 2) \
222 and (line[assign_ix+1].string == '%') \
223 and (line[assign_ix+2].type == tokenize.NAME):
224 return cls(line[assign_ix+1].start)
225
226 def transform(self, lines: List[str]):
227 """Transform a magic assignment found by the ``find()`` classmethod.

Callers

nothing calls this directly

Calls 1

_find_assign_opFunction · 0.85

Tested by

no test coverage detected