[rtems-central commit] content: Make Content iterable
Sebastian Huber
sebh at rtems.org
Tue Nov 21 13:35:40 UTC 2023
Module: rtems-central
Branch: master
Commit: f32b510da81a7dd0036a2b30a89393bae9b654b1
Changeset: http://git.rtems.org/rtems-central/commit/?id=f32b510da81a7dd0036a2b30a89393bae9b654b1
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Nov 21 11:13:15 2023 +0100
content: Make Content iterable
---
rtemsspec/content.py | 3 +++
rtemsspec/tests/test_content.py | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 9651664e..7e596a2e 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -196,6 +196,9 @@ class Content:
self._empty_line_indent = ""
self._pop_indent_gap = pop_indent_gap
+ def __iter__(self):
+ yield from self._lines
+
def __str__(self):
return "\n".join(itertools.chain(self._lines, [""]))
diff --git a/rtemsspec/tests/test_content.py b/rtemsspec/tests/test_content.py
index 6bc344fa..ad26972e 100644
--- a/rtemsspec/tests/test_content.py
+++ b/rtemsspec/tests/test_content.py
@@ -169,6 +169,13 @@ b c
"""
+def test_iter():
+ content = Content("BSD-2-Clause", True)
+ assert "".join(content) == ""
+ content.add("a")
+ assert "".join(content) == "a"
+
+
def test_paste():
content = Content("BSD-2-Clause", True)
content.paste("")
More information about the vc
mailing list