Set number of matches to four and cutoff to 0.4

Review Request #8043 — Created March 9, 2016 and submitted — Latest diff uploaded

totte
RBTools
master
7910780...
rbtools
Set number of matches to four and cutoff to 0.4

This script...

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/usr/bin/env python2

import difflib

word = "git@git.example.org:/foo.git"
possibilities = ["/srv/git/repositories/baz.git", 
             "git://git.example.org/test.git", 
             "/srv/git/repositories/bar.git", 
             "/srv/git/repositories/test.git", 
             "/srv/git/repositories/website.git", 
             "/srv/git/repositories/foo.git"]
print(difflib.get_close_matches(word, possibilities, n=4))

...will return ['git://git.example.org/test.git'], while this script...

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/usr/bin/env python2

import difflib

word = "git@git.example.org:/foo.git"
possibilities = ["/srv/git/repositories/baz.git", 
             "git://git.example.org/test.git", 
             "/srv/git/repositories/bar.git", 
             "/srv/git/repositories/test.git", 
             "/srv/git/repositories/website.git", 
             "/srv/git/repositories/foo.git"]
print(difflib.get_close_matches(word, possibilities, n=4, cutoff=0.4))

...will return ['git://git.example.org/test.git', '/srv/git/repositories/foo.git', '/srv/git/repositories/baz.git', '/srv/git/repositories/bar.git'].

    Loading...