knittingpattern Module

The knitting pattern module.

Load and convert knitting patterns using the convinience functions lited below.

knittingpattern.load_from_object(object_)[source]

Load a knitting pattern from an object.

Return type:knittingpattern.KnittingPatternSet.KnittingPatternSet
knittingpattern.load_from_string(string)[source]

Load a knitting pattern from a string.

Return type:knittingpattern.KnittingPatternSet.KnittingPatternSet
knittingpattern.load_from_file(file)[source]

Load a knitting pattern from a file-like object.

Return type:knittingpattern.KnittingPatternSet.KnittingPatternSet
knittingpattern.load_from_path(path)[source]

Load a knitting pattern from a file behind located at path.

Return type:knittingpattern.KnittingPatternSet.KnittingPatternSet
knittingpattern.load_from_url(url)[source]

Load a knitting pattern from a url.

Return type:knittingpattern.KnittingPatternSet.KnittingPatternSet
knittingpattern.load_from_relative_file(module, path_relative_to)[source]

Load a knitting pattern from a path relative to a module.

Parameters:
  • module (str) – can be a module’s file, a module’s name or a module’s path.
  • path_relative_to (str) – is the path relavive to the modules location. The result is loaded from this.
Return type:

knittingpattern.KnittingPatternSet.KnittingPatternSet

knittingpattern.convert_from_image(colors=('white', 'black'))[source]

Convert and image to a knitting pattern.

Returns:a loader
Return type:knittingpattern.Loader.PathLoader
Parameters:colors (tuple) – the colors to convert to
convert_from_image().path("pattern.png").path("pattern.json")
convert_from_image().path("pattern.png").knitting_pattern()

See also

knittingoattern.convert.image_to_knitting_pattern

knittingpattern.load_from()[source]

Create a loader to load knitting patterns with.

Returns:the loader to load objects with
Return type:knittingpattern.Loader.JSONLoader

Example:

import knittingpattern, webbrowser
k = knittingpattern.load_from().example("Cafe.json")
webbrowser.open(k.to_svg(25).temporary_path(".svg"))
knittingpattern.new_knitting_pattern(id_, name=None)[source]

Create a new knitting pattern.

Returns:

a new empty knitting pattern.

Parameters:
  • id_ – the id of the knitting pattern
  • name – the name of the knitting pattern or None if the id_ should be used
Return type:

knittingpattern.KnittingPattern.KnittingPattern

knittingpattern.new_knitting_pattern_set()[source]

Create a new, empty knitting pattern set.

Return type:knittingpattern.KnittingPatternSet.KnittingPatternSet
Returns:a new, empty knitting pattern set