From 47120f4157603acc337917f8baee9e126a613ec7 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Mon, 9 Dec 2019 20:35:48 +0100 Subject: [PATCH] scripts/qsscheck: Also check default stylesheets --- scripts/qsscheck.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/scripts/qsscheck.py b/scripts/qsscheck.py index c0d33181521..e23b3ba3d1c 100755 --- a/scripts/qsscheck.py +++ b/scripts/qsscheck.py @@ -66,13 +66,13 @@ def get_skin_objectnames(skin_path): yield from RE_XML_OBJNAME_SETVAR.findall(line) -def get_skin_stylesheets(skin_path): - """Yields (qss_path, stylesheet) tuples for each qss file in skin_path).""" +def get_stylesheets(path): + """Yields (qss_path, stylesheet) tuples for each qss file in path).""" cssparser = tinycss.css21.CSS21Parser() - for filename in os.listdir(skin_path): + for filename in os.listdir(path): if os.path.splitext(filename)[1] != '.qss': continue - qss_path = os.path.join(skin_path, filename) + qss_path = os.path.join(path, filename) stylesheet = cssparser.parse_stylesheet_file(qss_path) yield qss_path, stylesheet @@ -112,6 +112,25 @@ def check_skins(mixxx_path, skins, ignore_patterns=()): object names (e.g. #Test, #*Debug). """ classnames, objectnames = get_global_names(mixxx_path) + + # Check default stylesheets + default_styles_path = os.path.join(mixxx_path, 'res', 'skins') + for qss_path, stylesheet in get_stylesheets(default_styles_path): + for error in stylesheet.errors: + yield '%s:%d:%d: %s - %s' % ( + qss_path, error.line, error.column, + error.__class__.__name__, error.reason, + ) + for token, message in check_stylesheet( + stylesheet, classnames, objectnames, []): + if any(fnmatch.fnmatchcase(token.value, pattern) + for pattern in ignore_patterns): + continue + yield '%s:%d:%d: %s' % ( + qss_path, token.line, token.column, message, + ) + + # Check skin stylesheets for skin_name, skin_path in sorted(skins): # If the skin objectname is something like 'Deck', # then replace it with 'Deck*' and use glob-like matching @@ -124,7 +143,7 @@ def check_skins(mixxx_path, skins, ignore_patterns=()): else: skin_objectnames.add(new_objname) - for qss_path, stylesheet in get_skin_stylesheets(skin_path): + for qss_path, stylesheet in get_stylesheets(skin_path): for error in stylesheet.errors: yield '%s:%d:%d: %s - %s' % ( qss_path, error.line, error.column,