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

Method transform

IPython/core/inputtransformer2.py:226–241  ·  view source on GitHub ↗

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

(self, lines: List[str])

Source from the content-addressed store, hash-verified

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.
228 """
229 start_line, start_col = self.start_line, self.start_col
230 lhs = lines[start_line][:start_col]
231 end_line = find_end_of_continued_line(lines, start_line)
232 rhs = assemble_continued_line(lines, (start_line, start_col), end_line)
233 assert rhs.startswith('%'), rhs
234 magic_name, _, args = rhs[1:].partition(' ')
235
236 lines_before = lines[:start_line]
237 call = "get_ipython().run_line_magic({!r}, {!r})".format(magic_name, args)
238 new_line = lhs + call + '\n'
239 lines_after = lines[end_line+1:]
240
241 return lines_before + [new_line] + lines_after
242
243
244class SystemAssign(TokenTransformBase):

Callers

nothing calls this directly

Calls 3

assemble_continued_lineFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected