diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-05-05 14:41:19 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-05-08 21:58:56 +0200 |
commit | 0fda7921d872dad0da4c70673b98610409f33aff (patch) | |
tree | 28d858ef431e7520a4ba8690a253a408718281cb | |
parent | spec: Fix typo (diff) | |
download | rtems-central-0fda7921d872dad0da4c70673b98610409f33aff.tar.bz2 |
items: Add Item.spec_2
-rw-r--r-- | rtemsspec/items.py | 9 | ||||
-rw-r--r-- | rtemsspec/tests/test_items_item.py | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/rtemsspec/items.py b/rtemsspec/items.py index 00960bbf..6594ae9b 100644 --- a/rtemsspec/items.py +++ b/rtemsspec/items.py @@ -264,6 +264,15 @@ class Item: """ Returns the UID of the item with an URL-like format. """ return f"spec:{self._uid}" + @property + def spec_2(self) -> str: + """ + Returns the UID of the item with an URL-like format with invisible + white space to allow line breaks. + """ + uid = self._uid.replace("/", "/\u200b") + return f"spec:{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 efbe4b7d..2670b172 100644 --- a/rtemsspec/tests/test_items_item.py +++ b/rtemsspec/tests/test_items_item.py @@ -67,8 +67,9 @@ def test_uid(): def test_spec(): - item = Item(EmptyItemCache(), "x", {}) - assert item.spec == "spec:x" + item = Item(EmptyItemCache(), "x/y/z", {}) + assert item.spec == "spec:x/y/z" + assert item.spec_2 == "spec:x/\u200by/\u200bz" def test_contains(): |