Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
InteractiveConsole Class Reference
Inheritance diagram for InteractiveConsole:
InteractiveInterpreter

Public Member Functions

def __init__
 
def resetbuffer
 
def interact
 
def push
 
def raw_input
 
- Public Member Functions inherited from InteractiveInterpreter
def __init__
 
def runsource
 
def runcode
 
def showsyntaxerror
 
def showtraceback
 
def write
 

Data Fields

 filename
 
 buffer
 
- Data Fields inherited from InteractiveInterpreter
 locals
 
 compile
 

Detailed Description

Closely emulate the behavior of the interactive Python interpreter.

This class builds on InteractiveInterpreter and adds prompting
using the familiar sys.ps1 and sys.ps2, and input buffering.

Definition at line 179 of file code.py.

Constructor & Destructor Documentation

def __init__ (   self,
  locals = None,
  filename = "<console>" 
)
Constructor.

The optional locals argument will be passed to the
InteractiveInterpreter base class.

The optional filename argument should specify the (file)name
of the input stream; it will show up in tracebacks.

Definition at line 187 of file code.py.

188  def __init__(self, locals=None, filename="<console>"):
189  """Constructor.
190 
191  The optional locals argument will be passed to the
192  InteractiveInterpreter base class.
193 
194  The optional filename argument should specify the (file)name
195  of the input stream; it will show up in tracebacks.
196 
197  """
198  InteractiveInterpreter.__init__(self, locals)
199  self.filename = filename
200  self.resetbuffer()

Member Function Documentation

def interact (   self,
  banner = None 
)
Closely emulate the interactive Python console.

The optional banner argument specify the banner to print
before the first interaction; by default it prints a banner
similar to the one printed by the real Python interpreter,
followed by the current class name in parentheses (so as not
to confuse this with the real interpreter -- since it's so
close!).

Definition at line 205 of file code.py.

References async_chat.push(), InteractiveConsole.push(), fifo.push(), InteractiveConsole.raw_input(), InteractiveConsole.resetbuffer(), locale.str(), Pickler.write, openrsrc.write(), _Hqxcoderengine.write(), _Rlecoderengine.write(), InteractiveInterpreter.write(), BinHex.write(), Marshaller.write, and file_wrapper.write.

206  def interact(self, banner=None):
207  """Closely emulate the interactive Python console.
208 
209  The optional banner argument specify the banner to print
210  before the first interaction; by default it prints a banner
211  similar to the one printed by the real Python interpreter,
212  followed by the current class name in parentheses (so as not
213  to confuse this with the real interpreter -- since it's so
214  close!).
215 
216  """
217  try:
218  sys.ps1
219  except AttributeError:
220  sys.ps1 = ">>> "
221  try:
222  sys.ps2
223  except AttributeError:
224  sys.ps2 = "... "
225  cprt = 'Type "copyright", "credits" or "license" for more information.'
226  if banner is None:
227  self.write("Python %s on %s\n%s\n(%s)\n" %
228  (sys.version, sys.platform, cprt,
229  self.__class__.__name__))
230  else:
231  self.write("%s\n" % str(banner))
232  more = 0
233  while 1:
234  try:
235  if more:
236  prompt = sys.ps2
237  else:
238  prompt = sys.ps1
239  try:
240  line = self.raw_input(prompt)
241  except EOFError:
242  self.write("\n")
243  break
244  else:
245  more = self.push(line)
246  except KeyboardInterrupt:
247  self.write("\nKeyboardInterrupt\n")
248  self.resetbuffer()
249  more = 0
def push (   self,
  line 
)
Push a line to the interpreter.

The line should not have a trailing newline; it may have
internal newlines.  The line is appended to a buffer and the
interpreter's runsource() method is called with the
concatenated contents of the buffer as source.  If this
indicates that the command was executed or invalid, the buffer
is reset; otherwise, the command is incomplete, and the buffer
is left as it was after the line was appended.  The return
value is 1 if more input is required, 0 if the line was dealt
with in some way (this is the same as runsource()).

Definition at line 250 of file code.py.

References InteractiveConsole.buffer, InteractiveConsole.filename, MiniFieldStorage.filename, FieldStorage.filename, dospath.join(), InteractiveConsole.resetbuffer(), and InteractiveInterpreter.runsource().

251  def push(self, line):
252  """Push a line to the interpreter.
253 
254  The line should not have a trailing newline; it may have
255  internal newlines. The line is appended to a buffer and the
256  interpreter's runsource() method is called with the
257  concatenated contents of the buffer as source. If this
258  indicates that the command was executed or invalid, the buffer
259  is reset; otherwise, the command is incomplete, and the buffer
260  is left as it was after the line was appended. The return
261  value is 1 if more input is required, 0 if the line was dealt
262  with in some way (this is the same as runsource()).
263 
264  """
265  self.buffer.append(line)
266  source = "\n".join(self.buffer)
267  more = self.runsource(source, self.filename)
268  if not more:
269  self.resetbuffer()
270  return more
def raw_input (   self,
  prompt = "" 
)
Write a prompt and read a line.

The returned line does not include the trailing newline.
When the user enters the EOF key sequence, EOFError is raised.

The base implementation uses the built-in function
raw_input(); a subclass may replace this with a different
implementation.

Definition at line 271 of file code.py.

272  def raw_input(self, prompt=""):
273  """Write a prompt and read a line.
274 
275  The returned line does not include the trailing newline.
276  When the user enters the EOF key sequence, EOFError is raised.
277 
278  The base implementation uses the built-in function
279  raw_input(); a subclass may replace this with a different
280  implementation.
281 
282  """
283  return raw_input(prompt)
284 
def resetbuffer (   self)
Reset the input buffer.

Definition at line 201 of file code.py.

202  def resetbuffer(self):
203  """Reset the input buffer."""
204  self.buffer = []

Field Documentation

buffer

Definition at line 203 of file code.py.

filename

Definition at line 198 of file code.py.


The documentation for this class was generated from the following file: