#!/usr/bin/env python3 import re import sys import subprocess # Run this script through arc lint MESSAGE = "Wrong formatting!" data = subprocess.run( ["clang-format", "--output-replacements-xml", sys.argv[1]], stdout=subprocess.PIPE, check=True).stdout.decode( "utf-8").strip().split("\n") has_error = False for row in data: match = re.match( r"^", row) if match: has_error = True offset = int(match.group(1)) + int(match.group(2)) print("warning:{}:{}".format(offset, MESSAGE)) sys.exit(1 if has_error else 0)