mbdlyb.fqn

Fully Qualified Name (FQN) class for hierarchical element naming.

FQN provides a dot-separated string representation of elements’ positions in hierarchical structures, enabling efficient lookup and navigation.

Classes

FQN

Represents a fully qualified name for hierarchical elements.

Module Contents

class mbdlyb.fqn.FQN(fqn: str)

Represents a fully qualified name for hierarchical elements.

FQN uses dot-separated components to represent the path through a hierarchy. For example, ‘system.subsystem.component’ represents an element ‘component’ within ‘subsystem’ within ‘system’.

Variables:
  • _s (str) – The string representation of the FQN.

  • _l (Optional[list[str]]) – Cached list of components, lazily computed.

aslist() → list[str]

Get the FQN as a list of components.

Returns:

List of dot-separated components (cached for efficiency).

Return type:

list[str]

element_count() → int

Get the number of components in this FQN.

Returns:

The number of dot-separated components.

Return type:

int

classmethod fromlist(l: list[str]) → FQN

Create an FQN from a list of components.

Parameters:

l (list[str]) – List of components to join.

Returns:

A new FQN with components joined by dots.

Return type:

FQN

static longest_common_fqn(*fqns: FQN) → FQN | None

Find the longest common FQN prefix among multiple FQNs.

Parameters:

*fqns (FQN) – Variable number of FQNs to compare.

Returns:

The longest common FQN prefix, or None if there is no common prefix.

Return type:

Optional[FQN]

relative_fqn(ref: FQN) → FQN

Get the relative FQN from a reference point.

Parameters:

ref (FQN) – The reference FQN to calculate relative position from.

Returns:

The relative FQN path from the reference point to this FQN.

Return type:

FQN

with_suffix(suffix: str | int) → FQN

Create a new FQN with a suffix appended using double underscore.

Parameters:

suffix (Union[str, int]) – The suffix to append.

Returns:

A new FQN with the suffix appended.

Return type:

FQN

property stem: FQN

Get the FQN without the last component.

Returns:

A new FQN representing the stem (all components except the last one).

Return type:

FQN