From 79e61db3514857e48e6b61281b65d251bf68bfd6 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Nov 2020 13:26:36 +0300 Subject: [PATCH] 0.0.9 --- setup.py | 2 +- xontrib/hist_format.py | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index 04f7181..7704263 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setuptools.setup( name='xontrib-hist-format', - version='0.0.8', + version='0.0.9', license='MIT', author='anki-code', author_email='no@no.no', diff --git a/xontrib/hist_format.py b/xontrib/hist_format.py index 941b503..82a13c8 100644 --- a/xontrib/hist_format.py +++ b/xontrib/hist_format.py @@ -12,10 +12,10 @@ def _hist_format(args): opt = argp.parse_args(args) opt.commands_count = abs(int(opt.commands_count)) - if opt.output_head: - opt.output_head = abs(int(opt.output_head)) - if opt.output_tail: - opt.output_tail = abs(int(opt.output_tail)) + if opt.output_head_count: + opt.output_head_count = abs(int(opt.output_head_count)) + if opt.output_tail_count: + opt.output_tail_count = abs(int(opt.output_tail_count)) formats = { 'md': {'begin': '```python', 'end': '```', 'comment': '# '}, @@ -62,26 +62,26 @@ def _hist_format(args): print() output_lines = [format['comment'] + l for l in str(h.out).rstrip().split('\n')] - if opt.output_head and opt.output_tail: - if (opt.output_head + opt.output_tail) < len(output_lines): - print('\n'.join(output_lines[:opt.output_head])) + if opt.output_head_count and opt.output_tail_count: + if (opt.output_head_count + opt.output_tail_count) < len(output_lines): + print('\n'.join(output_lines[:opt.output_head_count])) print(format['comment']) - print(format['comment'] + f'---- Skipped {len(output_lines) - opt.output_head - opt.output_tail} lines of output ----') + print(format['comment'] + f'---- Skipped {len(output_lines) - opt.output_head_count - opt.output_tail_count} lines of output ----') print(format['comment']) - print('\n'.join(output_lines[-opt.output_tail:])) + print('\n'.join(output_lines[-opt.output_tail_count:])) else: print('\n'.join(output_lines)) - elif opt.output_head: - print('\n'.join(output_lines[:opt.output_head])) - skipped = len(output_lines) - opt.output_head + elif opt.output_head_count: + print('\n'.join(output_lines[:opt.output_head_count])) + skipped = len(output_lines) - opt.output_head_count if skipped > 0: print(format['comment'] + f'---- Skipped next {skipped} lines of output ----') - elif opt.output_tail: - skipped = len(output_lines) - opt.output_tail + elif opt.output_tail_count: + skipped = len(output_lines) - opt.output_tail_count if skipped > 0: print(format['comment'] + f'---- Skipped prev {skipped} lines of output ----') - print('\n'.join(output_lines[-opt.output_tail:])) + print('\n'.join(output_lines[-opt.output_tail_count:])) else: print('\n'.join(output_lines))