From 051ba1e8e1f64e80d8a54adbe0fc0237f2afac78 Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 17 Feb 2026 15:34:33 -0500 Subject: [PATCH 1/2] Add option to specify revision when generating output Signed-off-by: mulhern --- misc_scripts/update_introspection_data.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/misc_scripts/update_introspection_data.py b/misc_scripts/update_introspection_data.py index 8bf7e88..b7f2fe0 100755 --- a/misc_scripts/update_introspection_data.py +++ b/misc_scripts/update_introspection_data.py @@ -23,7 +23,7 @@ import sys import xml.etree.ElementTree as ET from enum import Enum -from typing import List, Mapping, Sequence +from typing import List, Mapping, Optional, Sequence # isort: THIRDPARTY import dbus @@ -179,15 +179,21 @@ def setup_minimal_object_set( } -def _make_python_spec(proxies: Mapping[ProxyType, ProxyObject]) -> dict[str, str]: +def _make_python_spec( + proxies: Mapping[ProxyType, ProxyObject], *, revision_number: Optional[int] = None +) -> dict[str, str]: """ Make the introspection spec for python consumption. """ - revision = ( - f"r{Version(Manager.Properties.Version.Get(proxies[ProxyType.MANAGER])).minor}" + revision_number = ( + Version(Manager.Properties.Version.Get(proxies[ProxyType.MANAGER])).minor + if revision_number is None + else revision_number ) + revision = f"r{revision_number}" + def get_current_interfaces(interface_prefixes: Sequence[str]) -> List[str]: return [f"{prefix}.{revision}" for prefix in interface_prefixes] @@ -259,13 +265,13 @@ def _print_python_spec(specs: Mapping[str, str]): print("}") -def _python_output(_namespace: argparse.Namespace): +def _python_output(namespace: argparse.Namespace): """ Generate python output """ bus = dbus.SystemBus() proxies = setup_minimal_object_set(bus) - specs = _make_python_spec(proxies) + specs = _make_python_spec(proxies, revision_number=namespace.revision_number) _print_python_spec(specs) @@ -357,6 +363,9 @@ def _gen_parser() -> argparse.ArgumentParser: python_parser = subparsers.add_parser( "python", help="Generate introspection data for consumption by Python scripts" ) + python_parser.add_argument( + "--revision-number", help="D-Bus interface revision number", type=int + ) python_parser.set_defaults(func=_python_output) docs_parser = subparsers.add_parser( From 7c4be5f8184c26aa587858360d6374fe6b407fe7 Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 17 Feb 2026 17:19:56 -0500 Subject: [PATCH 2/2] Sort XML objects by tag and name for greater consistency Some D-Bus implementations sort this way, but others do not. Signed-off-by: mulhern --- misc_scripts/update_introspection_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/misc_scripts/update_introspection_data.py b/misc_scripts/update_introspection_data.py index b7f2fe0..a21ce93 100755 --- a/misc_scripts/update_introspection_data.py +++ b/misc_scripts/update_introspection_data.py @@ -115,6 +115,7 @@ def _xml_object_to_str(xml_object: ET.Element) -> str: """ Convert XML object read from D-Bus to a string. """ + xml_object[:] = sorted(xml_object, key=lambda child: (child.tag, child.get("name"))) return ET.tostring(xml_object).decode("utf-8").rstrip(" \n")