AppleScript Environment

class oscopilot.environments.applescript_env.AppleScript[source]

Bases: SubprocessEnv

A class representing an AppleScript environment for executing AppleScript code.

This class inherits from SubprocessEnv, which provides a general environment for executing code in subprocesses.

add_active_line_indicators(code)[source]

Adds log commands to indicate the active line of execution in the AppleScript.

Parameters:

code (str) – The AppleScript code to add active line indicators to.

Returns:

The modified AppleScript code with active line indicators.

Return type:

str

detect_active_line(line)[source]

Detects the active line indicator in the output.

Parameters:

line (str) – A line from the output.

Returns:

The line number indicated by the active line indicator, or None if not found.

Return type:

int

detect_end_of_execution(line)[source]

Detects the end of execution marker in the output.

Parameters:

line (str) – A line from the output.

Returns:

True if the end of execution marker is found, False otherwise.

Return type:

bool

file_extension = 'applescript'
name = 'AppleScript'
preprocess_code(code)[source]

Preprocesses the AppleScript code before execution.

Inserts an end_of_execution marker and adds active line indicators to the code.

Parameters:

code (str) – The AppleScript code to preprocess.

Returns:

The preprocessed AppleScript code.

Return type:

str