knitout_interpreter.knitout_operations.Header_Line module
Module containing the classes for Header Lines in Knitout
- class Knitout_Header_Line_Type(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumEnumeration of properties that can be set in the header.
- Machine = 'machine'
- Gauge = 'gauge'
- Position = 'position'
- Carriers = 'carrier_count'
- Knitout_Version = 'version'
- get_specification_value(specification)[source]
- Parameters:
specification (Knitting_Machine_Specification) – The specification to retrieve the value associated with this header line type.
- Returns:
Return the value in the specification associated with this header type.
- Return type:
Knitting_Machine_Type | int | Knitting_Position
- property specification_keyword: str
Returns: str: The keyword to initialize this value in a Knitting_Machine_Specification.
- classmethod __contains__(member)
Return True if member is a member of this enum raises TypeError if member is not an enum member
note: in 3.12 TypeError will no longer be raised, and True will also be returned if member is the value of a member in this enum
- classmethod __getitem__(name)
Return the member matching name.
- classmethod __iter__()
Return members in definition order.
- classmethod __len__()
Return the number of members (no aliases)
- class Knitout_Header_Line(*args, **kwargs)[source]
Bases:
Knitout_Line- __init__(header_type, header_value, comment=None)[source]
- Parameters:
header_type (Knitout_Header_Line_Type) – The type of value set by this header line.
header_value (Knitting_Machine_Type | int | Knitting_Position) – The value set by this header line.
comment (str, optional) – Additional details in the comments. Defaults to no comment.
- property header_type: Knitout_Header_Line_Type
Returns: Knitout_Header_Line_Type: The type of value to be changed by this header line.
- property header_value: Knitting_Machine_Type | int | Knitting_Position
Returns: Knitting_Machine_Type | int | Knitting_Position: The value set by this header line.
- value_matches_spec(specification)[source]
- Parameters:
specification (Knitting_Machine_Specification) – The machine specification to compare this header line to.
- Returns:
True if the given header value matches the value in the given specification.
- Return type:
- 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:
- 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. False, otherwise.
- Return type:
- __eq__(other)[source]
- Parameters:
other (Knitout_Header_Line) – The other header line to compare to.
- Returns:
True if other is of the same type and share the same header values.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- class Knitout_Version_Line(*args, **kwargs)[source]
Bases:
Knitout_Header_LineRepresents a knitout version specification line.
- __eq__(other)
- Parameters:
other (Knitout_Header_Line) – The other header line to compare to.
- Returns:
True if other is of the same type and share the same header values.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- execute(machine_state)
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. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- property header_type: Knitout_Header_Line_Type
Returns: Knitout_Header_Line_Type: The type of value to be changed by this header line.
- property header_value: Knitting_Machine_Type | int | Knitting_Position
Returns: Knitting_Machine_Type | int | Knitting_Position: The value set by this header line.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- updates_machine_state(machine_state)
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:
- value_matches_spec(specification)
- Parameters:
specification (Knitting_Machine_Specification) – The machine specification to compare this header line to.
- Returns:
True if the given header value matches the value in the given specification.
- Return type:
- class Machine_Header_Line(*args, **kwargs)[source]
Bases:
Knitout_Header_Line- property machine_type: Knitting_Machine_Type
Returns: Knitting_Machine_Type: The type of machine the header line is set to.
- __eq__(other)
- Parameters:
other (Knitout_Header_Line) – The other header line to compare to.
- Returns:
True if other is of the same type and share the same header values.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- execute(machine_state)
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. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- property header_type: Knitout_Header_Line_Type
Returns: Knitout_Header_Line_Type: The type of value to be changed by this header line.
- property header_value: Knitting_Machine_Type | int | Knitting_Position
Returns: Knitting_Machine_Type | int | Knitting_Position: The value set by this header line.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- updates_machine_state(machine_state)
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:
- value_matches_spec(specification)
- Parameters:
specification (Knitting_Machine_Specification) – The machine specification to compare this header line to.
- Returns:
True if the given header value matches the value in the given specification.
- Return type:
- class Gauge_Header_Line(*args, **kwargs)[source]
Bases:
Knitout_Header_Line- __eq__(other)
- Parameters:
other (Knitout_Header_Line) – The other header line to compare to.
- Returns:
True if other is of the same type and share the same header values.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- execute(machine_state)
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. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- property header_type: Knitout_Header_Line_Type
Returns: Knitout_Header_Line_Type: The type of value to be changed by this header line.
- property header_value: Knitting_Machine_Type | int | Knitting_Position
Returns: Knitting_Machine_Type | int | Knitting_Position: The value set by this header line.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- updates_machine_state(machine_state)
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:
- value_matches_spec(specification)
- Parameters:
specification (Knitting_Machine_Specification) – The machine specification to compare this header line to.
- Returns:
True if the given header value matches the value in the given specification.
- Return type:
- class Position_Header_Line(*args, **kwargs)[source]
Bases:
Knitout_Header_Line- property position: Knitting_Position
Returns: Knitting_Position: The position of the knitting area on the needle beds.
- __eq__(other)
- Parameters:
other (Knitout_Header_Line) – The other header line to compare to.
- Returns:
True if other is of the same type and share the same header values.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- execute(machine_state)
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. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- property header_type: Knitout_Header_Line_Type
Returns: Knitout_Header_Line_Type: The type of value to be changed by this header line.
- property header_value: Knitting_Machine_Type | int | Knitting_Position
Returns: Knitting_Machine_Type | int | Knitting_Position: The value set by this header line.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- updates_machine_state(machine_state)
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:
- value_matches_spec(specification)
- Parameters:
specification (Knitting_Machine_Specification) – The machine specification to compare this header line to.
- Returns:
True if the given header value matches the value in the given specification.
- Return type:
- class Carriers_Header_Line(*args, **kwargs)[source]
Bases:
Knitout_Header_Line- property carrier_str: str
Returns: str: The string of carriers used to initialize the header string.
- __eq__(other)
- Parameters:
other (Knitout_Header_Line) – The other header line to compare to.
- Returns:
True if other is of the same type and share the same header values.
- Return type:
- classmethod __init_subclass__(**kwargs)
Automatically wrap execute() method in all subclasses.
- static __new__(cls, *args, **kwargs)
Counts the number of knitout lines created while running a program. Ensures a unique identifier for each knitout line.
- property comment_str: str
Get the comment as a formatted string.
- Returns:
The comment formatted as a string with appropriate formatting.
- execute(machine_state)
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. False, otherwise.
- Return type:
- property follow_comments: list[Knitout_Comment_Line]
Returns: list[Knitout_Comment_Line]: A list of Knitout_Comment_Line objects that follow this line.
- property has_comment: bool
Check if this line has a comment.
- Returns:
True if comment is present. False, otherwise.
- Return type:
- property has_line_number: bool
Returns: bool: True if the original line number of this knitout line has been set.
- property header_type: Knitout_Header_Line_Type
Returns: Knitout_Header_Line_Type: The type of value to be changed by this header line.
- property header_value: Knitting_Machine_Type | int | Knitting_Position
Returns: Knitting_Machine_Type | int | Knitting_Position: The value set by this header line.
- id_str()
Get string representation with original line number if present.
- Returns:
String with original line number added if present.
- Return type:
- property original_line_number: int
Returns: int: The original position of this line from the program it was parsed from.
- set_line(line_number, source=None)
Set the line number of this instruction. If this is the first time that the instruction’s line was set, the value will become the original line number.
- property source_program: str | None
Returns: str | None: The name of the program this was parsed from or None if that value is unknown.
- updates_machine_state(machine_state)
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: