cyclonedx.contrib.bom.utils
Bom related utilities
Classes
Ensure that a collection of BomRef objects |
|
Context‑manager utility that temporarily flattens and merges all |
Module Contents
- class cyclonedx.contrib.bom.utils.BomRefDiscriminator(bomrefs: collections.abc.Iterable[cyclonedx.model.bom_ref.BomRef], prefix: str = 'BomRef')
Ensure that a collection of BomRef objects has unique, non‑empty
cyclonedx.model.bom_ref.BomRef.value.The discriminator inspects each provided BomRef and assigns a newly generated identifier to any instance whose
valueis missing or duplicates an earlier one. All original values are preserved and can be restored viareset()or by using this class as a context manager.- discriminate() None
Enforce uniqueness across all :attr:`cyclonedx.model.bom_ref.BomRef.value`s.
Any BomRef whose
valueisNoneor duplicates a previously encountered value is assigned a newly generated unique identifier.
- classmethod from_bom(bom: cyclonedx.model.bom.Bom, prefix: str = 'BomRef') BomRefDiscriminator
Create a discriminator for all
cyclonedx.model.bom_ref.BomRefscontained within a Bom.- This includes BomRefs from
- class cyclonedx.contrib.bom.utils.BomDependencyGraphFlatMerger(bom: cyclonedx.model.bom.Bom)
Context‑manager utility that temporarily flattens and merges all
cyclonedx.model.bom.Bom.dependencies.When used as a context manager, the
cyclonedx.model.bom.Bom’s dependency graph is replaced with a flattened, merged representation for the duration of thewithblock and automatically restored afterward.- flatten_merge() None
Flatten and merge all
cyclonedx.model.bom.Bom.dependencies.This produces a non‑recursive, merged representation of the entire dependency graph and assigns it to the Bom.
Note
The original dependency graph is not modified. A new, flattened dependency structure is assigned to the Bom.
- reset() None
Restore the
cyclonedx.model.bom.Bom’s dependency graph to its original state.Note
This does not modify the dependency graph. It simply reassigns the original dependency collection back to the Bom.