Pkg.SimpleBatchEmulator — API for emulating Windows batch scripts

Overview

The Pkg.SimpleBatchEmulator module contains the API for emulating Windows batch scripts.

Emulating a Batch Script

The following code example demonstrates how to emulate a batch script:

from Pkg.SimpleBatchEmulator import *

script = r'''
set foo="hello"
echo %foo%
'''

emu = SimpleBatchEmulator(script)
emu.run()

Module API

Pkg.SimpleBatchEmulator module API.

Classes:

SimpleBatchEmulator(script)

This class is capable of emulating simple batch files.

class SimpleBatchEmulator(script: str)

This class is capable of emulating simple batch files.

Parameters

script (str) – The batch script to emulate.

See also run() and step().

Methods:

getBreakpoints()

Returns the set of breakpoints.

getCurrentLine()

Returns the number of the current line.

getLineCount()

Returns the number of script lines.

getLines()

Returns the script lines.

getVariables()

Returns the dictionary of variables.

goToLine(nline)

Jumps to a specified line.

previewCurrentLine()

Returns the next line to be emulated.

removeBreakpoint(nline)

Removes a breakpoint.

run([wo])

Emulates the script.

setBreakpoint(nline)

Sets a breakpoint.

step()

Emulates a single line.

getBreakpoints()Set[int]
Returns

Returns the set of breakpoints.

Return type

Set[int]

getCurrentLine()int
Returns

Returns the number of the current line.

Return type

int

getLineCount()int
Returns

Returns the number of script lines.

Return type

int

getLines()List[str]
Returns

Returns the script lines.

Return type

List[str]

getVariables()Dict[str, str]
Returns

Returns the dictionary of variables.

Return type

Dict[str, str]

goToLine(nline: int)bool

Jumps to a specified line.

Parameters

nline (int) – The line number.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

See also step().

previewCurrentLine()str
Returns

Returns the next line to be emulated.

Return type

str

removeBreakpoint(nline: int)bool

Removes a breakpoint.

Parameters

nline (int) – The line number at which the breakpoint is to be removed.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

See also setBreakpoint().

run(wo: Optional[Pro.Core.NTIWait] = None)None

Emulates the script.

Parameters

wo (Optional[NTIWait]) – An optional wait object.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

See also step().

setBreakpoint(nline: int)bool

Sets a breakpoint.

Parameters

nline (int) – The line number at which to set the breakpoint.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

See also removeBreakpoint().

step()bool

Emulates a single line.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

See also run().