chainfirst / chainall can be given a name argument to use as inner function's name
authorsylvain.thenault@logilab.fr
Mon, 16 Feb 2009 11:28:43 +0100
changeset 623 9dc7b3fa59f1
parent 622 2d30c5e1a7d2
child 645 4dd6226d48c9
chainfirst / chainall can be given a name argument to use as inner function's name
common/selectors.py
vregistry.py
--- a/common/selectors.py	Fri Feb 13 16:34:05 2009 +0100
+++ b/common/selectors.py	Mon Feb 16 11:28:43 2009 +0100
@@ -535,37 +535,36 @@
 
 # compound selectors ##########################################################
 
-non_final_entity = chainall(nonempty_rset, _non_final_entity)
-non_final_entity.__name__ = 'non_final_entity'
+non_final_entity = chainall(nonempty_rset, _non_final_entity,
+                            name='non_final_entity')
 nfentity_selector = deprecated_function(non_final_entity)
 
-implement_interface = chainall(non_final_entity, _implement_interface)
-implement_interface.__name__ = 'implement_interface'
+implement_interface = chainall(non_final_entity, _implement_interface,
+                               name='implement_interface')
 interface_selector = deprecated_function(implement_interface)
 
-accept = chainall(non_final_entity, accept_rset)
-accept.__name__ = 'accept'
+accept = chainall(non_final_entity, accept_rset, name='accept')
 accept_selector = deprecated_function(accept)
 
-accept_one = chainall(one_line_rset, accept)
-accept_one.__name__ = 'accept_one'
+accept_one = deprecated_function(chainall(one_line_rset, accept,
+                                          name='accept_one'))
 accept_one_selector = deprecated_function(accept_one)
 
-rql_condition = chainall(non_final_entity, one_line_rset, _rql_condition)
-rql_condition.__name__ = 'rql_condition'
+rql_condition = chainall(non_final_entity, one_line_rset, _rql_condition,
+                         name='rql_condition')
 rqlcondition_selector = deprecated_function(rql_condition)
 
 
-searchstate_accept = chainall(nonempty_rset, match_search_state, accept)
-searchstate_accept.__name__ = 'searchstate_accept'
+searchstate_accept = chainall(nonempty_rset, match_search_state, accept,
+                              name='searchstate_accept')
 searchstate_accept_selector = deprecated_function(searchstate_accept)
 
 searchstate_accept_one = chainall(one_line_rset, match_search_state,
-                                  accept, _rql_condition)
-searchstate_accept_one.__name__ = 'searchstate_accept_one'
+                                  accept, _rql_condition,
+                                  name='searchstate_accept_one')
 searchstate_accept_one_selector = deprecated_function(searchstate_accept_one)
 
-searchstate_accept_one_but_etype = chainall(searchstate_accept_one, but_etype)
-searchstate_accept_one_but_etype.__name__ = 'searchstate_accept_one_but_etype'
+searchstate_accept_one_but_etype = chainall(searchstate_accept_one, but_etype,
+                                            name='searchstate_accept_one_but_etype')
 searchstate_accept_one_but_etype_selector = deprecated_function(
     searchstate_accept_one_but_etype)
--- a/vregistry.py	Fri Feb 13 16:34:05 2009 +0100
+++ b/vregistry.py	Mon Feb 16 11:28:43 2009 +0100
@@ -513,7 +513,7 @@
 
 # advanced selector building functions ########################################
 
-def chainall(*selectors):
+def chainall(*selectors, **kwargs):
     """return a selector chaining given selectors. If one of
     the selectors fail, selection will fail, else the returned score
     will be the sum of each selector'score
@@ -527,9 +527,11 @@
                 return 0
             score += partscore
         return score
+    if 'name' in kwargs:
+        selector.__name__ = kwargs['name']
     return selector
 
-def chainfirst(*selectors):
+def chainfirst(*selectors, **kwargs):
     """return a selector chaining given selectors. If all
     the selectors fail, selection will fail, else the returned score
     will be the first non-zero selector score
@@ -541,5 +543,7 @@
             if partscore:
                 return partscore
         return 0
+    if 'name' in kwargs:
+        selector.__name__ = kwargs['name']
     return selector