otupy.profiles.xbom.data.abstract_xbom.Xbom
- class Xbom
-
Abstract base class for eXtended Bill of Materials (XBOM)
This abstract class defines the minimal interface that all XBOM implementations must follow. Actuators work with this interface, allowing different BOM formats to be used interchangeably without changes to the actuator code.
Only methods used by actuators are abstracted here. Format-specific methods remain in the concrete implementations.
Methods
Adds an item to the XBOM. This method must implement the logic to handle the different types of items that can be added to the XBOM. It should integrate other classes defined within this folder by invoking their respective as_* methods to ensure the item is correctly processed before addition. :param item: The item to be added. :return: None.
Add a dependency relationship
Add both an external reference and a dependency to another XBOM
Find the bom_ref of a component or service by name
Polymorphic deserialization for Xbom subclasses
Converts to dictionary
Attributes
Bill of Materials object (format-specific)
Format of the XBOM
- abstractmethod add(item: Any) None
Adds an item to the XBOM. This method must implement the logic to handle the different types of items that can be added to the XBOM. It should integrate other classes defined within this folder by invoking their respective as_* methods to ensure the item is correctly processed before addition. :param item: The item to be added.
- return:
None
- abstractmethod add_dependency(parent_ref: str, child_ref: str) None
Add a dependency relationship
Creates a dependency where child_ref depends on parent_ref.
- Parameters:
parent_ref – The bom_ref of the item that is depended upon
child_ref – The bom_ref of the dependent item
- Returns:
None
- abstractmethod add_dependency_with_external_ref(depends_on_xbom: Xbom, from_ref: str, comment: str | None = None) None
Add both an external reference and a dependency to another XBOM
- Parameters:
depends_on_xbom – The XBOM that this XBOM depends on
from_ref – The bom_ref of the item in this BOM that depends on the other
comment – Optional comment describing the dependency
- Returns:
None
- abstractmethod find_ref_by_name(name: str) str | None
Find the bom_ref of a component or service by name
- Parameters:
name – The name of the component or service to find
- Returns:
The bom_ref string if found, None otherwise
- format: XbomFormat = None
Format of the XBOM
- classmethod fromdict(dic, e)
Polymorphic deserialization for Xbom subclasses
When deserializing to the abstract Xbom type, this method inspects the ‘format’ field to determine the correct concrete subclass to use.
- Parameters:
dic – The dictionary representation
e – The encoder being used
- Returns:
An instance of the appropriate concrete Xbom subclass
- todict(e)
Converts to dictionary
It is used to convert this object to an intermediary representation during serialization. It takes an
Encoderargument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat is being used.- Returns:
A dictionary compliants to the Language Specification’s serialization rules.