Kaydet (Commit) b4a224d1 authored tarafından Rosemary's avatar Rosemary Kaydeden (comit) Caolán McNamara

tdf#80387 Extended lint-ui.py to check for UI title labels

Change-Id: I47ab882b0d54711050da4fc8fa288b195949eb60
Reviewed-on: https://gerrit.libreoffice.org/16425Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 3f4978f8
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment