KnittingPatternSet Module

A set of knitting patterns that can be dumped and loaded.

class knittingpattern.KnittingPatternSet.KnittingPatternSet(type_, version, patterns, parser, comment=None)[source]

Bases: object

This is the class for a set of knitting patterns.

The knitting patterns all have an id and can be accessed from here. It is possible to load this set of knitting patterns from various locations, see the knittingpattern module. You rarely need to create such a pattern yourself. It is easier to create the pattern by loading it from a file.

__init__(type_, version, patterns, parser, comment=None)[source]

Create a new knitting pattern set.

This is the class for a set of knitting patterns.

Parameters:
  • type (str) – the type of the knitting pattern set, see the specification.
  • version (str) – the version of the knitting pattern set. This is not the version of the library but the version of the specification.
  • patterns – a collection of patterns. This should be a IdCollection of KnittingPatterns.
  • comment – a comment about the knitting pattern
__weakref__

list of weak references to the object (if defined)

add_new_pattern(id_, name=None)[source]

Add a new, empty knitting pattern to the set.

Parameters:
  • id_ – the id of the pattern
  • name – the name of the pattern to add or if None, the id_ is used
Returns:

a new, empty knitting pattern

Return type:

knittingpattern.KnittingPattern.KnittingPattern

comment

The comment about the knitting pattern.

Returns:the comment for the knitting pattern set or None, see __init__().
first

The first element in this set.

Return type:knittingpattern.KnittingPattern.KnittingPattern
patterns

The pattern contained in this set.

Returns:the patterns of the knitting pattern, see __init__()
Return type:knittingpattern.IdCollection.IdCollection

The patterns can be accessed by their id.

to_ayabpng()[source]

Convert the knitting pattern to a png.

Returns:a dumper to save this pattern set as png for the AYAB software
Return type:knittingpattern.convert.AYABPNGDumper.AYABPNGDumper

Example:

>>> knitting_pattern_set.to_ayabpng().temporary_path()
"/the/path/to/the/file.png"
to_svg(zoom)[source]

Create an SVG from the knitting pattern set.

Parameters:zoom (float) – the height and width of a knit instruction
Returns:a dumper to save the svg to
Return type:knittingpattern.Dumper.XMLDumper

Example:

>>> knitting_pattern_set.to_svg(25).temporary_path(".svg")
"/the/path/to/the/file.svg"
type

The type of the knitting pattern.

Returns:the type of the knitting pattern, see __init__()
Return type:str
version

The version of the knitting pattern specification.

Returns:the version of the knitting pattern, see __init__()
Return type:str