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

Method transform

IPython/core/inputtransformer2.py:442–466  ·  view source on GitHub ↗

Transform a help command found by the ``find()`` classmethod.

(self, lines)

Source from the content-addressed store, hash-verified

440 return cls(line[ix].start, line[-2].start)
441
442 def transform(self, lines):
443 """Transform a help command found by the ``find()`` classmethod.
444 """
445 piece = ''.join(lines[self.start_line:self.q_line+1])
446 indent, content = piece[:self.start_col], piece[self.start_col:]
447 lines_before = lines[:self.start_line]
448 lines_after = lines[self.q_line + 1:]
449
450 m = _help_end_re.search(content)
451 if not m:
452 raise SyntaxError(content)
453 assert m is not None, content
454 target = m.group(1)
455 esc = m.group(3)
456
457 # If we're mid-command, put it back on the next prompt for the user.
458 next_input = None
459 if (not lines_before) and (not lines_after) \
460 and content.strip() != m.group(0):
461 next_input = content.rstrip('?\n')
462
463 call = _make_help_call(target, esc, next_input=next_input)
464 new_line = indent + call + '\n'
465
466 return lines_before + [new_line] + lines_after
467
468def make_tokens_by_line(lines:List[str]):
469 """Tokenize a series of lines and group tokens by line.

Callers 3

test_transform_helpFunction · 0.95
check_transformFunction · 0.45

Calls 3

groupMethod · 0.80
_make_help_callFunction · 0.70
searchMethod · 0.45

Tested by 2

test_transform_helpFunction · 0.76
check_transformFunction · 0.36