mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 02:37:41 -05:00
Change Plugin Hooks to Use options object/kwargs (#1132)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user