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

Document

The spdx.document.Document class represents the Document model, it is the top level of any spdx file.

Field Type Notes
version spdx.version.Version The SPDX version, currently only version 1.2 is supported
data_license spdx.document.License Must be CC-1.0 can be created by License.from_identifier('CC-1.0')
comment str Document comment, may be None
creation_info spdx.creationinfo.CreationInfo The document's creation information
package spdx.package.Package The package described by the document
extracted_licenses list of spdx.document.License Extracted Licenses, could be empty
reviews list of spdx.review.Review Document Reviews could be empty

The Document.validate method checks all the fields of a document and returns true if they are all valid according to the standard. It takes an optional parameter messages to append all error messages to it for displaying to the user.

TODO:

  • Implement validate_extraced_licenses method.

Creator

The class spdx.creationinfo.Creator represents a creator entity. It has a single field name and can be compared for equality with other Creators (does not check type).

Organization

The class spdx.creationinfo.Organization represents an organization entity it extends spdx.creationinfo.Creator and adds an email field. It also overrides the __eq__ method.

Person

The class spdx.creationinfo.Person represents a Person entity, it extends spdx.creationinfo.Creator to provide an email field. The Only difference between it and Organization is type in case a user needs that distinction.

##Tool The class spdx.creationinfo.Tool represents a Tool entity, it extends spdx.creationinfo.Creator It only has a name field. The only difference between it and Creator is type distinction.

##CreationInfo The class spdx.creationinfo.CreationInfo represents a document's creation info.

Field Type Notes
creators list of spdx.creationinfo.Creator or any subclass
created datetime.datetime Date of creation
comment str creation comment, could be None
license_list_version spdx.version.Version By default set to the value of config.LICENSE_LIST_VERSION

Methods:

add_creator : Appends a creator.

remove_creator : removes a creator.

set_created_now : sets creation date to datetime.utcnow()

validate : Validates the fields. Appends error messages to messages parameter.

Properties:

created_iso_format : Creation date as iso 8601 string.

Version

The class spdx.version.Version represents a version. It has two fields major and minor both integers. The class method from_str parses a string of the form N.N where N is a number and returns a version. It returns None if the string is invalid. It also provides a __cmp__ method.

Clone this wiki locally