def search(self, searcher): myname = self.name myversion = self.version ratio = 0 for nameversion, cutoff in searcher.nameversion: _, ratio1 = globdistance(nameversion, myname, cutoff) _, ratio2 = globdistance(nameversion, "%s-%s" % (myname, myversion), cutoff) _, ratio3 = globdistance(nameversion, "%s-%s" % (myname, splitrelease(myversion)[0]), cutoff) ratio = max(ratio, ratio1, ratio2, ratio3) if ratio: searcher.addResult(self, ratio)
def test_splitrelease(self): version, release = splitrelease("1.0-1_0ubuntu0.10.04") self.assertEquals(version, "1.0") self.assertEquals(release, "1_0ubuntu0.10.04")