knitout_interpreter.knitout_execution_structures.knitout_header module

Module containing the Knitting_Machine_Header class

class Knitting_Machine_Header(initial_specification=None, version=2)[source]

Bases: Sequence[Knitout_Header_Line]

A class structure for maintaining the relationship between header lines and knitting machine state.

This class manages the relationship between header lines read from a knitout file and the state of a given knitting machine.

__init__(initial_specification=None, version=2)[source]
property header_lines: list[Knitout_Header_Line]

Returns: list[Knitout_Header_Line]: A list of Knitout_Header_Lines that are set by this header object.

property header_len: int

Returns: int: The number of lines that will be in this header.

property specification: Knitout_Machine_Specification

Returns: Knitout_Machine_Specification: The knitting machine specification created by this header.

set_header_by_specification(machine_specification, version=2)[source]

Set the header lines to produce the given machine specification.

Parameters:
  • machine_specification (Knitout_Machine_Specification) – The machine specification to set this header to.

  • version (int, optional) – The version to set the header to. Defaults to 2.

extract_header(program)[source]

Update the header specification with any header lines in the given instruction sequence.

Parameters:

program (Sequence[Knitout_Line]) – The instruction sequence of the knitting machine being executed and update the header specification.

Returns:

True if any of the headers found in the instruction sequence updated the header specification, False otherwise.

Return type:

bool

count(value) integer -- return number of occurrences of value
index(value[, start[, stop]]) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.