-
Notifications
You must be signed in to change notification settings - Fork 1
License Representation
This page describes how licenses are modeled and how a license list is parsed.
##Single License
The class License in the spdx.document module represents a single license.
A license has an identifier, a url and a full name.
The URL property is simply the identifier prefixed with http://spdx.org/licenses/.
The class LicenseConjuction in the spdx.document module represents a conjunction of two licenses.
It's composed of two License instances license_1 and license_2.
It's a subclass of License and overrides the identifier and full_name properties by simply adding an and between the properties of license_1 and license_2.
The class LicenseDisjunction in the spdx.document module represents a disjunction of two licenses.
It's composed of two License instances license_1 and license_2.
It's a subclass of License and overrides the identifier and full_name properties by simply adding an or between the properties of license_1 and license_2.
The class ExtractedLicense in the spdx.document module represents an extracted license in an spdx document.
A license list value is a conjunction or disjunction of multiple licenses in the form: ( LicenseRef-1 and Apache-2.0 and LicenseRef-2) or ( LicenseRef-1 or Apache-2.0 or LicenseRef-2).
The spdx.utils.LicenseListLexer class uses ply.lex in order to convert a license list to a stream of tokens. It has the following tokens:
| TOKEN | DESCRIPTION |
|---|---|
| LP | Left parenthesis |
| RP | Right parenthesis |
| AND | and |
| OR | or |
| LICENSE | License identifier |
The spdx.utils.LicenseListParser class uses ply.yacc in order to parse the tokens returned by LicenseListLexer.
The LicenseListParser.parser method returns a LicenseConjuction or LicenseDisjunction instance that represents the 'root' of the license list.
The licenses are grouped from right to left. The parse method returns None if there is a syntax error.
license_list ::= LP conjuctions RP | LP disjunctions RP
conjuctions ::= conjuctions AND conjuction| conjuctions AND license| conjuction
disjunctions ::= disjunctions OR disjunction | disjunctions OR license | disjunction
conjuction ::= license AND license
disjunction ::= license OR license
license ::= LICENSE
Notes:
- Non-terminals are lower case. Terminals upper case.
-
licenserule is for taking an action.
- Granular
LicenseListParsererror reporting.