summaryrefslogtreecommitdiffstats
path: root/bin/check-autocorr.py
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2023-01-03 20:55:54 +0000
committerCaolán McNamara <caolanm@redhat.com>2023-01-05 09:56:48 +0000
commit8549d6e26f5116b1fcf5e066252cc987a3f2574f (patch)
tree618d5251271f982f1079572c8071da98b8b18c15 /bin/check-autocorr.py
parentexternal/icu: Fix intermittent cross build failure (diff)
downloadcore-8549d6e26f5116b1fcf5e066252cc987a3f2574f.tar.gz
core-8549d6e26f5116b1fcf5e066252cc987a3f2574f.zip
Related: tdf#150687 check autocorr DocumentList.xml at build time
to ensure no noopt entries exist Change-Id: I9fb95e211d6030e1f551558fd5a0a3ca700c8fc2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145030 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'bin/check-autocorr.py')
-rwxr-xr-xbin/check-autocorr.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/check-autocorr.py b/bin/check-autocorr.py
new file mode 100755
index 000000000000..ebf1b50b1911
--- /dev/null
+++ b/bin/check-autocorr.py
@@ -0,0 +1,39 @@
+#!/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: ./bin/check-autocorr.py extras/source/autocorr/lang/tr/DocumentList.xml
+
+import sys
+import os
+import xml.etree.ElementTree as ET
+
+complete_file = sys.argv[1]
+
+bAllFilesOk = True
+
+# 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)