[kupfer] relevance: Only call format_clean for nonempty clean parts
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] relevance: Only call format_clean for nonempty clean parts
- Date: Sun, 13 Sep 2009 22:53:16 +0000 (UTC)
commit f312bdaf2106bea9cfdbeb896a90bad9261ce19d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sun Sep 13 03:37:14 2009 +0200
relevance: Only call format_clean for nonempty clean parts
kupfer/relevance.py | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/relevance.py b/kupfer/relevance.py
index 3ec01e1..15a831d 100644
--- a/kupfer/relevance.py
+++ b/kupfer/relevance.py
@@ -46,9 +46,10 @@ def formatCommonSubstrings(s, query, format_clean=None, format_match=None):
"""
format_clean = format_clean or (lambda x: x)
format_match = format_match or (lambda x: x)
+ format = lambda x: x and format_clean(x)
if not query:
- return format_clean(s)
+ return format(s)
ls = s.lower()
@@ -56,7 +57,7 @@ def formatCommonSubstrings(s, query, format_clean=None, format_match=None):
first, last = _findBestMatch(ls, query)
if first == -1:
- return format_clean(s)
+ return format(s)
# find longest perfect match, put in slc
for slc in xrange(len(query), 0, -1):
@@ -71,11 +72,11 @@ def formatCommonSubstrings(s, query, format_clean=None, format_match=None):
# we use s[0:0], which is "" or u""
return s[0:0].join((
- format_clean(head),
+ format(head),
format_match(match),
formatCommonSubstrings(matchtail, nextkey,
format_clean, format_match),
- format_clean(tail),
+ format(tail),
))
def score(s, query):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]