knitout_interpreter.knitout_language.Knitout_Context module

Module used to manage the context of a knitout interpreter.

knitout_interpreter.knitout_language.Knitout_Context.process_knitout_instructions(codes)[source]

Separate list of knitout codes into components of a program for execution.

Parameters:

codes (list[Knitout_Line]) – List of knitout instructions to separate into program components.

Returns:

  • Version line for the knitout program

  • List of header lines

  • List of instruction lines

  • List of comment lines

Return type:

A tuple containing

class knitout_interpreter.knitout_language.Knitout_Context.Knitout_Context[source]

Bases: object

Maintains information about the state of a knitting process as knitout instructions are executed.

property version: int

Get the knitout version of the current context.

Returns:

The knitout version number, defaults to 2 if no version is set.

execute_header(header_declarations, comment_no_op_header=False)[source]

Update the machine state based on the given header values.

Header declarations that do not change the current context can optionally be converted to comments.

Parameters:
  • header_declarations (list[Knitout_Header_Line]) – The header lines to update based on.

  • comment_no_op_header (bool) – If True, no-op header declarations will be added to the instructions as comments. Defaults to False.

execute_instructions(instructions)[source]

Execute the instruction set on the machine state defined by the current header.

Parameters:

instructions (list[Knitout_Line]) – Instructions to execute on the knitting machine.

execute_knitout(version_line, header_declarations, instructions)[source]

Execute the given knitout organized by version, header, and instructions.

Parameters:
Returns:

  • List of knitout instructions that were executed

  • Machine state after execution

  • Knit graph created by execution

Return type:

A tuple containing

process_knitout_file(knitout_file_name)[source]

Parse and process a file of knitout code.

Parameters:

knitout_file_name (str) – File path containing knitout code to process.

Returns:

  • List of executed knitout lines

  • Knitting machine state after execution

  • Knit graph formed by execution

Return type:

A tuple containing

execute_knitout_instructions(codes)[source]

Execute given knitout instructions.

Parameters:

codes (list[Knitout_Line]) – List of knitout lines to execute.

Returns:

  • List of executed knitout lines

  • Machine state after execution

  • Knit graph created by execution

Return type:

A tuple containing