[rtems-central commit] items: Add Item.spec_2
Sebastian Huber
sebh at rtems.org
Tue May 9 13:45:27 UTC 2023
Module: rtems-central
Branch: master
Commit: 0fda7921d872dad0da4c70673b98610409f33aff
Changeset: http://git.rtems.org/rtems-central/commit/?id=0fda7921d872dad0da4c70673b98610409f33aff
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri May 5 14:41:19 2023 +0200
items: Add Item.spec_2
---
rtemsspec/items.py | 9 +++++++++
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():
More information about the vc
mailing list