File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -24,11 +24,11 @@ def main():
2424 totals = {"lines" : 0 , "words" : 0 , "chars" : 0 }
2525
2626 no_flags = not args .l and not args .w and not args .c
27- width = 7
27+ width = 8
2828
2929 def format_output (counts , label ):
3030 if no_flags :
31- return f"{ counts ['lines' ]:> {width }} { counts ['words' ]:>{width }} { counts ['chars' ]:>{width }} { label } "
31+ return f"{ counts ['lines' ]:>{width }} { counts ['words' ]:>{width }} { counts ['chars' ]:>{width }} { label } "
3232
3333 parts = []
3434 if args .l :
@@ -46,7 +46,7 @@ def format_output(counts, label):
4646 with open (file_path , "rb" ) as f :
4747 data = f .read ()
4848 except OSError as err :
49- print (f"wc: cannot read file'{ file_path } ': { err } " , file = sys .stderr )
49+ print (f"wc: cannot read file' { file_path } ': { err } " , file = sys .stderr )
5050 had_error = True
5151 continue
5252
@@ -67,12 +67,9 @@ def format_output(counts, label):
6767 print (format_output (counts , file_path ))
6868
6969 if len (args .paths ) > 1 :
70- no_flags = not args . l and not args . w and not args . c
70+ print ( format_output ( totals , "total" ))
7171
72- if no_flags :
73- print (format_output (totals , "total" ))
74-
75- sys .exit (1 if had_error else 0 )
72+ sys .exit (1 if had_error else 0 )
7673
7774if __name__ == "__main__" :
7875 main ()
You can’t perform that action at this time.
0 commit comments