There was an error while loading. Please reload this page.
1 parent 0e5e2ee commit 1ea4d3eCopy full SHA for 1ea4d3e
1 file changed
implement-shell-tools/wc/wc.py
@@ -19,17 +19,12 @@
19
totals = {"l": 0, "w": 0, "c": 0}
20
21
for path in args.paths:
22
- try:
23
- if (os.path.isdir(path)):
24
- print(f"wc: {path}: read: Is a directory")
25
- except:
26
- print(f"wc: {path} open: No such file or directory", file=sys.stderr)
27
- file_count += 1
28
- continue
29
-
30
- if (os.path.isfile(path)):
+ if (not os.path.exists(path)):
+ print(f"wc: {path}: open: No such file or directory", file=sys.stderr)
+ elif (os.path.isdir(path)):
+ print(f"wc: {path}: read: Is a directory")
+ elif (os.path.isfile(path)):
31
output_str = ""
32
33
with open(path, "r", encoding="utf-8") as file:
34
lines = file.readlines()
35
0 commit comments