Created
April 3, 2025 18:01
-
-
Save adithya2306/c351e8e2d5818c512c3be1a66b5146a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
SPDX-FileCopyrightText: 2025 Adithya R | |
SPDX-License-Identifier: MIT | |
""" | |
import sys | |
import xml.etree.ElementTree as ET | |
if len(sys.argv) < 3: | |
print("Usage:\n\t./merge-carrierconfig.py <cc1.xml> <cc2.xml> [<ccN.xml>]") | |
sys.exit(1) | |
cc_main_root = ET.Element("carrier_config_list") | |
cc_main = ET.ElementTree(cc_main_root) | |
cc_xmls = sys.argv[1:] | |
for cc in cc_xmls: | |
cc_root = ET.parse(cc).getroot() | |
cc_main_root.append(ET.Comment(f"BEGIN {cc}")) | |
for elem in cc_root.findall("carrier_config"): | |
cc_main_root.append(elem) | |
cc_main_root.append(ET.Comment(f"END {cc}")) | |
cc_main_root.insert(0, ET.Comment(f"Autogenerated from {', '.join(cc_xmls)}")) | |
ET.indent(cc_main_root) | |
cc_main.write("merged_carrier_config.xml", encoding="utf-8", xml_declaration=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment