From 3ae18b4e8ac615a4150f72630fea64b655b960b9 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 11 Jan 2021 13:04:25 +0000 Subject: add a .ui skeleton script as a base for any mass-conversions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia061e459bcf8b36833013a01fb128b6f8dc8d052 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109094 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- bin/ui-converter-skeleton.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bin/ui-converter-skeleton.py (limited to 'bin') diff --git a/bin/ui-converter-skeleton.py b/bin/ui-converter-skeleton.py new file mode 100755 index 000000000000..e5b651b089c2 --- /dev/null +++ b/bin/ui-converter-skeleton.py @@ -0,0 +1,42 @@ +#!/bin/python +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# this should parse a .ui and overwrite it with the same content +# for a in `git ls-files "*.ui"`; do bin/ui-converter-skeleton.py $a; done + +import lxml.etree as etree +import sys + +with open(sys.argv[1], encoding="utf-8") as f: + header = f.readline() + firstline = f.readline() + # the comment after the xml declaration goes missing unless we provide a + # custom doctype with tostring that contains the comment as a line after + # the true doctype + if firstline.startswith("