Browse files

try to convert value if no basestring in NodeTextIndexer

  • Loading branch information...
1 parent b991f35 commit 4b64a194e8ae3f080c65e19452b72745f8744a71 @rnixx rnixx committed Sep 22, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/souper/soup.py
View
9 src/souper/soup.py
@@ -96,6 +96,8 @@ def query(self, queryobject, sort_index=None, limit=None, sort_type=None,
limit=limit, sort_type=sort_type,
reverse=reverse, names=names)
if with_size:
+ # XXX: should this be 'return' instead of 'yield'. yielding size is
+ # useless
yield size
for iid in iids:
yield self.data[iid]
@@ -106,6 +108,8 @@ def lazy(self, queryobject, sort_index=None, limit=None, sort_type=None,
limit=limit, sort_type=sort_type,
reverse=reverse, names=names)
if with_size:
+ # XXX: should this be 'return' instead of 'yield'. yielding size is
+ # useless
yield size
for iid in iids:
yield LazyRecord(iid, self)
@@ -199,7 +203,10 @@ def __init__(self, attrs):
def __call__(self, context, default):
values = list()
for attr in self.attrs:
- values.append(context.attrs.get(attr, u''))
+ val = context.attrs.get(attr, u'')
+ if not isinstance(val, basestring):
+ val = str(val)
+ values.append(val)
values = [_.strip().decode('utf-8') for _ in values if _.strip()]
if not values:
return default

0 comments on commit 4b64a19

Please sign in to comment.