Merge lp://qastaging/~jml/pkgme-devportal/levenshtein into lp://qastaging/pkgme-devportal

Proposed by Jonathan Lange
Status: Merged
Approved by: Jonathan Lange
Approved revision: 75
Merged at revision: 65
Proposed branch: lp://qastaging/~jml/pkgme-devportal/levenshtein
Merge into: lp://qastaging/pkgme-devportal
Diff against target: 133 lines (+71/-18)
2 files modified
devportalbinary/binary.py (+58/-15)
devportalbinary/tests/test_binary.py (+13/-3)
To merge this branch: bzr merge lp://qastaging/~jml/pkgme-devportal/levenshtein
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+116822@code.qastaging.launchpad.net

Commit message

Guess main binary using levenshtein distance rather than exact matching

Description of the change

Based on lp:~mvo/pkgme-devportal/lp1026952-levenshtein

Addresses bug 1026952 by using Levenshtein distance (i.e. minimum number
of edits) rather than looking for a binary with the exact name as the package)

Differences between this & mvo's branch:
 * Drops the exact name matching altogether, as Levenshtein gets us this
 * Ignores case when calculating distance
 * Includes a definition of Levenshtein distance in the docstring for the
   function, to aid the ignorant

And two other completely unnecessary changes:
 * Extracts the 'rank' inner function to be '_rank_executable'
 * No whitespace at the end of lines

Thanks,
jml

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

This looks great, one leftover:

47 + # levenshtein distance, the "2" here is arbirtary

should get removed then this can land.

review: Approve
Revision history for this message
James Westby (james-w) wrote :

======================================================================
FAIL: tests.test_binary.BinaryBackendTests.test_executable_is_best_guess
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/tmparD01z/devportalbinary/tests/test_binary.py", line 329, in test_executable_is_best_guess
    backend.get_executable(package_name))
MismatchError: !=:
reference = '/opt/tests.test_binary.BinaryBackendTests.test_executable_is_best_guess-1/the-best'
actual = '/opt/tests.test_binary.BinaryBackendTests.test_executable_is_best_guess-1/whatever/not-the-best'

Ran 125 tests in 0.469s
FAILED (failures=1)

75. By Jonathan Lange

Make the test more robust.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches