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

Method push

IPython/core/inputtransformer.py:132–153  ·  view source on GitHub ↗
(self, line)

Source from the content-addressed store, hash-verified

130 self.tokenizer = generate_tokens(it.__next__)
131
132 def push(self, line):
133 self.buf.append(line + '\n')
134 if all(l.isspace() for l in self.buf):
135 return self.reset()
136
137 tokens = []
138 stop_at_NL = False
139 try:
140 for intok in self.tokenizer:
141 tokens.append(intok)
142 t = intok[0]
143 if t == tokenize.NEWLINE or (stop_at_NL and t == tokenize.NL):
144 # Stop before we try to pull a line we don't have yet
145 break
146 elif t == tokenize.ERRORTOKEN:
147 stop_at_NL = True
148 except TokenError:
149 # Multi-line statement - stop and try again with the next line
150 self.reset_tokenizer()
151 return None
152
153 return self.output(tokens)
154
155 def output(self, tokens):
156 self.buf.clear()

Callers

nothing calls this directly

Calls 3

resetMethod · 0.95
reset_tokenizerMethod · 0.95
outputMethod · 0.95

Tested by

no test coverage detected