[rtems-central commit] items: Add Item.spec

Sebastian Huber sebh at rtems.org
Thu Aug 20 14:13:13 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Aug 14 07:23:59 2020 +0200

items: Add Item.spec

---

 rtemsspec/items.py                 | 5 +++++
 rtemsspec/tests/test_items_item.py | 5 +++++
 rtemsspec/validation.py            | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index cdcf451..4da02dd 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -184,6 +184,11 @@ class Item:
         """ Returns the UID of the item. """
         return self._uid
 
+    @property
+    def spec(self) -> str:
+        """ Returns the UID of the item with an URL-like format. """
+        return f"spec:{self._uid}"
+
     def to_abs_uid(self, abs_or_rel_uid: str) -> str:
         """
         Returns the absolute UID of an absolute UID or an UID relative to this
diff --git a/rtemsspec/tests/test_items_item.py b/rtemsspec/tests/test_items_item.py
index 511349a..a388b9b 100644
--- a/rtemsspec/tests/test_items_item.py
+++ b/rtemsspec/tests/test_items_item.py
@@ -44,6 +44,11 @@ def test_uid():
     assert item.uid == "x"
 
 
+def test_spec():
+    item = Item(EmptyItemCache(), "x", {})
+    assert item.spec == "spec:x"
+
+
 def test_contains():
     data = {}
     data["x"] = "y"
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index e37d5a5..dec6999 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -98,7 +98,7 @@ class _TestItem:
     @property
     def name(self) -> str:
         """ Returns the name. """
-        return f"spec:{self._item.uid}"
+        return self._item.spec
 
     @property
     def includes(self) -> List[str]:



More information about the vc mailing list