summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRosemary <rosemaryseb8@gmail.com>2015-06-23 14:34:06 +0530
committerCaolán McNamara <caolanm@redhat.com>2015-06-25 13:29:05 +0000
commitb4a224d1a91232a16b70be4531a3e6fd2d9bc9ae (patch)
tree77587c0899ca5271a88afa6739f48b445a016065 /bin
parent3f4978f8c660c595773c92b99d45d0631cac04b0 (diff)
tdf#80387 Extended lint-ui.py to check for UI title labels
Change-Id: I47ab882b0d54711050da4fc8fa288b195949eb60 Reviewed-on: https://gerrit.libreoffice.org/16425 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lint-ui.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/lint-ui.py b/bin/lint-ui.py
index 54e1d27fb19e..2ed80c2523fb 100755
--- a/bin/lint-ui.py
+++ b/bin/lint-ui.py
@@ -11,6 +11,7 @@
import sys
import xml.etree.ElementTree as ET
+import re
DEFAULT_WARNING_STR = 'Lint assertion failed'
@@ -23,6 +24,8 @@ ALIGNMENT_TOP_PADDING = '6'
MESSAGE_BOX_SPACING = '24'
MESSAGE_BORDER_WIDTH = '12'
+IGNORED_WORDS = ['the', 'of', 'to', 'for', 'a', 'and', 'as', 'from', 'on', 'into', 'by', 'at', 'or', 'do', 'in', 'when']
+
def lint_assert(predicate, warning=DEFAULT_WARNING_STR):
if not predicate:
print(" * " + warning)
@@ -77,6 +80,19 @@ def check_alignment_top_padding(alignment):
lint_assert(top_padding.text == ALIGNMENT_TOP_PADDING,
"GtkAlignment 'top_padding' should be " + ALIGNMENT_TOP_PADDING)
+def check_title_labels(root):
+ labels = root.findall(".//child[@type='label']")
+ titles = [label.find(".//property[@name='label']") for label in labels]
+ for title in titles:
+ if title is None:
+ continue
+ words = re.split(r'[^a-zA-Z0-9_-]', title.text)
+ first = True
+ for word in words:
+ if word[0].islower() and (word not in IGNORED_WORDS or first):
+ lint_assert(False, "The word '" + word + "' should be capitalized")
+ first = False
+
def main():
print(" == " + sys.argv[1] + " ==")
tree = ET.parse(sys.argv[1])
@@ -102,5 +118,7 @@ def main():
check_frames(root)
+ check_title_labels(root)
+
if __name__ == "__main__":
main()