From bc181ef8dd5bd47691ad0ed4612dac3d8a0ea60d Mon Sep 17 00:00:00 2001 From: giles knap Date: Tue, 17 Dec 2024 10:03:03 +0000 Subject: [PATCH] allow no output file for dbcompare --- src/builder2ibek/__main__.py | 2 +- src/builder2ibek/dbcompare.py | 9 +++++---- tests/samples/compare.diff | 9 ++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/builder2ibek/__main__.py b/src/builder2ibek/__main__.py index 611dbed..c76a6dd 100644 --- a/src/builder2ibek/__main__.py +++ b/src/builder2ibek/__main__.py @@ -84,7 +84,7 @@ def db_compare( ignore: list[str] = typer.Option( [], help="List of record name sub strings to ignore" ), - output: Optional[Path] = typer.Option(..., help="Output file"), + output: Optional[Path] = typer.Option(None, help="Output file"), ): """ Compare two DB files and output the differences diff --git a/src/builder2ibek/dbcompare.py b/src/builder2ibek/dbcompare.py index 6b4b2a2..b8dd44e 100644 --- a/src/builder2ibek/dbcompare.py +++ b/src/builder2ibek/dbcompare.py @@ -38,15 +38,16 @@ def compare_dbs( new_only_filtered.remove(rec) result = ( - "Records in original but not in new:\n" - + "*******************************************************************\n" + "*******************************************************************\n" + + "Records in original but not in new:\n\n" + "\n".join(old_only_filtered) + "\n\n" - + "Records in new but not in original:\n" + "*******************************************************************\n" + + "Records in new but not in original:\n\n" + "\n".join(new_only_filtered) + "\n\n" - + f"\records in original: {len(old_set)}\n" + + "*******************************************************************\n" + + f"records in original: {len(old_set)}\n" f" records in new: {len(new_set)}\n" f" records missing in new: {len(old_only_filtered)}\n" f" records extra in new: {len(new_only_filtered)}\n" diff --git a/tests/samples/compare.diff b/tests/samples/compare.diff index c47f6f1..a7e523c 100644 --- a/tests/samples/compare.diff +++ b/tests/samples/compare.diff @@ -1,5 +1,6 @@ -Records in original but not in new: ******************************************************************* +Records in original but not in new: + bo SR03C-VA-IOC-01:SRHEARTBT calc SR03A-VA-GAUGE-01:PLOG_CALC calc SR03A-VA-GAUGE-02:PLOG_CALC @@ -37,8 +38,9 @@ stringout SR03C-VA-IOC-01:RRTIME stringout SR03C-VA-IOC-01:SRRECENTST stringout SR03C-VA-IOC-01:SRSTATUSST -Records in new but not in original: ******************************************************************* +Records in new but not in original: + aSub SR03A-VA-MIMG-01:MEAN aSub SR03C-VA-MIMG-01:MEAN aSub SR03S-VA-MIMG-01:MEAN @@ -135,7 +137,8 @@ stringout SR03C-VA-IOC-01:SR_rebootTime stringout SR03C-VA-IOC-01:SR_recentlyStr stringout SR03C-VA-IOC-01:SR_statusStr - ecords in original: 7436 +******************************************************************* +records in original: 7436 records in new: 7495 records missing in new: 36 records extra in new: 95