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

Method __call__

IPython/testing/ipunittest.py:70–104  ·  view source on GitHub ↗

Convert IPython prompts to python ones in a string.

(self, ds)

Source from the content-addressed store, hash-verified

68 self.rpyps2 = re.compile (r'(\s*%s)(.*)$' % self.pyps2)
69
70 def __call__(self, ds):
71 """Convert IPython prompts to python ones in a string."""
72 from . import globalipapp
73
74 pyps1 = '>>> '
75 pyps2 = '... '
76 pyout = ''
77
78 dnew = ds
79 dnew = self.rps1.sub(pyps1, dnew)
80 dnew = self.rps2.sub(pyps2, dnew)
81 dnew = self.rout.sub(pyout, dnew)
82 ip = InteractiveShell.instance()
83
84 # Convert input IPython source into valid Python.
85 out = []
86 newline = out.append
87 for line in dnew.splitlines():
88
89 mps1 = self.rpyps1.match(line)
90 if mps1 is not None:
91 prompt, text = mps1.groups()
92 newline(prompt+ip.prefilter(text, False))
93 continue
94
95 mps2 = self.rpyps2.match(line)
96 if mps2 is not None:
97 prompt, text = mps2.groups()
98 newline(prompt+ip.prefilter(text, True))
99 continue
100
101 newline(line)
102 newline('') # ensure a closing newline, needed by doctest
103 #print "PYSRC:", '\n'.join(out) # dbg
104 return '\n'.join(out)
105
106 #return dnew
107

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected