otupy.profiles.xbom.data.abstract_xbom.Xbom

class Xbom

Bases: Record, ABC

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

add

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_dependency

Add a dependency relationship

add_dependency_with_external_ref

Add both an external reference and a dependency to another XBOM

find_ref_by_name

Find the bom_ref of a component or service by name

fromdict

Polymorphic deserialization for Xbom subclasses

todict

Converts to dictionary

Attributes

bom

Bill of Materials object (format-specific)

format

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

bom: Any = None

Bill of Materials object (format-specific)

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 Encoder argument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..

Parameters:

e – The Encoder that is being used.

Returns:

A dictionary compliants to the Language Specification’s serialization rules.