summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLembrun <amadeusk7@free.fr>2021-02-26 22:07:08 +0100
committerLembrun <amadeusk7@free.fr>2021-02-26 22:07:08 +0100
commite8b05af233fc9b08901167b8a43c2518ab62aa54 (patch)
tree02b99ced7c9e644c6250a9b77ba0ba5f17aea4f0 /scripts
parentc586dc272f999898833cf58681ece358fc7b438d (diff)
downloadqutebrowser-e8b05af233fc9b08901167b8a43c2518ab62aa54.tar.gz
qutebrowser-e8b05af233fc9b08901167b8a43c2518ab62aa54.zip
Qtbot methods changed to snake case,snake case check added
Diffstat (limited to 'scripts')
-rw-r--r--scripts/dev/misc_checks.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py
index f66081dbf..b06ff84ae 100644
--- a/scripts/dev/misc_checks.py
+++ b/scripts/dev/misc_checks.py
@@ -329,6 +329,81 @@ def check_userscript_shebangs(_args: argparse.Namespace) -> bool:
return ok
+def _check_case_file(path, fobj, patterns):
+ ok = True
+ for num, line in enumerate(fobj, start=1):
+ for pattern, explanation in patterns:
+ if pattern.search(line):
+ ok = False
+ print(f'{path}:{num}: ', end='')
+ utils.print_col(f'Found "{pattern.pattern}" - {explanation}', 'blue')
+ return ok
+
+
+def check_case(args: argparse.Namespace) -> Optional[bool]:
+ """Check if the qtbot methods are in snake case."""
+ patterns = [
+ (
+ re.compile(r'qtbot.addWidget'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.waitActive'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.waitExposed'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.waitForWindowShown'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.waitSignal'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.waitSignals'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.assertNotEmitted'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.waitUntil'),
+ "Snake-case available",
+ ),
+ (
+ re.compile(r'qtbot.waitCallback'),
+ "Snake-case available",
+ )
+ ]
+
+ # Files which should be ignored, e.g. because they come from another
+ # package
+ hint_data = pathlib.Path('tests', 'end2end', 'data', 'hints')
+ ignored = [
+ pathlib.Path('scripts', 'dev', 'misc_checks.py'),
+ pathlib.Path('qutebrowser', '3rdparty', 'pdfjs'),
+ hint_data / 'ace' / 'ace.js',
+ hint_data / 'bootstrap' / 'bootstrap.css',
+ ]
+
+ try:
+ ok = True
+ for path in _get_files(verbose=args.verbose, ignored=ignored):
+ with tokenize.open(str(path)) as f:
+ if not _check_case_file(path, f, patterns):
+ ok = False
+ print()
+ return ok
+ except Exception:
+ traceback.print_exc()
+ return None
+
+
def main() -> int:
checkers = {
'git': check_git,
@@ -337,6 +412,7 @@ def main() -> int:
'userscript-descriptions': check_userscripts_descriptions,
'userscript-shebangs': check_userscript_shebangs,
'changelog-urls': check_changelog_urls,
+ 'snake-case': check_case
}
parser = argparse.ArgumentParser()