File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,16 +118,17 @@ def counter(item):
118118
119119
120120for path in args .paths :
121- with open (path , "r" ) as f :
122- content = f .read ()
123- stats = counter (content )
124- if args .line :
125- print (f"{ stats ['lines' ]} { path } " )
126- elif args .word :
127- print (f"{ stats ['words' ]} { path } " )
128- elif args .char :
129- print (f"{ stats ['characters' ]} { path } " )
130- else :
131- print (f"{ stats ['lines' ]} { stats ['words' ]} { stats ['characters' ]} { path } " )
121+ if os .path .isfile (path ):
122+ with open (path , "r" ) as f :
123+ content = f .read ()
124+ stats = counter (content )
125+ if args .line :
126+ print (f"{ stats ['lines' ]} { path } " )
127+ elif args .word :
128+ print (f"{ stats ['words' ]} { path } " )
129+ elif args .char :
130+ print (f"{ stats ['characters' ]} { path } " )
131+ else :
132+ print (f"{ stats ['lines' ]} { stats ['words' ]} { stats ['characters' ]} { path } " )
132133
133134
You can’t perform that action at this time.
0 commit comments