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

Function leading_indent

IPython/core/inputtransformer.py:476–500  ·  view source on GitHub ↗

Remove leading indentation. If the first line starts with a spaces or tabs, the same whitespace will be removed from each following line until it is reset.

()

Source from the content-addressed store, hash-verified

474
475@CoroutineInputTransformer.wrap
476def leading_indent():
477 """Remove leading indentation.
478
479 If the first line starts with a spaces or tabs, the same whitespace will be
480 removed from each following line until it is reset.
481 """
482 space_re = re.compile(r'^[ \t]+')
483 line = ''
484 while True:
485 line = (yield line)
486
487 if line is None:
488 continue
489
490 m = space_re.match(line)
491 if m:
492 space = m.group(0)
493 while line is not None:
494 if line.startswith(space):
495 line = line[len(space):]
496 line = (yield line)
497 else:
498 # No leading spaces - wait for reset
499 while line is not None:
500 line = (yield line)
501
502
503_assign_pat = \

Callers 1

__init__Method · 0.90

Calls 1

groupMethod · 0.80

Tested by

no test coverage detected