Parser Module¶
In this module you can find the parsing of knitting pattern structures.
-
class
knittingpattern.Parser.Parser(specification)[source]¶ Bases:
objectParses a knitting pattern set and anything in it.
-
__init__(specification)[source]¶ Create a parser with a specification.
Parameters: specification¶ – the types and classes to use for the resulting object structure, preferably a knittingpattern.ParsingSpecification.ParsingSpecification
-
__weakref__¶ list of weak references to the object (if defined)
-
instruction_in_row(row, specification)[source]¶ Parse an instruction.
Parameters: Returns: the instruction in the row
-
knitting_pattern_set(values)[source]¶ Parse a knitting pattern set.
Parameters: value¶ (dict) – the specification of the knitting pattern set Return type: knittingpattern.KnittingPatternSet.KnittingPatternSet Raises: knittingpattern.KnittingPatternSet.ParsingError – if valuedoes not fulfill the specification.
-
new_pattern(id_, name, rows=None)[source]¶ Create a new knitting pattern.
If rows is
Noneit is replaced with thenew_row_collection().
-
new_row(id_)[source]¶ Create a new row with an id.
Parameters: id_¶ – the id of the row Returns: a row Return type: knittingpattern.Row.Row
-
new_row_collection()[source]¶ Create a new row collection.
Returns: a new specified row collection for the knitting pattern
-
-
knittingpattern.Parser.ID= 'id'¶ the id of a row, an instruction or a pattern
-
knittingpattern.Parser.NAME= 'name'¶ the name of a row
-
knittingpattern.Parser.TYPE= 'type'¶ the type of an instruction or the knitting pattern set
-
knittingpattern.Parser.VERSION= 'version'¶ the version of a knitting pattern set
-
knittingpattern.Parser.INSTRUCTIONS= 'instructions'¶ the instructions in a row
-
knittingpattern.Parser.SAME_AS= 'same as'¶ pointer to a inherit from
-
knittingpattern.Parser.PATTERNS= 'patterns'¶ the patterns in the knitting pattern set
-
knittingpattern.Parser.ROWS= 'rows'¶ the rows inside a pattern
-
knittingpattern.Parser.CONNECTIONS= 'connections'¶ the connections in a pattern
-
knittingpattern.Parser.FROM= 'from'¶ the position and row a connection comes from
-
knittingpattern.Parser.TO= 'to'¶ the position and row a connection goes to
-
knittingpattern.Parser.START= 'start'¶ the mesh index the connection starts at
-
knittingpattern.Parser.DEFAULT_START= 0¶ the default mesh index the connection starts at if none is given
-
knittingpattern.Parser.MESHES= 'meshes'¶ the number of meshes of a connection
-
knittingpattern.Parser.COMMENT= 'comment'¶ a comment of a row, an instruction, anything
-
exception
knittingpattern.Parser.ParsingError[source]¶ Bases:
ValueErrorMistake in the provided object to parse.
This Error is raised if there is an error during the parsing for
Parser.-
__weakref__¶ list of weak references to the object (if defined)
-
-
knittingpattern.Parser.default_parser()[source]¶ The parser with a default specification.
Returns: a parser using a knittingpattern.ParsingSpecification.DefaultSpecificationReturn type: knittingpattern.Parser.Parser