From be29e385d39c1dce1f9516225ffb9e251895d751 Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Sat, 31 Oct 2020 02:20:04 +0800 Subject: update for C & multiple files uploading & code review checking --- util.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'util.py') diff --git a/util.py b/util.py index 76cb182..e1dd9af 100644 --- a/util.py +++ b/util.py @@ -1,4 +1,6 @@ +import subprocess import logging +import os import re @@ -39,7 +41,26 @@ def getProjRepoName(arg): def passCodeQuality(path, language): - with open(path, encoding='utf-8', errors='replace') as f: - res = f.read() if language == "matlab": - return "global " not in res \ No newline at end of file + with open(path, encoding='utf-8', errors='replace') as f: + res = f.read() + return "global " not in res + if language == "c": + res = subprocess.check_output( + ["ctags", "-R", "-x", "--sort=yes", "--c-kinds=v", path]) + lines = res.splitlines() + return len([line for line in lines if b"const" not in line]) == 0 + + +def getAllFiles(root): + for f in os.listdir(root): + if os.path.isfile(os.path.join(root, f)): + yield os.path.join(f) + dirs = [ + d for d in os.listdir(root) + if os.path.isdir(os.path.join(root, d)) and d != ".git" + ] + for d in dirs: + dirfiles = getAllFiles(os.path.join(root, d)) + for f in dirfiles: + yield os.path.join(d, f) -- cgit v1.2.3