forked from u-blox/ubxlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastyle.py
23 lines (19 loc) · 817 Bytes
/
astyle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
'''Run AStyle on all code.'''
# Run this from the ubxlib root directory to run AStyle, which must be on the path,
# on all relevant files in the ubxlib directory tree, using the standard ubxlib astyle.cfg
import subprocess
import sys
with subprocess.Popen(["astyle", "--options=astyle.cfg", "--suffix=none", "--verbose",
"--errors-to-stdout", "--recursive", "*.c,*.h,*.cpp,*.hpp"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True) as astyle:
fail = False
output, _ = astyle.communicate()
for line in output.splitlines():
if line.startswith("Formatted"):
fail = True
print (line)
if astyle.returncode != 0:
fail = True
sys.exit(1 if fail else 0)