6
6
"""
7
7
8
8
import argparse
9
- import sys
10
9
11
10
12
11
def parse_args () -> tuple [list [str ], str ]:
13
- parser = argparse .ArgumentParser (description = "Python implementation of the core-utils wc" )
12
+ parser = argparse .ArgumentParser (
13
+ description = "Python implementation of the core-utils wc"
14
+ )
14
15
parser .add_argument ("-l" , "--lines" , action = "store_true" )
15
16
parser .add_argument ("-w" , "--words" , action = "store_true" )
16
17
parser .add_argument ("-c" , "--characters" , action = "store_true" )
@@ -37,7 +38,7 @@ def get_words(content):
37
38
38
39
39
40
def count_characters (content : list [str ]):
40
- words = get_words ()
41
+ words = get_words (content )
41
42
characters = [len (word ) for word in words ]
42
43
return sum (characters )
43
44
@@ -50,14 +51,13 @@ def count_characters(content: list[str]):
50
51
51
52
lines_count = count_lines (lines )
52
53
words_count = count_words (lines )
53
-
54
- characters_count = count_characters ()
54
+ characters_count = count_characters (lines )
55
55
56
56
if args .lines :
57
57
print (lines_count , end = " " )
58
58
if args .words == "-w" :
59
59
print (words_count , end = " " )
60
60
if args .characters == "-c" :
61
61
print (characters_count , end = " " )
62
- if not any (args .lines , args .words , args .characters ):
62
+ if not any (( args .lines , args .words , args .characters ) ):
63
63
print (lines_count , words_count , characters_count )
0 commit comments