diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2023-01-01 18:08:49 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-03 20:33:52 +0000 |
commit | c95f7c6bf705ea84e1f8da40042b382189e7179a (patch) | |
tree | 1e99477e36fd54db1606f7112aba55a0e6b3c8c1 /bin | |
parent | 601a2d3b09fdf4332b257f2c0ebd01e19e47887f (diff) |
Add script to check DocumentList.xml in autocorrect
Change-Id: I4c2d356c900ce7bde43d8e06af2fdda4f66c15ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144925
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/find-autocorr-samevalue-beforeafter.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/find-autocorr-samevalue-beforeafter.py b/bin/find-autocorr-samevalue-beforeafter.py new file mode 100755 index 000000000000..7116100bdb87 --- /dev/null +++ b/bin/find-autocorr-samevalue-beforeafter.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +# 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/. + +# Use this script to find the lines in extras/source/autocorr/lang/<language>/DocumentList.xml +# which contain the same value for abbreviated-name and name +# Usage sample: ./find-autocorr-samevalue-beforeafter.py + +import os +import xml.etree.ElementTree as ET + +root_dir = '../extras/source/autocorr/lang' + +bAllFilesOk = True + +for root, dirs, files in os.walk(root_dir): + for file in files: + + # just deal with DocumentList.xml, ignore the other files + if (file != "DocumentList.xml"): + continue + complete_file = os.path.join(str(root), file) + # parse the XML file + tree = ET.parse(complete_file) + root = tree.getroot() + + # find all elements X + elements_x = root.findall('.//block-list:block', namespaces={'block-list': "http://openoffice.org/2001/block-list"}) + for element in elements_x: + # get the value of the attribute "abbreviated-name" + value_a = element.get('{http://openoffice.org/2001/block-list}abbreviated-name') + # get the value of the attribute "name" + value_b = element.get('{http://openoffice.org/2001/block-list}name') + # check if the values are equal + if value_a == value_b: + print('In ' + complete_file + ' same value: ' + value_a) + bAllFilesOk = False + +if bAllFilesOk == True: + exit(0) +exit(1) |