class LoadFileCommand extends Command
Command
that represents a request to use
Jython to run a file containing Jython statements. This is conceptually a
bit similar to importing a module, but the loading is done behind the scenes
and you may specify whatever namespace you like (be careful!).Modifier and Type | Field and Description |
---|---|
private String |
name
Namespace to use when executing
path . |
private String |
path
Path to the Jython file awaiting execution.
|
Constructor and Description |
---|
LoadFileCommand(Console console,
String name,
String path)
Creates a command that will attempt to execute a Jython file in the
namespace given by
name . |
Modifier and Type | Method and Description |
---|---|
void |
execute(Interpreter interpreter)
Tries to load the file specified by
path using moduleName
for the __name__ attribute. |
String |
toString() |
getInputStream
public LoadFileCommand(Console console, String name, String path)
name
.console
- Originating console.name
- Namespace to use when executing path
.path
- Path to a Jython file.public void execute(Interpreter interpreter) throws Exception
path
using moduleName
for the __name__
attribute. Note that this command does not
currently display any results in the originating Console
.
If moduleName
is not __main__
, this command is
basically the same thing as doing from moduleName import *
.
If moduleName
is __main__
, then this command
will work for if __name__ == '__main__'
and will run main
functions as expected.