Skip to content
Ahmed Hisham Ismail edited this page Jun 27, 2014 · 3 revisions

The module spdx.parsers.tagvaluebuilders contains the builder classes responsible for building SPDX document components.

###Exceptions

Name Description
BuilderException Super class of all exceptions raises by builders
IncompatibleVersionError Raised if tried to set an unsupported version as document version
CardinalityError Raised if tried to add more than m entries of a field that can have a maximum of M
ValueError Raised if a field is given an incorrect value
'OrderError` Raised if a field set before a prerequisite is

Helper Methods

####str_from_text retrieves the content of free form text between <text> and </text> tags.

Returns None if not free form text.

##Classes

DocBuilder

This class is responsible for setting the fields of spdx.document.Document. All methods take a Document as one of the parameters and modifies it to set the values. Methods either return True or raise one of the exceptions above.

EntityBuilder

This class is different from other builders, instead of setting fields in the Document parameter it creates spdx.creationinfo.Creator instances by parsing strings and returns them.

It has three methods build_tool , build_org and build_person. That return an instance of on of the subclasses of Creator.

It's methods only raise ValueError exceptions, if the value is not a valid entity representation.

CreationInfoBuilder

This class is responsible for for setting the fields of spdx.creationinfo.CreationInfo

ReviewBuilder

This is the class responsible for setting the fields of spdx.review.Review and adding them to the document. A reviewer marks the start of a new review entry. the method add_reviewer also creates a new review and adds it to the document. The other methods operate on the last review added to the document.

PackageBuilder

This is the class responsible for setting the fields of spdx.package.Package

Builder

This class extends all other builder classes, to provide a single builder to build any component of a document. This is what the Tag/Value parser uses to build a document. The method reset must be called between different documents to reset the state of all the builders.

Clone this wiki locally