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

Method find

IPython/core/inputtransformer2.py:370–383  ·  view source on GitHub ↗

Find the first escaped command (%foo, !foo, etc.) in the cell.

(cls, tokens_by_line)

Source from the content-addressed store, hash-verified

368 """Transformer for escaped commands like %foo, !foo, or /foo"""
369 @classmethod
370 def find(cls, tokens_by_line):
371 """Find the first escaped command (%foo, !foo, etc.) in the cell.
372 """
373 for line in tokens_by_line:
374 if not line:
375 continue
376 ix = 0
377 ll = len(line)
378 while ll > ix and line[ix].type in {tokenize.INDENT, tokenize.DEDENT}:
379 ix += 1
380 if ix >= ll:
381 continue
382 if line[ix].string in ESCAPE_SINGLES:
383 return cls(line[ix].start)
384
385 def transform(self, lines):
386 """Transform an escaped line found by the ``find()`` classmethod.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected