From 44d85880bed477256ac96925c0d866d2c1282e5a Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Wed, 11 Nov 2020 09:33:15 +0100 Subject: [PATCH] update clang/copyright scripts --- do-clang-format.py | 32 +++++++++++++++++++++++--------- do-copyright.py | 2 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/do-clang-format.py b/do-clang-format.py index 10a04073e..4dc30a1a5 100755 --- a/do-clang-format.py +++ b/do-clang-format.py @@ -8,6 +8,7 @@ import argparse import subprocess as subp import os import sys +import re parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--apply', action="store_true", @@ -17,20 +18,20 @@ parser.add_argument("--all", action="store_true", args = parser.parse_args() -excludeDirs = ["./modules", "./externals", "build", "install", "git"] +excludeDirs = [r"^(\./)?modules/", r"^(\./)?externals/", r"^(\./)?build", r"^(\./)?install", r"(\./)?\.git"] filelist = [] if args.all: for dirpath, dirnames, filenames in os.walk("."): excl = False for excl_dir in excludeDirs: - if excl_dir in dirpath: + if re.findall(excl_dir, dirpath): excl = True break if excl: continue for f in filenames: - if f.endswith(".hpp") or f.endswith(".cpp"): + if (f.endswith(".hpp") or f.endswith(".cpp") or f.endswith(".inl")): filename = os.path.join(dirpath, f) if not os.path.islink(filename): filelist.append(filename) @@ -47,18 +48,31 @@ else: filelist.append(line[1:].lstrip()) cmd = "git ls-files --exclude-standard --others" - filelist += subp.check_output(cmd, shell=True).decode("utf8").strip().split("\n") - filelist = [x for x in filelist - if "./externals" not in x and - "./modules" not in x and - (x.endswith(".hpp") or x.endswith(".cpp"))] + filelist2 = subp.check_output(cmd, shell=True).decode("utf8").strip().split("\n") + filelist += filelist2 + # some cleanup + filelist_clean = [] + for f in filelist: + if not (f.endswith(".hpp") or f.endswith(".cpp") or f.endswith(".inl")): + continue + if os.path.islink(f): + continue + excl = False + for excl_dir in excludeDirs: + if re.findall(excl_dir, f): + excl = True + break + if excl: + continue + filelist_clean.append(f) + filelist = filelist_clean cmd = "clang-format" if "CLANG_FORMAT" in os.environ: cmd = os.environ["CLANG_FORMAT"] cmd += " -style=file" if args.apply: - for filename in filelist: + for filename in filelist: subp.check_call(cmd.split() + ["-i", filename]) else: diff --git a/do-copyright.py b/do-copyright.py index e550f303e..1fb31e082 100755 --- a/do-copyright.py +++ b/do-copyright.py @@ -24,7 +24,7 @@ Debug = 0 excludeDirs = ["./modules", "./externals", "build", "install", "git"] excludeFiles = ['PhysicalConstants.h','CorsikaFenvOSX.cc', 'sgn.h', 'quartic.h'] -extensions = [".cpp", ".hpp"] +extensions = [".cpp", ".inl", ".hpp"] """ justCheck: T: only checking, F: also changing files -- GitLab