eric4.Scripting.ScriptManager

Module implementing the scripting component of the eric4 IDE.

Classes

CompilationError Class implementing an exception, which is raised, if a script couldn't be compiled.
ExecutionError Class implementing an exception, which is raised, if a script couldn't be executed.
NoSuchScriptError Class implementing an exception, which is raised, if a script couldn't be found.
ScriptAction Class implementing the script action.
ScriptError Base class for all scripting related exceptions.
ScriptManager Class implementing the script manager.

Functions

None


CompilationError

Class implementing an exception, which is raised, if a script couldn't be compiled.

Derived from

ScriptError

Methods

CompilationError Constructor

CompilationError (Constructor)

CompilationError(error)

Constructor

Up


ExecutionError

Class implementing an exception, which is raised, if a script couldn't be executed.

Derived from

ScriptError

Methods

ExecutionError Constructor

ExecutionError (Constructor)

ExecutionError(error)

Constructor

Up


NoSuchScriptError

Class implementing an exception, which is raised, if a script couldn't be found.

Derived from

ScriptError

Methods

NoSuchScriptError Constructor

NoSuchScriptError (Constructor)

NoSuchScriptError(script)

Constructor

Up


ScriptAction

Class implementing the script action.

This class is subclassed from QAction to have the possibility to attach it to menus and toolbars.

Raises CompilationError:
raised, if script compilation fails
Raises ExecutionError:
raised, if script execution failed

Signals

executeScript
signal emitted when this script action is triggered

Derived from

QAction

Methods

ScriptAction Constructor
__compile Private method to compile the code string.
__triggered Private method connected to the QAction triggered signal.
addTo Public method to add this action to a widget.
execute Public method to execute this script.
remove Public method to remove this action.
removeFrom Public method to remove this action from a widget.

ScriptAction (Constructor)

ScriptAction(code, *args)

Constructor

code
the script code (string or QString)
*args
arguments passed on to QAction

ScriptAction.__compile

__compile(code)

Private method to compile the code string.

code
string containing the code (string)
Returns:
the compiled bytecode as a string
Raises CompilationError:
raised, if compilation fails

ScriptAction.__triggered

__triggered()

Private method connected to the QAction triggered signal.

ScriptAction.addTo

addTo(widget)

Public method to add this action to a widget.

This keeps a list of widgets we are added to.

widget
widget to add this action to (QWidget)

ScriptAction.execute

execute(out, err, globals, locals)

Public method to execute this script.

out
redirect for sys.stdout
err
redirect for sys.stderr
globals
dictionary containing global scope
locals
dictionary containing local scope

ScriptAction.remove

remove()

Public method to remove this action.

ScriptAction.removeFrom

removeFrom(widget)

Public method to remove this action from a widget.

This keeps a list of widgets we are added to.

widget
widget to remove this action from (QWidget)

Up


ScriptError

Base class for all scripting related exceptions.

Derived from

Exception

Methods

ScriptError Constructor
__repr__ Private method returning a representation of the exception.
__str__ Private method returning a string representation of the exception.

ScriptError (Constructor)

ScriptError()

Constructor

ScriptError.__repr__

__repr__()

Private method returning a representation of the exception.

Returns:
string representing the error message

ScriptError.__str__

__str__()

Private method returning a string representation of the exception.

Returns:
string representing the error message

Up


ScriptManager

Class implementing the script manager.

Signals

firstScriptAdded
emitted after the first script was added
lastScriptDeleted
emitted after the last script was deleted

Derived from

QObject

Methods

ScriptManager Constructor
addScript Public method to add a new script.
deleteScript Public method to delete a script.
executeAction Public slot to execute a script action.
executeScript Public method to execute a script.
getScriptName Public method to select a script name from the list of scripts.
getScriptNames Public method to retrieve the names of all scripts.

ScriptManager (Constructor)

ScriptManager(parent = None, global_ = None, local_ = None)

Constructor

parent
parent of this scriptmanager (QObject)
global_
dictionary for global scope
local_
dictionary for local scope
*args
arguments passed on to QObject

ScriptManager.addScript

addScript(scriptName, scriptString)

Public method to add a new script.

scriptName
name of the script to be added (string or QString)
scriptString
the script code (string or QString)
Returns:
a ScriptAction object

ScriptManager.deleteScript

deleteScript(scriptName)

Public method to delete a script.

scriptName
name of the script to be deleted (string or QString)

ScriptManager.executeAction

executeAction(action)

Public slot to execute a script action.

action
script action to be executed (ScriptAction)

ScriptManager.executeScript

executeScript(scriptName, out = sys.stdout, err = sys.stderr)

Public method to execute a script.

scriptName
name of the script to be executed (string or QString)
out
redirect for stdout
err
redirect for stderr
Raises NoSuchScriptError:
raised, if the named script cannot be found

ScriptManager.getScriptName

getScriptName()

Public method to select a script name from the list of scripts.

Returns:
Tuple of script name and a flag, indicating, if the user pressed ok or canceled the operation. (QString, boolean)

ScriptManager.getScriptNames

getScriptNames()

Public method to retrieve the names of all scripts.

Returns:
list of all script names (list of strings)

Up