[rtems-central commit] glossary: Use ItemMapper.add_get_value()

Sebastian Huber sebh at rtems.org
Tue Dec 1 13:38:26 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Dec  1 13:23:45 2020 +0100

glossary: Use ItemMapper.add_get_value()

---

 rtemsspec/glossary.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/rtemsspec/glossary.py b/rtemsspec/glossary.py
index 21a39e8..64fcbc6 100644
--- a/rtemsspec/glossary.py
+++ b/rtemsspec/glossary.py
@@ -87,14 +87,14 @@ class _GlossaryMapper(ItemMapper):
     def __init__(self, item: Item, document_terms: ItemMap):
         super().__init__(item)
         self._document_terms = document_terms
-
-    def get_value(self, ctx: ItemGetValueContext) -> Any:
-        """ Recursively adds glossary terms to the document terms. """
-        if ctx.type_path_key == "glossary/term:/term":
-            if ctx.item.uid not in self._document_terms:
-                self._document_terms[ctx.item.uid] = ctx.item
-                _GlossaryMapper(ctx.item, self._document_terms).substitute(
-                    ctx.item["text"])
+        self.add_get_value("glossary/term:/term", self._add_to_terms)
+        self.add_get_value("glossary/term:/plural", self._add_to_terms)
+
+    def _add_to_terms(self, ctx: ItemGetValueContext) -> Any:
+        if ctx.item.uid not in self._document_terms:
+            self._document_terms[ctx.item.uid] = ctx.item
+            _GlossaryMapper(ctx.item,
+                            self._document_terms).substitute(ctx.item["text"])
         # The value of this substitute is unused.
         return ""
 



More information about the vc mailing list