File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515file_paths = args .path
1616
1717file_details_list = []
18+ line_count_total = 0
19+ word_count_total = 0
20+ file_size_total = 0
1821
1922# Get file details
2023for file_path in file_paths :
2124 with open (file_path , "r" , encoding = "utf-8" ) as f :
2225 content = f .read ()
2326
2427 details = {
25- "file_path" : file_path ,
26- "file_size" : os .path .getsize (file_path ),
2728 "line_count" : content .count ("\n " ), # matches real wc -l
2829 "word_count" : len (content .split ()), # split on whitespace
30+ "file_size" : os .path .getsize (file_path ),
31+ "file_path" : file_path ,
2932 }
33+ # Update totals
34+ line_count_total += details ["line_count" ]
35+ word_count_total += details ["word_count" ]
36+ file_size_total += details ["file_size" ]
37+ total_path = "Total"
3038
3139 file_details_list .append (details )
3240
33-
34- print (file_details_list )
35-
36- def get_line_count (text ):
37- return text .count ("\n " )
38-
39-
40- def get_word_count (text ):
41- return len (text .split ())
41+ totals_details = {
42+ "line_count" : line_count_total ,
43+ "word_count" : word_count_total ,
44+ "file_size" : file_size_total ,
45+ "file_path" : "total"
46+ }
4247
4348
49+ print (totals_details )
4450
4551show_all = not (args .lines or args .words or args .bytes )
4652
You can’t perform that action at this time.
0 commit comments