From d618e88bcb7069481c55318fff88de2417582b25 Mon Sep 17 00:00:00 2001 From: Silas Kraume Date: Thu, 15 Feb 2024 21:03:24 +0100 Subject: [PATCH] renamed Count to Sum --- cat_win/cat.py | 22 +++++++++++----------- cat_win/const/argconstants.py | 8 ++++---- cat_win/tests/test_full.py | 2 +- cat_win/util/holder.py | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cat_win/cat.py b/cat_win/cat.py index 7b140f04..24b57323 100644 --- a/cat_win/cat.py +++ b/cat_win/cat.py @@ -17,13 +17,13 @@ from cat_win.const.argconstants import ALL_ARGS, ARGS_EDITOR, ARGS_WORDCOUNT, ARGS_WWORDCOUNT from cat_win.const.argconstants import ARGS_HELP, ARGS_NUMBER, ARGS_ENDS, ARGS_SQUEEZE -from cat_win.const.argconstants import ARGS_REVERSE, ARGS_COUNT, ARGS_BLANK, ARGS_FILES +from cat_win.const.argconstants import ARGS_REVERSE, ARGS_SUM, ARGS_BLANK, ARGS_FILES from cat_win.const.argconstants import ARGS_INTERACTIVE, ARGS_NOCOL, ARGS_BINVIEW, ARGS_FILE_PREFIX from cat_win.const.argconstants import ARGS_CLIP, ARGS_CHECKSUM, ARGS_DEC, ARGS_HEX, ARGS_BIN from cat_win.const.argconstants import ARGS_VERSION, ARGS_DEBUG, ARGS_CUT, ARGS_REPLACE, ARGS_DATA from cat_win.const.argconstants import ARGS_CCONFIG, ARGS_LLENGTH, ARGS_ONELINE, ARGS_PEEK from cat_win.const.argconstants import ARGS_CHR, ARGS_B64E, ARGS_B64D, ARGS_FFILES, ARGS_GREP -from cat_win.const.argconstants import ARGS_NOBREAK, ARGS_ECHO, ARGS_CCOUNT, ARGS_HEXVIEW +from cat_win.const.argconstants import ARGS_NOBREAK, ARGS_ECHO, ARGS_SSUM, ARGS_HEXVIEW from cat_win.const.argconstants import ARGS_NOKEYWORD, ARGS_RECONFIGURE, ARGS_RECONFIGURE_IN from cat_win.const.argconstants import ARGS_RECONFIGURE_OUT, ARGS_RECONFIGURE_ERR, ARGS_CONFIG from cat_win.const.argconstants import ARGS_EVAL, ARGS_SORT, ARGS_GREP_ONLY, ARGS_PLAIN_ONLY @@ -248,16 +248,16 @@ def _show_wordcount() -> None: print(color_dic[CKW.RESET_ALL]) -def _show_count() -> None: +def _show_sum() -> None: """ display the line sum of each file individually if - ARGS_CCOUNT is specified. + ARGS_SSUM is specified. display the line sum of all files. """ - if holder.args_id[ARGS_CCOUNT]: + if holder.args_id[ARGS_SSUM]: longest_file_name = max(map(len, holder.all_files_lines.keys())) + 1 - print(f"{color_dic[CKW.SUMMARY]}" + \ - f"{'File': <{longest_file_name}}LineCount{color_dic[CKW.RESET_ALL]}") + print(f"{color_dic[CKW.SUMMARY]}{'File': <{longest_file_name}}{color_dic[CKW.RESET_ALL]}" + f"{color_dic[CKW.SUMMARY]}LineCount{color_dic[CKW.RESET_ALL]}") for file, _ in holder.all_files_lines.items(): print(f"{color_dic[CKW.SUMMARY]}{file: <{longest_file_name}}" + \ f"{holder.all_files_lines[file]: >{holder.all_line_number_place_holder}}" + \ @@ -967,9 +967,9 @@ def edit_files() -> None: if holder.args_id[ARGS_WORDCOUNT]: print('') _show_wordcount() - if holder.args_id[ARGS_COUNT]: + if holder.args_id[ARGS_SUM]: print('') - _show_count() + _show_sum() if holder.args_id[ARGS_FILES]: print('') _show_files() @@ -1163,8 +1163,8 @@ def main(): [tmp_file_helper.generate_temp_file_name() for _ in holder.files]) holder.generate_values(arg_parser.file_encoding) - if holder.args_id[ARGS_CCOUNT]: - _show_count() + if holder.args_id[ARGS_SSUM]: + _show_sum() return if holder.args_id[ARGS_WWORDCOUNT]: _show_wordcount() diff --git a/cat_win/const/argconstants.py b/cat_win/const/argconstants.py index d8cae517..40b977f5 100644 --- a/cat_win/const/argconstants.py +++ b/cat_win/const/argconstants.py @@ -19,12 +19,12 @@ def __init__(self, short_form: str, long_form: str, arg_help: str, arg_id: int, ARGS_HELP, ARGS_NUMBER, ARGS_ENDS, ARGS_EDITOR, ARGS_SQUEEZE = range(0, 5) -ARGS_REVERSE, ARGS_COUNT, ARGS_BLANK, ARGS_FILES, ARGS_INTERACTIVE = range(5, 10) +ARGS_REVERSE, ARGS_SUM, ARGS_BLANK, ARGS_FILES, ARGS_INTERACTIVE = range(5, 10) ARGS_CLIP, ARGS_CHECKSUM, ARGS_DEC, ARGS_HEX, ARGS_BIN = range(10, 15) ARGS_VERSION, ARGS_DEBUG, ARGS_CUT, ARGS_REPLACE, ARGS_DATA = range(15, 20) ARGS_CCONFIG, ARGS_LLENGTH, ARGS_ONELINE, ARGS_PEEK, ARGS_NOCOL = range(20, 25) ARGS_CHR, ARGS_B64E, ARGS_B64D, ARGS_FFILES, ARGS_GREP = range(25, 30) -ARGS_NOBREAK, ARGS_ECHO, ARGS_CCOUNT, ARGS_HEXVIEW, ARGS_BINVIEW = range(30, 35) +ARGS_NOBREAK, ARGS_ECHO, ARGS_SSUM, ARGS_HEXVIEW, ARGS_BINVIEW = range(30, 35) ARGS_NOKEYWORD, ARGS_RECONFIGURE, ARGS_RECONFIGURE_IN = range(35, 38) ARGS_RECONFIGURE_OUT, ARGS_RECONFIGURE_ERR = range(38, 40) ARGS_EVAL, ARGS_SORT, ARGS_GREP_ONLY, ARGS_PLAIN_ONLY, ARGS_FILE_PREFIX = range(40, 45) @@ -92,9 +92,9 @@ def __init__(self, short_form: str, long_form: str, arg_help: str, arg_id: int, ArgConstant('-D', '--DIRS', 'ONLY list found directories', ARGS_DDIRECTORIES, show_arg=False, section=5), ArgConstant('-s', '--sum', 'show sum of lines', - ARGS_COUNT, show_arg_on_shell=False, section=5), + ARGS_SUM, show_arg_on_shell=False, section=5), ArgConstant('-S', '--SUM', 'ONLY show sum of lines', - ARGS_CCOUNT, show_arg=False, section=5), + ARGS_SSUM, show_arg=False, section=5), ArgConstant('-w', '--wordcount', 'display the wordcount', ARGS_WORDCOUNT, show_arg_on_shell=False, section=5), ArgConstant('-W', '--WORDCOUNT', 'ONLY display the wordcount', diff --git a/cat_win/tests/test_full.py b/cat_win/tests/test_full.py index bed21e8f..29ec2649 100644 --- a/cat_win/tests/test_full.py +++ b/cat_win/tests/test_full.py @@ -163,7 +163,7 @@ def test_cat_output_full_show_files(self): self.assertIn(test_peek, fake_out.getvalue()) @patch('cat_win.cat.sys.argv', ['', test_file_path, test_empty_path, test_peek, '-S']) - def test_cat_output_full_show_count(self): + def test_cat_output_full_show_sum(self): with patch('cat_win.cat.sys.stdout', new=StdOutMock()) as fake_out: cat.main() self.assertIn(test_file_path, fake_out.getvalue()) diff --git a/cat_win/util/holder.py b/cat_win/util/holder.py index 25b6634d..1040a992 100644 --- a/cat_win/util/holder.py +++ b/cat_win/util/holder.py @@ -6,7 +6,7 @@ import heapq from cat_win.const.argconstants import HIGHEST_ARG_ID, ARGS_NOCOL, ARGS_LLENGTH, ARGS_NUMBER, \ - ARGS_REVERSE, ARGS_B64D, ARGS_B64E, ARGS_COUNT, ARGS_CCOUNT, DIFFERENTIABLE_ARGS + ARGS_REVERSE, ARGS_B64D, ARGS_B64E, ARGS_SUM, ARGS_SSUM, DIFFERENTIABLE_ARGS from cat_win.util.cbase64 import _decode_base64 from cat_win.util.file import File @@ -268,7 +268,7 @@ def generate_values(self, encoding: str) -> None: raw_f_write.write(_decode_base64(raw_f_read.read().decode(encoding))) except OSError: pass - if self.args_id[ARGS_COUNT] or self.args_id[ARGS_CCOUNT] or self.args_id[ARGS_NUMBER]: + if self.args_id[ARGS_SUM] or self.args_id[ARGS_SSUM] or self.args_id[ARGS_NUMBER]: self.__calc_place_holder__() if self.args_id[ARGS_LLENGTH]: self.__calc_file_line_length_place_holder__()