Skip to content

Commit

Permalink
allow no output file for dbcompare
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Dec 17, 2024
1 parent bcddea4 commit bc181ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/builder2ibek/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/builder2ibek/dbcompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions tests/samples/compare.diff
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit bc181ef

Please sign in to comment.