From 13e7f92f723cd9d95d88b92e640a37ade9afc86e Mon Sep 17 00:00:00 2001 From: Jyotiraditya Panda Date: Thu, 12 Sep 2024 18:47:15 +0530 Subject: [PATCH] roomservice: Use ElementTree.write() write() handles XML conversion and file writing internally. The xml_declaration=True parameter adds the XML header automatically, eliminating the need for manual string manipulation Change-Id: Ib8c3fe33e60accad05572c5af0f0b90866a219d9 Signed-off-by: Jyotiraditya Panda --- build/tools/roomservice.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index bc860cae..9a2ba14a 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -192,12 +192,8 @@ def add_to_manifest(repositories): lm.append(project) ElementTree.indent(lm) - raw_xml = ElementTree.tostring(lm).decode() - raw_xml = '\n' + raw_xml - - f = open('.repo/local_manifests/roomservice.xml', 'w') - f.write(raw_xml) - f.close() + tree = ElementTree.ElementTree(lm) + tree.write('.repo/local_manifests/roomservice.xml', encoding='UTF-8', xml_declaration=True) def fetch_dependencies(repo_path): print('Looking for dependencies in %s' % repo_path)