summaryrefslogtreecommitdiff
path: root/rtemsspec
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-21 11:13:15 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-21 11:15:24 +0100
commit46d720f4ef15278bf82078d52996c712f949a33d (patch)
tree26f949d8a6ad019d6f44111da6ce1921145cd714 /rtemsspec
parent93a268baa1f00f2a7f182b414a8e61bee78c8ffb (diff)
items: Add Link order
Diffstat (limited to 'rtemsspec')
-rw-r--r--rtemsspec/items.py6
-rw-r--r--rtemsspec/tests/test_items_item.py3
2 files changed, 9 insertions, 0 deletions
diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index 4b0d2600..30af77f3 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -133,6 +133,12 @@ class Link:
def __setitem__(self, key: str, value: Any) -> None:
self._data[key] = value
+ def __lt__(self, other: Any) -> bool:
+ if not isinstance(other, Link):
+ return NotImplemented
+ # pylint: disable=protected-access
+ return self._item.uid < other._item.uid
+
@property
def item(self) -> "Item":
""" The item referenced by this link. """
diff --git a/rtemsspec/tests/test_items_item.py b/rtemsspec/tests/test_items_item.py
index 1f107e56..8208bb9c 100644
--- a/rtemsspec/tests/test_items_item.py
+++ b/rtemsspec/tests/test_items_item.py
@@ -154,6 +154,9 @@ def test_children():
assert len(children) == 0
links = [link for link in parent.links_to_children()]
assert len(links) == 1
+ assert not links[0] < links[0]
+ with pytest.raises(TypeError):
+ links[0] < 0
assert links[0].item == child
assert links[0]["a"] == "b"
assert links[0].role == "c"