77"""
88
99import argparse
10+ import contextlib
1011import os
1112import pathlib
1213import subprocess
@@ -37,13 +38,16 @@ def __init__(self, *, dry_run=DRY_RUN_DEFAULT):
3738 self .dry_run = dry_run
3839
3940 def progress (self , string ):
40- print ("****** %s" % ( string ,) )
41+ print (f "****** { string } " )
4142
4243 def check (self ):
4344 '''run astyle on all files in self.files_to_check'''
4445 # for path in self.files_to_check:
4546 # self.progress("Checking (%s)" % path)
4647 astyle_command = ["astyle" ]
48+ # Show the astyle version suppressing all exceptions
49+ with contextlib .suppress ():
50+ _ = subprocess .run (astyle_command + ["--version" ])
4751 if self .dry_run :
4852 astyle_command .append ("--dry-run" )
4953
@@ -56,7 +60,7 @@ def check(self):
5660 text = True
5761 )
5862 if ret .returncode != 0 :
59- self .progress ("astyle check failed: (%s)" % ( ret .stdout ) )
63+ self .progress (f "astyle check failed: ({ ret .stdout } )" )
6064 self .retcode = 1
6165 if "Formatted" in ret .stdout :
6266 self .progress ("Files needing formatting found." )
@@ -72,7 +76,7 @@ def run(self):
7276
7377
7478if __name__ == '__main__' :
75- parser = argparse .ArgumentParser (description = 'Check all Python files for astyle cleanliness' )
79+ parser = argparse .ArgumentParser (description = 'Check C and C++ files for astyle cleanliness' )
7680 parser .add_argument ('--dry-run' ,
7781 action = 'store_true' ,
7882 default = DRY_RUN_DEFAULT ,
0 commit comments