Module pythonConsole :: Class PythonConsole
[hide private]
[frames] | no frames]

Class PythonConsole

source code

code.InteractiveInterpreter --+    
                              |    
        code.InteractiveConsole --+
                                  |
                     object --+   |
                              |   |
  baseObject.AutoPropertyObject --+
                                  |
                                 PythonConsole

An interactive Python console for NVDA which directs output to supplied functions. This is necessary for a Python console with input/output other than stdin/stdout/stderr. Input is always received via the push method. This console handles redirection of stdout and stderr and prevents clobbering of the gettext "_" builtin. The console's namespace is populated with useful modules and can be updated with a snapshot of NVDA's state using updateNamespaceSnapshotVars.

Nested Classes [hide private]

Inherited from baseObject.AutoPropertyObject: __metaclass__

Instance Methods [hide private]
 
__init__(self, outputFunc, setPromptFunc, exitFunc, echoFunc=None, **kwargs)
Constructor.
source code
 
_set_prompt(self, prompt) source code
 
_get_prompt(self) source code
 
write(self, data)
Write a string.
source code
 
push(self, line)
Push a line to the interpreter.
source code
 
updateNamespaceSnapshotVars(self)
Update the console namespace with a snapshot of NVDA's current state.
source code
 
removeNamespaceSnapshotVars(self)
Remove the variables from the console namespace containing the last snapshot of NVDA's state.
source code

Inherited from code.InteractiveConsole: interact, raw_input, resetbuffer

Inherited from code.InteractiveInterpreter: runcode, runsource, showsyntaxerror, showtraceback

Inherited from baseObject.AutoPropertyObject: invalidateCache

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from baseObject.AutoPropertyObject: invalidateCaches

Class Variables [hide private]

Inherited from baseObject.AutoPropertyObject: cachePropertiesByDefault

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, outputFunc, setPromptFunc, exitFunc, echoFunc=None, **kwargs)
(Constructor)

source code 

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.

Overrides: object.__init__
(inherited documentation)

write(self, data)

source code 

Write a string.

The base implementation writes to sys.stderr; a subclass may replace this with a different implementation.

Overrides: code.InteractiveInterpreter.write
(inherited documentation)

push(self, line)

source code 

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()).

Overrides: code.InteractiveConsole.push
(inherited documentation)

updateNamespaceSnapshotVars(self)

source code 

Update the console namespace with a snapshot of NVDA's current state. This creates/updates variables for the current focus, navigator object, etc.

removeNamespaceSnapshotVars(self)

source code 

Remove the variables from the console namespace containing the last snapshot of NVDA's state. This removes the variables added by updateNamespaceSnapshotVars.