-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwccn.py
More file actions
executable file
·23 lines (18 loc) · 784 Bytes
/
wccn.py
File metadata and controls
executable file
·23 lines (18 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
# This file is kept for backward compatibility
# The functionality has been moved to the chinese_wordcount package
from chinese_wordcount.counter import count_file, walk
if __name__ == "__main__":
import sys
if len(sys.argv) != 4:
print("usage: python chinese_wc.py [dir] [depth] [appendix]\r\nlike: python chinese_wc.py ~/Documents/org 3 \'.org\'")
else:
dir = sys.argv[1] # directory
depth = int(sys.argv[2])
appendix = sys.argv[3]
print("the directory is: ", dir)
files = walk(dir, depth)
for f in files:
for e in f[2]:
if e.endswith(appendix):
print("{count}\t{filename}".format(filename=f[0]+'/'+e, count=count_file(f[0]+'/'+e)))