Skip to content

Commit 85ee312

Browse files
committed
refactored
1 parent 84192ba commit 85ee312

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

  • implement-shell-tools/wc

‎implement-shell-tools/wc/wc.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ def read_file(file_name):
6161

6262

6363
def calculate_line_count(text):
64-
if not text:
65-
return 0
6664
return len(text.splitlines())
6765

6866

@@ -93,12 +91,12 @@ def add_totals(all_files_data):
9391

9492
# ===== Outputting Data =====
9593
def print_output(output_data):
94+
active_metrics = displayed_metrics or metrics
9695
for file in output_data:
9796
output_string = ""
9897

99-
for metric in metrics:
100-
if not displayed_metrics or metric in displayed_metrics:
101-
output_string += str(file[metric]).rjust(8)
98+
for metric in active_metrics:
99+
output_string += str(file[metric]).rjust(8)
102100

103101
output_string += f" {file['name']}"
104102
print(output_string)

0 commit comments

Comments
 (0)