forked from kfrlib/kfr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format-all.py
34 lines (27 loc) · 956 Bytes
/
format-all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
from __future__ import print_function
import fnmatch
import os
import subprocess
import sys
import glob
path = os.path.dirname(os.path.realpath(__file__))
masks = ['*.hpp', '*.h', '*.cpp', '*.c', '*.cxx']
ignore = ['build/*', 'build-*', 'cmake-*', '.*', 'include/kfr/io/dr']
filenames = []
for root, dirnames, files in os.walk(path, path):
ignore_dir = False
for mask in ignore:
if fnmatch.fnmatch(os.path.relpath(root, path), mask):
ignore_dir = True
break
if not ignore_dir:
for mask in masks:
for filename in fnmatch.filter(files, mask):
filenames.append(os.path.join(root, filename))
for filename in filenames:
print( filename, '...' )
subprocess.call(['clang-format', '-i', filename])
# Fix clang-format bug: https://llvm.org/bugs/show_bug.cgi?id=26125
for tmp_file in glob.glob(filename+'*.tmp'):
os.remove(tmp_file)