# cyclonedx.model.license

License related things

## Attributes

`LicenseExpressionAcknowledgement` | Deprecated — Alias for `LicenseAcknowledgement`
`License` | TypeAlias for a union of supported license models.

## Classes

`LicenseAcknowledgement` | This is our internal representation of the type_licenseAcknowledgementEnumerationType ENUM type
`DisjunctiveLicense` | This is our internal representation of licenseType complex type that can be used in multiple places within
`LicenseExpressionDetails` | This is our internal representation of the `licenseExpressionDetailedType` complex type that specifies the details
`LicenseExpression` | This is our internal representation of licenseType's expression type that can be used in multiple places within
`LicenseRepository` | Collection of `License`.

## Module Contents

class cyclonedx.model.license.LicenseAcknowledgement

  Bases: `str`, `enum.Enum`

  This is our internal representation of the type_licenseAcknowledgementEnumerationType ENUM type within the CycloneDX standard.

  Note

  Introduced in CycloneDX v1.6

  Note

  See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.7/xml/#type_licenseAcknowledgementEnumerationType

  CONCLUDED = 'concluded'
  DECLARED = 'declared'

cyclonedx.model.license.LicenseExpressionAcknowledgement

  Deprecated — Alias for `LicenseAcknowledgement`

  Deprecated since version next: Import LicenseAcknowledgement instead. The exported original symbol itself is NOT deprecated - only this import path.

class cyclonedx.model.license.DisjunctiveLicense(*, bom_ref: str | cyclonedx.model.bom_ref.BomRef | None = None, id: str | None = None, name: str | None = None, text: cyclonedx.model.AttachedText | None = None, url: cyclonedx.model.XsUri | None = None, acknowledgement: LicenseAcknowledgement | None = None, properties: collections.abc.Iterable[cyclonedx.model.Property] | None = None)

  This is our internal representation of licenseType complex type that can be used in multiple places within a CycloneDX BOM document.

  Note

  See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_licenseType

  property bom_ref: cyclonedx.model.bom_ref.BomRef

    An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be unique within the BOM.

    Returns:

      BomRef

  property id: str | None

    A SPDX license ID.

    Note

    See the list of expected values: https://cyclonedx.org/docs/1.7/json/#components_items_licenses_items_license_id

    Returns:

      str or None

  property name: str | None

    If SPDX does not define the license used, this field may be used to provide the license name.

    Returns:

      str or None

  property text: cyclonedx.model.AttachedText | None

    Specifies the optional full text of the attachment

    Returns:

      AttachedText else None

  property url: cyclonedx.model.XsUri | None

    The URL to the attachment file. If the attachment is a license or BOM, an externalReference should also be specified for completeness.

    Returns:

      XsUri or None

  property properties: SortedSet[Property]

    Provides the ability to document properties in a key/value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions.

    Return:

      Set of Property

  property acknowledgement: LicenseAcknowledgement | None

    Declared licenses and concluded licenses represent two different stages in the licensing process within software development.

    Declared licenses refer to the initial intention of the software authors regarding the licensing terms under which their code is released. On the other hand, concluded licenses are the result of a comprehensive analysis of the project’s codebase to identify and confirm the actual licenses of the components used, which may differ from the initially declared licenses. While declared licenses provide an upfront indication of the licensing intentions, concluded licenses offer a more thorough understanding of the actual licensing within a project, facilitating proper compliance and risk management. Observed licenses are defined in evidence.licenses. Observed licenses form the evidence necessary to substantiate a concluded license.

    Returns:

      LicenseAcknowledgement or None

class cyclonedx.model.license.LicenseExpressionDetails(license_identifier: str, *, bom_ref: str | cyclonedx.model.bom_ref.BomRef | None = None, text: cyclonedx.model.AttachedText | None = None, url: cyclonedx.model.XsUri | None = None)

  This is our internal representation of the `licenseExpressionDetailedType` complex type that specifies the details and attributes related to a software license identifier within a CycloneDX BOM document.

  Note

  Introduced in CycloneDX v1.7

  Note

  See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_licenseExpressionDetailedType

  property license_identifier: str

    A valid SPDX license identifier. Refer to https://spdx.org/specifications for syntax requirements. This field serves as the primary key, which uniquely identifies each record.

    Example values:

      - “Apache-2.0”,

      - “GPL-3.0-only WITH Classpath-exception-2.0”

      - “LicenseRef-my-custom-license”

    Returns:

      str

  property text: cyclonedx.model.AttachedText | None

    A way to include the textual content of the license.

    Returns:

      AttachedText else None

  property url: cyclonedx.model.XsUri | None

    The URL to the license file. If specified, a ‘license’ externalReference should also be specified for completeness.

    Returns:

      XsUri or None

  property bom_ref: cyclonedx.model.bom_ref.BomRef

    An identifier which can be used to reference the license elsewhere in the BOM. Every bom-ref MUST be unique within the BOM. Value SHOULD not start with the BOM-Link intro ‘urn:cdx:’ to avoid conflicts with BOM-Links.

    Returns:

      BomRef

class cyclonedx.model.license.LicenseExpression(value: str, *, bom_ref: str | cyclonedx.model.bom_ref.BomRef | None = None, acknowledgement: LicenseAcknowledgement | None = None, details: collections.abc.Iterable[LicenseExpressionDetails] | None = None)

  This is our internal representation of licenseType’s expression type that can be used in multiple places within a CycloneDX BOM document.

  Note

  See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/json/#components_items_licenses_items_expression

  property details: SortedSet[LicenseExpressionDetails]

    Details for parts of the expression.

    Returns:

      Set of LicenseExpressionDetails

  property bom_ref: cyclonedx.model.bom_ref.BomRef

    An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be unique within the BOM.

    Returns:

      BomRef

  property value: str

    Value of this LicenseExpression.

    Returns:

      str

  property acknowledgement: LicenseAcknowledgement | None

    Declared licenses and concluded licenses represent two different stages in the licensing process within software development.

    Declared licenses refer to the initial intention of the software authors regarding the licensing terms under which their code is released. On the other hand, concluded licenses are the result of a comprehensive analysis of the project’s codebase to identify and confirm the actual licenses of the components used, which may differ from the initially declared licenses. While declared licenses provide an upfront indication of the licensing intentions, concluded licenses offer a more thorough understanding of the actual licensing within a project, facilitating proper compliance and risk management. Observed licenses are defined in evidence.licenses. Observed licenses form the evidence necessary to substantiate a concluded license.

    Returns:

      LicenseAcknowledgement or None

cyclonedx.model.license.License

  TypeAlias for a union of supported license models.

  - `LicenseExpression`

  - `DisjunctiveLicense`

class cyclonedx.model.license.LicenseRepository(iterable=None, key=None)

  Bases: `sortedcontainers.SortedSet`[`License`]

  Collection of `License`.

  This is a set, not a list. Order MUST NOT matter here. If you wanted a certain order, then you should also express whether the items are concat by AND or OR. If you wanted to do so, you should use `LicenseExpression`.

  As a model, this MUST accept multiple `LicenseExpression` along with multiple `DisjunctiveLicense`, as this was an accepted in CycloneDX JSON before v1.5. So for modeling purposes, this is supported. Denormalizers/deserializers will be thankful. The normalization/serialization process SHOULD take care of these facts and do what is needed.

  isdisjoint

    Return True if two sets have a null intersection.

  issubset
  issuperset
  bisect_left
  bisect
  bisect_right
  index

    S.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.

    Supporting start and stop arguments is optional, but recommended.

  irange
  islice
  property key

    Function used to extract comparison key from values.

    Sorted set compares values directly when the key function is none.

  add(value)

    Add value to sorted set.

    Runtime complexity: O(log(n)) – approximate.

        >>> ss = SortedSet()
        >>> ss.add(3)
        >>> ss.add(1)
        >>> ss.add(2)
        >>> ss
        SortedSet([1, 2, 3])

    Parameters:

      value – value to add to sorted set

  clear()

    Remove all values from sorted set.

    Runtime complexity: O(n)

  copy()

    Return a shallow copy of the sorted set.

    Runtime complexity: O(n)

    Returns:

      new sorted set

  count(value)

    Return number of occurrences of value in the sorted set.

    Runtime complexity: O(1)

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> ss.count(3)
        1

    Parameters:

      value – value to count in sorted set

    Returns:

      count

  discard(value)

    Remove value from sorted set if it is a member.

    If value is not a member, do nothing.

    Runtime complexity: O(log(n)) – approximate.

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> ss.discard(5)
        >>> ss.discard(0)
        >>> ss == set([1, 2, 3, 4])
        True

    Parameters:

      value – value to discard from sorted set

  pop(index=-1)

    Remove and return value at index in sorted set.

    Raise `IndexError` if the sorted set is empty or index is out of range.

    Negative indices are supported.

    Runtime complexity: O(log(n)) – approximate.

        >>> ss = SortedSet('abcde')
        >>> ss.pop()
        'e'
        >>> ss.pop(2)
        'c'
        >>> ss
        SortedSet(['a', 'b', 'd'])

    Parameters:

      index (int) – index of value (default -1)

    Returns:

      value

    Raises:

      IndexError – if index is out of range

  remove(value)

    Remove value from sorted set; value must be a member.

    If value is not a member, raise `KeyError`.

    Runtime complexity: O(log(n)) – approximate.

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> ss.remove(5)
        >>> ss == set([1, 2, 3, 4])
        True
        >>> ss.remove(0)
        Traceback (most recent call last):
          ...
        KeyError: 0

    Parameters:

      value – value to remove from sorted set

    Raises:

      KeyError – if value is not in sorted set

  difference(*iterables)

    Return the difference of two or more sets as a new sorted set.

    The difference method also corresponds to operator `-`.

    `ss.__sub__(iterable)` <==> `ss - iterable`

    The difference is all values that are in this sorted set but not the other iterables.

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> ss.difference([4, 5, 6, 7])
        SortedSet([1, 2, 3])

    Parameters:

      iterables – iterable arguments

    Returns:

      new sorted set

  difference_update(*iterables)

    Remove all values of iterables from this sorted set.

    The difference_update method also corresponds to operator `-=`.

    `ss.__isub__(iterable)` <==> `ss -= iterable`

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> _ = ss.difference_update([4, 5, 6, 7])
        >>> ss
        SortedSet([1, 2, 3])

    Parameters:

      iterables – iterable arguments

    Returns:

      itself

  intersection(*iterables)

    Return the intersection of two or more sets as a new sorted set.

    The intersection method also corresponds to operator `&`.

    `ss.__and__(iterable)` <==> `ss & iterable`

    The intersection is all values that are in this sorted set and each of the other iterables.

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> ss.intersection([4, 5, 6, 7])
        SortedSet([4, 5])

    Parameters:

      iterables – iterable arguments

    Returns:

      new sorted set

  intersection_update(*iterables)

    Update the sorted set with the intersection of iterables.

    The intersection_update method also corresponds to operator `&=`.

    `ss.__iand__(iterable)` <==> `ss &= iterable`

    Keep only values found in itself and all iterables.

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> _ = ss.intersection_update([4, 5, 6, 7])
        >>> ss
        SortedSet([4, 5])

    Parameters:

      iterables – iterable arguments

    Returns:

      itself

  symmetric_difference(other)

    Return the symmetric difference with other as a new sorted set.

    The symmetric_difference method also corresponds to operator `^`.

    `ss.__xor__(other)` <==> `ss ^ other`

    The symmetric difference is all values tha are in exactly one of the sets.

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> ss.symmetric_difference([4, 5, 6, 7])
        SortedSet([1, 2, 3, 6, 7])

    Parameters:

      other – other iterable

    Returns:

      new sorted set

  symmetric_difference_update(other)

    Update the sorted set with the symmetric difference with other.

    The symmetric_difference_update method also corresponds to operator `^=`.

    `ss.__ixor__(other)` <==> `ss ^= other`

    Keep only values found in exactly one of itself and other.

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> _ = ss.symmetric_difference_update([4, 5, 6, 7])
        >>> ss
        SortedSet([1, 2, 3, 6, 7])

    Parameters:

      other – other iterable

    Returns:

      itself

  union(*iterables)

    Return new sorted set with values from itself and all iterables.

    The union method also corresponds to operator `|`.

    `ss.__or__(iterable)` <==> `ss | iterable`

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> ss.union([4, 5, 6, 7])
        SortedSet([1, 2, 3, 4, 5, 6, 7])

    Parameters:

      iterables – iterable arguments

    Returns:

      new sorted set

  update(*iterables)

    Update the sorted set adding values from all iterables.

    The update method also corresponds to operator `|=`.

    `ss.__ior__(iterable)` <==> `ss |= iterable`

        >>> ss = SortedSet([1, 2, 3, 4, 5])
        >>> _ = ss.update([4, 5, 6, 7])
        >>> ss
        SortedSet([1, 2, 3, 4, 5, 6, 7])

    Parameters:

      iterables – iterable arguments

    Returns:

      itself