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

Method transform

IPython/core/inputtransformer2.py:265–281  ·  view source on GitHub ↗

Transform a system assignment found by the ``find()`` classmethod.

(self, lines: List[str])

Source from the content-addressed store, hash-verified

263 ix += 1
264
265 def transform(self, lines: List[str]):
266 """Transform a system assignment found by the ``find()`` classmethod.
267 """
268 start_line, start_col = self.start_line, self.start_col
269
270 lhs = lines[start_line][:start_col]
271 end_line = find_end_of_continued_line(lines, start_line)
272 rhs = assemble_continued_line(lines, (start_line, start_col), end_line)
273 assert rhs.startswith('!'), rhs
274 cmd = rhs[1:]
275
276 lines_before = lines[:start_line]
277 call = "get_ipython().getoutput({!r})".format(cmd)
278 new_line = lhs + call + '\n'
279 lines_after = lines[end_line + 1:]
280
281 return lines_before + [new_line] + lines_after
282
283# The escape sequences that define the syntax transformations IPython will
284# apply to user input. These can NOT be just changed here: many regular

Callers

nothing calls this directly

Calls 3

assemble_continued_lineFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected