@@ -81,6 +81,48 @@ def scan_for_bad_import(file_path, all_pat, good_pats):
81 print("%s: bad import version in multiple lines" % file_path)
81 print("%s: bad import version in multiple lines" % file_path)
82 return bool(errors)
82 return bool(errors)
85+flickable_pat = re.compile(r'.*\ Flickable {')
86+listview_pat = re.compile(r'.*\ ListView {')
87+gridview_pat = re.compile(r'.*\ GridView {')
88+flickable_pats = [flickable_pat, listview_pat, gridview_pat]
89+unity_components_pat = re.compile(r'.*import ".*Components"')
90+components_path = re.compile(r'.*qml/Components.*')
92+def scan_for_flickable_imports(file_path, component_pats, qtquick_pat, uitk_pat):
94+ with open(file_path, 'rt', encoding='utf-8') as ifile, open(file_path, 'rt', encoding='utf-8') as i2file:
95+ flickable_found = False
96+ for lino, line in enumerate(ifile, start=1):
97+ for component_pat in component_pats:
98+ if component_pat.match(line):
99+ flickable_found = True
101+ qtquick_found = False
103+ for lino, line in enumerate(i2file, start=1):
104+ if not qtquick_found and qtquick_pat.match(line):
105+ qtquick_found = True
106+ if uitk_pat.match(line):
108+ if not qtquick_found:
114+ if 0 < len(errors) <= 10:
120+ "%s: bad import version in line%s %s" % (
121+ file_path, plural, ", ".join((str(i) for i in errors))))
123+ print("%s: bad import version in multiple lines" % file_path)
84# Parse args
126# Parse args
86parser = argparse.ArgumentParser(
128parser = argparse.ArgumentParser(
@@ -116,6 +158,9 @@ try:
116 found_bad_import = True
158 found_bad_import = True
117 if scan_for_bad_import(path, ubuntu_components_pat, [ubuntu_good_components_pat]):
159 if scan_for_bad_import(path, ubuntu_components_pat, [ubuntu_good_components_pat]):
118 found_bad_import = True
160 found_bad_import = True
161+ if not components_path.match(path):
162+ if scan_for_flickable_imports(path, flickable_pats, quick_good_pat, unity_components_pat):
163+ found_bad_import = True
120except OSError as e:
165except OSError as e:
121 error("cannot create file list for \"" + dir + "\": " + e.strerror)
166 error("cannot create file list for \"" + dir + "\": " + e.strerror)