subprocess.call([clangFormatBinary, '-style=file', inputFilename], stdout=outfile, shell=True) nkt.setup() # we need to set pwd in order for clang-format to find the .clang-format file! os.chdir(nkt.getNetworKitRoot()) numberNonCompliant = 0 numberFileSkipped = 0 clangFormatCommand = findClangFormat() with tempfile.TemporaryDirectory(dir=nkt.getNetworKitRoot()) as tempDir: files = nkt.getCXXFiles() for file in files: if not subscribedToFormat(file): numberFileSkipped += 1 continue tempFile = os.path.join(tempDir, 'cfOutput') runClangFormat(file, tempFile, clangFormatCommand) if not filecmp.cmp(file, tempFile, shallow=False): numberNonCompliant += 1 nkt.reportChange(file + " is non-compliant") if nkt.doReportDiff(): nkt.computeAndReportDiff(file, tempFile)
""" This tool iterates over all C++ files and replaces tab-based indentation with spaces (tabwidth = 4). If used in read-only mode it returns a negative exit code if a change is necessary. """ import nktooling as nkt import re import os, sys nkt.setup() numScannedFiled = 0 numNoncompliantFiles = 0 numIllegalFiles = 0 files = nkt.getCXXFiles(includeSources=False) includePragmaOnce = False rePragmaOnce = re.compile("#pragma\s+once$") for file in files: if "/ext/" in file: continue numScannedFiled += 1 # compute new include guard name newGuard = os.path.relpath(file, os.path.join(nkt.getNetworKitRoot(), "include")) newGuard = re.sub("include/", "", newGuard)