From bd7d36e6b2e480deddb1840e58c400cc802a5f24 Mon Sep 17 00:00:00 2001 From: Tristan van Berkom Date: Mon, 26 May 2025 19:02:01 +0900 Subject: [PATCH] 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 @@ def show_pipeline(self, dependencies, format_): 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 @@ def __init__( 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. #