equal
deleted
inserted
replaced
958 :param scorefunc: callable expected to take an entity as argument and to |
958 :param scorefunc: callable expected to take an entity as argument and to |
959 return a score >= 0 |
959 return a score >= 0 |
960 """ |
960 """ |
961 def __init__(self, scorefunc, once_is_enough=False): |
961 def __init__(self, scorefunc, once_is_enough=False): |
962 super(score_entity, self).__init__(once_is_enough) |
962 super(score_entity, self).__init__(once_is_enough) |
963 self.score_entity = scorefunc |
963 def intscore(*args, **kwargs): |
|
964 score = scorefunc(*args, **kwargs) |
|
965 if not score: |
|
966 return 0 |
|
967 if isinstance(score, (int, long)): |
|
968 return score |
|
969 return 1 |
|
970 self.score_entity = intscore |
964 |
971 |
965 |
972 |
966 # XXX DEPRECATED ############################################################## |
973 # XXX DEPRECATED ############################################################## |
967 from cubicweb.vregistry import chainall |
974 from cubicweb.vregistry import chainall |
968 |
975 |