Skip to content

Commit

Permalink
fix(model): Add back missing Component.functions on LA/PA
Browse files Browse the repository at this point in the history
27e9986 renamed these attributes, but
did not add deprecated aliases with the old names, which caused some
downstream breakage. This commit adds those aliases with proper
warnings when using them.
  • Loading branch information
Wuestengecko committed Oct 26, 2022
1 parent 8ef9da8 commit 9dcee13
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions capellambse/model/layers/la.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
from __future__ import annotations

import collections.abc as cabc
import operator

from .. import common as c
Expand Down Expand Up @@ -74,6 +75,30 @@ class LogicalComponent(cs.Component):

components: c.Accessor

@property
def functions(self) -> c.ElementList[LogicalFunction]:
import warnings

warnings.warn(
"LogicalComponent.functions is deprecated,"
" use allocated_functions instead",
FutureWarning,
stacklevel=2,
)
return self.allocated_functions

@functions.setter
def functions(self, value: cabc.Iterable[LogicalFunction]) -> None:
import warnings

warnings.warn(
"LogicalComponent.functions is deprecated,"
" use allocated_functions instead",
FutureWarning,
stacklevel=2,
)
self.allocated_functions = value


@c.xtype_handler(XT_ARCH)
class LogicalComponentPkg(c.GenericElement):
Expand Down
25 changes: 25 additions & 0 deletions capellambse/model/layers/pa.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
from __future__ import annotations

import collections.abc as cabc
import operator

from capellambse.loader import xmltools
Expand Down Expand Up @@ -97,6 +98,30 @@ def deployed_components(
def components(self) -> c.ElementList[PhysicalComponent]:
return self.deployed_components + self.owned_components

@property
def functions(self) -> c.ElementList[PhysicalFunction]:
import warnings

warnings.warn(
"LogicalComponent.functions is deprecated,"
" use allocated_functions instead",
FutureWarning,
stacklevel=2,
)
return self.allocated_functions

@functions.setter
def functions(self, value: cabc.Iterable[PhysicalFunction]) -> None:
import warnings

warnings.warn(
"LogicalComponent.functions is deprecated,"
" use allocated_functions instead",
FutureWarning,
stacklevel=2,
)
self.allocated_functions = value


@c.xtype_handler(XT_ARCH)
class PhysicalComponentPkg(c.GenericElement):
Expand Down

0 comments on commit 9dcee13

Please sign in to comment.