[rtems-central commit] items: Add Link.__setitem__()

Sebastian Huber sebh at rtems.org
Wed Oct 28 13:15:50 UTC 2020


Module:    rtems-central
Branch:    master
Commit:    30b294cb6c574d9a7250c548280f8838137814d1
Changeset: http://git.rtems.org/rtems-central/commit/?id=30b294cb6c574d9a7250c548280f8838137814d1

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Oct 28 14:14:45 2020 +0100

items: Add Link.__setitem__()

---

 rtemsspec/items.py                 | 3 +++
 rtemsspec/tests/test_items_item.py | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index 84fca2a..6e87245 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -112,6 +112,9 @@ class Link:
     def __getitem__(self, name: str) -> Any:
         return self._data[name]
 
+    def __setitem__(self, key: str, value: Any) -> None:
+        self._data[key] = value
+
     @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 e84ce27..f2a137d 100644
--- a/rtemsspec/tests/test_items_item.py
+++ b/rtemsspec/tests/test_items_item.py
@@ -173,6 +173,8 @@ def test_parents():
     child.init_parents(item_cache)
     for link in child.links_to_parents():
         link.item.add_link_to_child(Link.create(link, child))
+        link["foo"] = "bar"
+    assert child["links"][0]["foo"] == "bar"
     parents = [item for item in child.parents()]
     assert len(parents) == 1
     assert parents[0] == parent



More information about the vc mailing list