mavparm: honour use_tabs for params present in only one file - #1275
Open
azrabano23 wants to merge 1 commit into
Open
mavparm: honour use_tabs for params present in only one file#1275azrabano23 wants to merge 1 commit into
azrabano23 wants to merge 1 commit into
Conversation
`mavparmdiff.py -t` switches the output delimiter to tabs, but
MAVParmDict.diff() only applied use_tabs to the header and to
parameters whose values differ. Parameters present in only one of the
two files were still printed with the fixed-width space-padded format,
so a tab-separated diff could not be imported into a spreadsheet:
PARAMETER\tFILE1\tFILE2
ADSB_ENABLE 0.0000
ADSB_TYPE 0.0000
AHRS_TRIM_X\t-0.0135\t-0.0512
Emit "NAME\tVALUE" for params only in FILE1 and "NAME\t\tVALUE" for
params only in FILE2 when use_tabs is set, matching the column layout
of the header and of the differing-value rows. The space-padded format
is unchanged.
Add a regression test that captures diff() output with use_tabs=True
and checks every row is purely tab-delimited.
Fixes ArduPilot#796
Signed-off-by: Azra Bano <azrabano.work@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
mavparmdiff.py -tis documented as "use tabs delimiter between columns for the output", but only the header row and the rows for parameters that differ between the two files were tab-delimited. Parameters present in only one file were still printed with the fixed-width, space-padded format, so the output could not be imported into a spreadsheet (issue #796).With two three-line parameter files (
cat -vtshows tabs as^I):Root cause
In
MAVParmDict.diff()theuse_tabsflag was only checked in the header branch and in the "value differs" branch. The "only in FILE1" and "only in FILE2" branches always used the%-16.16s %12.4fformats.The fix
When
use_tabsis set, printNAME\tVALUEfor params only in FILE1 andNAME\t\tVALUEfor params only in FILE2, so the columns line up with the header and the differing-value rows. The space-padded output is unchanged.Verification
Added
test_diff_use_tabsintests/test_mavparm.py, which capturesdiff(..., use_tabs=True, header=True)output and checks every row is purely tab-delimited. It fails on master (AssertionErroron the space-padded rows) and passes with this change.Tested with Python 3.12 on macOS.
Fixes #796
🤖 Generated with Claude Code