Change Plugin Hooks to Use options object/kwargs (#1132)

This commit is contained in:
Jeff Glass
2023-01-26 07:20:04 -06:00
committed by GitHub
parent 697ac9de9a
commit 12bf6db331
4 changed files with 37 additions and 37 deletions

View File

@@ -25,15 +25,15 @@ export class StdioDirector extends Plugin {
* with that ID for the duration of the evaluation.
*
*/
beforePyScriptExec(interpreter: Interpreter, src: string, PyScriptTag: any): void {
if (PyScriptTag.hasAttribute("output")){
const targeted_io = new TargetedStdio(PyScriptTag, "output", true, true)
PyScriptTag.stdout_manager = targeted_io
beforePyScriptExec(options: {interpreter: Interpreter, src: string, pyScriptTag: any}): void {
if (options.pyScriptTag.hasAttribute("output")){
const targeted_io = new TargetedStdio(options.pyScriptTag, "output", true, true)
options.pyScriptTag.stdout_manager = targeted_io
this._stdioMultiplexer.addListener(targeted_io)
}
if (PyScriptTag.hasAttribute("stderr")){
const targeted_io = new TargetedStdio(PyScriptTag, "stderr", false, true)
PyScriptTag.stderr_manager = targeted_io
if (options.pyScriptTag.hasAttribute("stderr")){
const targeted_io = new TargetedStdio(options.pyScriptTag, "stderr", false, true)
options.pyScriptTag.stderr_manager = targeted_io
this._stdioMultiplexer.addListener(targeted_io)
}
}
@@ -41,14 +41,14 @@ export class StdioDirector extends Plugin {
/** After a <py-script> tag is evaluated, if that tag has a 'stdout_manager'
* (presumably TargetedStdio, or some other future IO handler), it is removed.
*/
afterPyScriptExec(interpreter: Interpreter, src: string, PyScriptTag: any, result: any): void {
if (PyScriptTag.stdout_manager != null){
this._stdioMultiplexer.removeListener(PyScriptTag.stdout_manager)
PyScriptTag.stdout_manager = null
afterPyScriptExec(options: {interpreter: Interpreter, src: string, pyScriptTag: any, result: any}): void {
if (options.pyScriptTag.stdout_manager != null){
this._stdioMultiplexer.removeListener(options.pyScriptTag.stdout_manager)
options.pyScriptTag.stdout_manager = null
}
if (PyScriptTag.stderr_manager != null){
this._stdioMultiplexer.removeListener(PyScriptTag.stderr_manager)
PyScriptTag.stderr_manager = null
if (options.pyScriptTag.stderr_manager != null){
this._stdioMultiplexer.removeListener(options.pyScriptTag.stderr_manager)
options.pyScriptTag.stderr_manager = null
}
}
}