[rtems-central commit] items: Remove support for pipe substitution

Sebastian Huber sebh at rtems.org
Fri Oct 1 06:04:12 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Oct  1 07:34:55 2021 +0200

items: Remove support for pipe substitution

---

 rtemsspec/items.py                      | 11 ++++-------
 rtemsspec/tests/test_items_itemcache.py | 21 +++------------------
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index eb26176..d012749 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -416,7 +416,7 @@ class Item:
 
 class ItemTemplate(string.Template):
     """ String template for item mapper identifiers. """
-    idpattern = "[a-zA-Z0-9._/-]+(:[][a-zA-Z0-9._/-]+)?(|[a-zA-Z0-9_]+)*"
+    idpattern = "[a-zA-Z0-9._/-]+(:[][a-zA-Z0-9._/-]+)?"
 
 
 class _ItemMapperContext(dict):
@@ -517,12 +517,11 @@ class ItemMapper:
         Maps an identifier with item and prefix to the corresponding item and
         attribute value.
         """
-        uid_key_path, *pipes = identifier.split("|")
-        colon = uid_key_path.find(":")
+        colon = identifier.find(":")
         if colon >= 0:
-            uid, key_path = uid_key_path[:colon], uid_key_path[colon + 1:]
+            uid, key_path = identifier[:colon], identifier[colon + 1:]
         else:
-            uid, key_path = uid_key_path, "/_uid"
+            uid, key_path = identifier, "/_uid"
         if item is None:
             item = self._item
         if uid == ".":
@@ -544,8 +543,6 @@ class ItemMapper:
             msg = (f"cannot get value for '{key_path}' of {item.spec} "
                    f"specified by '{identifier}'")
             raise ValueError(msg) from err
-        for func in pipes:
-            value = getattr(self, func)(value)
         return item, key_path, value
 
     def __getitem__(self, identifier):
diff --git a/rtemsspec/tests/test_items_itemcache.py b/rtemsspec/tests/test_items_itemcache.py
index 4dc48c0..99f2cf5 100644
--- a/rtemsspec/tests/test_items_itemcache.py
+++ b/rtemsspec/tests/test_items_itemcache.py
@@ -113,27 +113,13 @@ def get_value_dict(ctx):
     return ctx.key
 
 
-class Mapper(ItemMapper):
-    def __init__(self, item):
-        super().__init__(item)
-
-    def u(self, value):
-        return "u" + value
-
-    def v(self, value):
-        return "v" + value
-
-    def dup(self, value):
-        return value + value
-
-
 def test_item_mapper(tmpdir):
     config = create_item_cache_config_and_copy_spec(tmpdir, "spec-item-cache")
     item_cache = ItemCache(config)
     item = item_cache["/p"]
     base_mapper = ItemMapper(item)
     assert base_mapper["d/c:v"] == "c"
-    mapper = Mapper(item)
+    mapper = ItemMapper(item)
     assert mapper.substitute(None) == ""
     assert mapper.substitute(None, prefix="v") == ""
     with mapper.prefix("v"):
@@ -152,11 +138,10 @@ def test_item_mapper(tmpdir):
     assert mapper["d/c"] == "/d/c"
     assert mapper["d/c:v"] == "c"
     assert mapper["d/c:a/b"] == "e"
-    assert mapper["d/c:a/b|u"] == "ue"
     mapper.add_get_value(":/a/x-to-b", get_x_to_b_value)
-    assert mapper["d/c:a/x-to-b|u|v"] == "vue"
+    assert mapper["d/c:a/x-to-b"] == "e"
     assert mapper["d/c:a/f[1]"] == 2
-    assert mapper["d/c:a/../a/f[3]/g[0]|dup"] == 8
+    assert mapper["d/c:a/../a/f[3]/g[0]"] == 4
     item_3, key_path_3, value_3 = mapper.map("/p:/v")
     assert item_3 == item
     assert key_path_3 == "/v"



More information about the vc mailing list