Skip to content

Commit

Permalink
renamed Count to Sum
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenZcience committed Feb 15, 2024
1 parent 2aa6a81 commit d618e88
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions cat_win/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}}" + \
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions cat_win/const/argconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion cat_win/tests/test_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', ['<CAT>', 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())
Expand Down
4 changes: 2 additions & 2 deletions cat_win/util/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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__()

0 comments on commit d618e88

Please sign in to comment.