diff options
author | BoYanZh <bomingzh@sjtu.edu.cn> | 2020-10-31 02:20:04 +0800 |
---|---|---|
committer | BoYanZh <bomingzh@sjtu.edu.cn> | 2020-10-31 02:20:04 +0800 |
commit | be29e385d39c1dce1f9516225ffb9e251895d751 (patch) | |
tree | d18d407e9b5ccbf8d9fcfadd054c4bbc7c99ee37 /util.py | |
parent | 13f7ad085c7089b896aa2d42c068d05124b2cde7 (diff) |
update for C & multiple files uploading & code review checking
Diffstat (limited to 'util.py')
-rw-r--r-- | util.py | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -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) |