This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/public-source-info-serialize
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit bd7d36e6b2e480deddb1840e58c400cc802a5f24
Author: Tristan van Berkom <[email protected]>
AuthorDate: Mon May 26 19:02:01 2025 +0900

    source.py: Make SourceInfo.serialize() a public API.
    
    This will output a normalized dictionary suitable for serialization
    into formats like json or yaml.
    
    Also updated caller in _frontend/widget.py.
---
 src/buildstream/_frontend/widget.py |  2 +-
 src/buildstream/source.py           | 14 ++++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/buildstream/_frontend/widget.py 
b/src/buildstream/_frontend/widget.py
index f2607fee9..6c15f7263 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -453,7 +453,7 @@ class LogLine(Widget):
 
                     serialized_sources = []
                     for s in source_infos:
-                        serialized = s._serialize()
+                        serialized = s.serialize()
                         serialized_sources.append(serialized)
 
                     all_source_infos += serialized_sources
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 23b8a9444..21d060a86 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -587,14 +587,12 @@ class SourceInfo:
         Additional plugin defined key/values
         """
 
-    # _serialize()
-    #
-    # Produce a dictionary object suitable to be dumped in YAML format
-    # in the `bst show` command line interface.
-    #
-    # Returns: A dictionary used to dump this out on the CLI with 
_yaml.roundtrip_dump_string()
-    #
-    def _serialize(self) -> Dict[str, Any]:
+    def serialize(self) -> Dict[str, Union[str, Dict[str, str]]]:
+        """Produce a dictionary object suitable for serialization into formats 
like json or yaml.
+
+        Returns: A dictionary object with strings as keys and values, except 
for the
+                 extra_data which, if present, is also a dictionary with 
strings as keys and values.
+        """
         #
         # WARNING: This return value produces output for an API stable 
interface.
         #

Reply via email to