InstructionLibrary Module¶
Instructions have many attributes that do not need to be specified
in each knitting pattern set.
This module provides the fucntionality to load default values for instructions from various locations.
-
class
knittingpattern.InstructionLibrary.InstructionLibrary[source]¶ Bases:
objectThis library can be used to look up default specification of instructions.
The specification is searched for by the type of the instruction.
-
__init__()[source]¶ Create a new
InstructionLibrarywithout arguments.Use
loadto load specifications.
-
__weakref__¶ list of weak references to the object (if defined)
-
add_instruction(specification)[source]¶ Add an instruction specification
Parameters: specification¶ – a specification with a key knittingpattern.Instruction.TYPESee also
-
as_instruction(specification)[source]¶ Convert the specification into an instruction
Parameters: specification¶ – a specification with a key knittingpattern.Instruction.TYPEThe instruction is not added.
See also
-
load¶ Returns: a loader that can be used to load specifications Return type: knittingpattern.Loader.JSONLoader A file to load is a list of instructions in JSON format.
[ { "type" : "knit", "another" : "attribute" }, { "type" : "purl" } ]
-
-
class
knittingpattern.InstructionLibrary.DefaultInstructions[source]¶ Bases:
knittingpattern.InstructionLibrary.InstructionLibraryThe default specifications for instructions ported with this package
-
INSTRUCTIONS_FOLDER= 'instructions'¶ the folder relative to this module where the instructions are located
-
-
knittingpattern.InstructionLibrary.default_instructions()[source]¶ Returns: a default instruction library Return type: DefaultInstructions Warning
The return value is mutable and you should not add new instructions to it. If you would like to add instructions to it, create a new
DefaultInstructionsinstance.