knitout_interpreter.knitout_operations.Header_Line module

Module containing the classes for Header Lines in Knitout

class knitout_interpreter.knitout_operations.Header_Line.Knitout_Header_Line_Type(value)[source]

Bases: Enum

Enumeration of properties that can be set in the header.

Machine = 'Machine'
Gauge = 'Gauge'
Yarn = 'Yarn'
Position = 'Position'
Carriers = 'Carriers'
class knitout_interpreter.knitout_operations.Header_Line.Knitout_Header_Line(header_type, header_value, comment)[source]

Bases: Knitout_Line

updates_machine_state(machine_state)[source]

Check if this header would update the given machine state.

Parameters:

machine_state (Knitting_Machine) – The machine state to check against.

Returns:

True if this header would update the given machine state, False otherwise.

Return type:

bool

class knitout_interpreter.knitout_operations.Header_Line.Machine_Header_Line(machine_type, comment=None)[source]

Bases: Knitout_Header_Line

updates_machine_state(machine_state)[source]

Check if this header would update the given machine state.

Parameters:

machine_state (Knitting_Machine) – The machine state to check against.

Returns:

True if this header would update the given machine state, False otherwise.

Return type:

bool

execute(machine_state)[source]

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Returns:

True if the process completes an update.

Return type:

bool

class knitout_interpreter.knitout_operations.Header_Line.Gauge_Header_Line(gauge, comment=None)[source]

Bases: Knitout_Header_Line

updates_machine_state(machine_state)[source]

Check if this header would update the given machine state.

Parameters:

machine_state (Knitting_Machine) – The machine state to check against.

Returns:

True if this header would update the given machine state, False otherwise.

Return type:

bool

execute(machine_state)[source]

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Returns:

True if the process completes an update.

Return type:

bool

class knitout_interpreter.knitout_operations.Header_Line.Position_Header_Line(position, comment=None)[source]

Bases: Knitout_Header_Line

updates_machine_state(machine_state)[source]

Check if this header would update the given machine state.

Parameters:

machine_state (Knitting_Machine) – The machine state to check against.

Returns:

True if this header would update the given machine state, False otherwise.

Return type:

bool

execute(machine_state)[source]

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Returns:

True if the process completes an update.

Return type:

bool

class knitout_interpreter.knitout_operations.Header_Line.Yarn_Header_Line(carrier_id, plies, yarn_weight, color, comment=None)[source]

Bases: Knitout_Header_Line

updates_machine_state(machine_state)[source]

Check if this header would update the given machine state.

Parameters:

machine_state (Knitting_Machine) – The machine state to check against.

Returns:

True if this header would update the given machine state, False otherwise.

Return type:

bool

execute(machine_state)[source]

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Returns:

True if the process completes an update.

Return type:

bool

class knitout_interpreter.knitout_operations.Header_Line.Carriers_Header_Line(carrier_ids, comment=None)[source]

Bases: Knitout_Header_Line

updates_machine_state(machine_state)[source]

Check if this header would update the given machine state.

Parameters:

machine_state (Knitting_Machine) – The machine state to check against.

Returns:

True if this header would update the given machine state, False otherwise.

Return type:

bool

execute(machine_state)[source]

Execute the instruction on the machine state.

Parameters:

machine_state (Knitting_Machine) – The knitting machine state to update.

Returns:

True if the process completes an update.

Return type:

bool

class knitout_interpreter.knitout_operations.Header_Line.Knitting_Machine_Header(knitting_machine)[source]

Bases: object

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.

update_header(header_line, update_machine=False)[source]

Update this header with the given header line.

Parameters:
  • header_line (Knitout_Header_Line) – The header line to update this header with.

  • update_machine (bool) – If True, the header line will update the machine state to the new values in this header_line, if present. If False, the header line will only update this header if there is no explicitly set header line for that value. In this case, if the header line would require the machine state to update, a warning is raised.

Returns:

True if this header is updated by the given header line.

Return type:

bool

Note

If update_machine is False, no updates are allowed and this will always return False. If the update would cause a change in the active machine, then a warning is raised, and it makes no changes to the machine state.

set_header_by_specification(machine_specification)[source]

Set the header lines to produce the given machine specification.

Parameters:

machine_specification (Knitting_Machine_Specification) – The machine specification to set this header to.

get_header_lines(version=2)[source]

Get a complete knitout header from the stored header lines.

Parameters:

version (int) – The knitout version number to process with. Defaults to 2.

Returns:

List of header lines that form a complete knitout header. This starts with a version line.

Return type:

list[Knitout_Line]

knitout_interpreter.knitout_operations.Header_Line.get_machine_header(knitting_machine, version=2)[source]

Get a list of header lines that describe the given machine state.

Parameters:
  • knitting_machine (Knitting_Machine) – The machine state to specify as a header.

  • version (int) – The desired knitout version of the header. Defaults to 2.

Returns:

A list containing header lines and a version line that describes the given machine state.

Return type:

list[Knitout_Line]