InstructionSVGCache
Module¶
This module provides functionality to cache instruction SVGs.
-
class
knittingpattern.convert.InstructionSVGCache.
InstructionSVGCache
(instruction_to_svg=None)[source]¶ Bases:
object
This class is a cache for SVG instructions.
If you plan too use only
instruction_to_svg_dict()
, you are save to replace aknittingpsttern.convert.InstructionToSVG.InstructionToSVG
with this cache to get faster results.-
__init__
(instruction_to_svg=None)[source]¶ Create the InstructionSVGCache.
Parameters: instruction_to_svg¶ – an InstructionToSVG
object. IfNone
is given, thedefault_instructions_to_svg
is used.
-
__weakref__
¶ list of weak references to the object (if defined)
-
get_instruction_id
(instruction_or_id)[source]¶ The id that identifies the instruction in this cache.
Parameters: instruction_or_id¶ – an instruction
or an instruction idReturns: a hashable
objectReturn type: tuple
-
instruction_to_svg_dict
(instruction_or_id, copy_result=True)[source]¶ Return the SVG dict for the SVGBuilder.
Parameters: - instruction_or_id¶ – the instruction or id, see
get_instruction_id()
- copy_result¶ (bool) – whether to copy the result
Return type: The result is cached.
- instruction_or_id¶ – the instruction or id, see
-
-
knittingpattern.convert.InstructionSVGCache.
default_instruction_svg_cache
()[source]¶ Return the default InstructionSVGCache.
Return type: knittingpattern.convert.InstructionSVGCache.InstructionSVGCache
-
knittingpattern.convert.InstructionSVGCache.
default_svg_cache
()¶ Return the default InstructionSVGCache.
Return type: knittingpattern.convert.InstructionSVGCache.InstructionSVGCache