From 8559796619666ebd54b5a332a2c9dbfbd1c9ad14 Mon Sep 17 00:00:00 2001 From: Svein Seldal Date: Fri, 8 Nov 2024 23:14:13 +0100 Subject: [PATCH 1/3] Improve odg diff mechanism * Add text diff by default, with options for data and internal variants --- src/objdictgen/printing.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/objdictgen/printing.py b/src/objdictgen/printing.py index 10b6a26..28bb0c2 100644 --- a/src/objdictgen/printing.py +++ b/src/objdictgen/printing.py @@ -349,24 +349,20 @@ def _pprint(text: str, prefix: str = ' '): yield f"<< {ppath}only in {Fore.MAGENTA}LEFT{rst}" if show: yield from _pprint(change.t1, " < ") - elif 'added' in chtype: yield f" >> {ppath}only in {Fore.BLUE}RIGHT{rst}" if show: yield from _pprint(change.t2, " > ") - elif 'changed' in chtype: yield f"<< - >> {ppath}changed value from '{Fore.GREEN}{change.t1}{rst}' to '{Fore.GREEN}{change.t2}{rst}'" if show: yield from _pprint(change.t1, " < ") yield from _pprint(change.t2, " > ") - elif 'type_changes' in chtype: yield f"<< - >> {ppath}changed type and value from '{Fore.GREEN}{change.t1}{rst}' to '{Fore.GREEN}{change.t2}{rst}'" if show: yield from _pprint(change.t1, " < ") yield from _pprint(change.t2, " > ") - elif 'diff' in chtype: start = path[0:2] if start == ' ': From bf7f29bec8e3f9eb330cf708bce5575a1dd71d4e Mon Sep 17 00:00:00 2001 From: Svein Seldal Date: Sat, 9 Nov 2024 00:21:47 +0100 Subject: [PATCH 2/3] Fixup bugs and add testing --- src/objdictgen/printing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/objdictgen/printing.py b/src/objdictgen/printing.py index 28bb0c2..10b6a26 100644 --- a/src/objdictgen/printing.py +++ b/src/objdictgen/printing.py @@ -349,20 +349,24 @@ def _pprint(text: str, prefix: str = ' '): yield f"<< {ppath}only in {Fore.MAGENTA}LEFT{rst}" if show: yield from _pprint(change.t1, " < ") + elif 'added' in chtype: yield f" >> {ppath}only in {Fore.BLUE}RIGHT{rst}" if show: yield from _pprint(change.t2, " > ") + elif 'changed' in chtype: yield f"<< - >> {ppath}changed value from '{Fore.GREEN}{change.t1}{rst}' to '{Fore.GREEN}{change.t2}{rst}'" if show: yield from _pprint(change.t1, " < ") yield from _pprint(change.t2, " > ") + elif 'type_changes' in chtype: yield f"<< - >> {ppath}changed type and value from '{Fore.GREEN}{change.t1}{rst}' to '{Fore.GREEN}{change.t2}{rst}'" if show: yield from _pprint(change.t1, " < ") yield from _pprint(change.t2, " > ") + elif 'diff' in chtype: start = path[0:2] if start == ' ': From bcecc3fcf196d68ae9155130ced82ce10de25992 Mon Sep 17 00:00:00 2001 From: Svein Seldal Date: Sat, 9 Nov 2024 01:51:54 +0100 Subject: [PATCH 3/3] Add odg list --minus function --- src/objdictgen/__main__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/objdictgen/__main__.py b/src/objdictgen/__main__.py index 1613b0e..a60728d 100644 --- a/src/objdictgen/__main__.py +++ b/src/objdictgen/__main__.py @@ -174,12 +174,12 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None): subp.add_argument('-i', '--index', action="append", help="Specify parameter index to show") subp.add_argument('--all', action="store_true", help="Show all subindexes, including subindex 0") - subp.add_argument('--sort', action="store_true", help="Sort output") subp.add_argument('--compact', action="store_true", help="Compact listing") subp.add_argument('--raw', action="store_true", help="Show raw parameter values") subp.add_argument('--short', action="store_true", help="Do not list sub-index") subp.add_argument('--unused', action="store_true", help="Include unused profile parameters") subp.add_argument('--internal', action="store_true", help="Show internal data") + subp.add_argument('--minus', help="Show only parameters that are not in this OD") subp.add_argument('--no-color', **opt_nocolor) # type: ignore[arg-type] subp.add_argument('--novalidate', **opt_novalidate) # type: ignore[arg-type] subp.add_argument('-D', '--debug', **opt_debug) # type: ignore[arg-type] @@ -309,6 +309,10 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None): # -- LIST command -- elif opts.command in ("list", "cat"): + minus = None + if opts.minus: + minus = open_od(opts.minus, validate=not opts.novalidate) + for n, name in enumerate(opts.od): if n > 0: @@ -317,7 +321,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None): print(Fore.LIGHTBLUE_EX + name + '\n' + "=" * len(name) + Style.RESET_ALL) od = open_od(name, validate=not opts.novalidate) - for line in format_node(od, name, index=opts.index, opts=opts): + for line in format_node(od, name, index=opts.index, minus=minus, opts=opts): print(line)