diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/lint-ui.py | 18 |
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() |