SPDX Core
The SPDX core provides functionality for parsing SPDX license expressions, collecting referenced identifiers, and using a checked-in snapshot of the SPDX License List Data for lookup and bundled license texts.
SPDX license expressions
SPDX license expressions can be parsed into a compact result object that contains the normalized expression string, referenced SPDX license identifiers, referenced exception identifiers, and LicenseRef-* identifiers.
using ReuseLicensing
parsed = parse_spdx_expression("(MIT OR Apache-2.0) AND LicenseRef-Custom.1")
parsed.expression"(MIT OR Apache-2.0) AND LicenseRef-Custom.1"sort(collect(parsed.licenses))2-element Vector{String}:
"Apache-2.0"
"MIT"sort(collect(parsed.licenserefs))1-element Vector{String}:
"custom.1"Legacy SPDX license identifiers with current replacements are normalized by default, so older spellings such as GPL-2.0+ are returned in their current SPDX form. Pass legacy = :error to reject legacy identifiers instead.
parse_spdx_expression("GPL-2.0+").expression"GPL-2.0-or-later"ReuseLicensing.ParsedSPDXExpression — Type
ParsedSPDXExpression{T<:AbstractSPDXLicenseExpression}Result of parse_spdx_expression.
Fields:
ast::T: The parsed SPDX abstract syntax tree.expression::String: The normalized SPDX expression string reconstructed fromast.licenses::Set{String}: Set of referenced SPDX license identifiers used for license-text lookup.exceptions::Set{String}: Set of referenced SPDX license exception identifiers.licenserefs::Set{String}: Set of lowercaseLicenseRefidentifiers used for lookup.
ReuseLicensing.parse_spdx_expression — Function
parse_spdx_expression(expr::AbstractString; legacy = :normalize) -> ParsedSPDXExpressionParse expr as an SPDX license expression and return a ParsedSPDXExpression containing the parsed AST, its normalized SPDX string form, and sets of the referenced license, exception, and LicenseRef identifiers.
The legacy keyword controls handling of deprecated SPDX license identifiers that have current replacements. Use legacy = :normalize to normalize legacy identifiers to their current SPDX form, or legacy = :error to reject them.
Throws ArgumentError if expr is not a valid SPDX license expression.
SPDX license data
Accessor functions are available to query SPDX license information and canonical identifier spellings.
ReuseLicensing.spdx_license_list_version — Function
spdx_license_list_version()Return the SPDX License List version used by this package's checked-in snapshot.
ReuseLicensing.is_spdx_osi_approved — Function
is_spdx_osi_approved(identifier)Return whether identifier is a current SPDX license identifier marked as OSI approved in the checked-in SPDX snapshot.
Unknown and deprecated identifiers return false.
ReuseLicensing.is_spdx_fsf_libre — Function
is_spdx_fsf_libre(identifier)Return whether identifier is a current SPDX license identifier marked as FSF libre in the checked-in SPDX snapshot.
Unknown and deprecated identifiers return false.
ReuseLicensing.canonical_spdx_license_id — Function
canonical_spdx_license_id(identifier; include_deprecated = false)Return the canonical spelling for an SPDX license identifier, or nothing when identifier is unknown. Deprecated identifiers are only included when include_deprecated is true.
ReuseLicensing.canonical_spdx_license_exception_id — Function
canonical_spdx_license_exception_id(identifier; include_deprecated = false)Return the canonical spelling for an SPDX license exception identifier, or nothing when identifier is unknown.
Accessing texts and paths
ReuseLicensing provides direct access to bundled license and exception texts, as well as path-based access for callers that need to control file loading.
ReuseLicensing.spdx_license_text_path — Function
spdx_license_text_path(identifier; include_deprecated = false)Return the path to the checked-in SPDX license text for identifier, or nothing when identifier is unknown or no text file is available.
ReuseLicensing.spdx_license_text — Function
spdx_license_text(identifier; include_deprecated = false)Return the checked-in SPDX license text for identifier, or nothing when identifier is unknown or no text file is available.
ReuseLicensing.spdx_license_exception_text_path — Function
spdx_license_exception_text_path(identifier; include_deprecated = false)Return the path to the checked-in SPDX license exception text for identifier, or nothing when identifier is unknown or no text file is available.
ReuseLicensing.spdx_license_exception_text — Function
spdx_license_exception_text(identifier; include_deprecated = false)Return the checked-in SPDX license exception text for identifier, or nothing when identifier is unknown or no text file is available.