@@ -77,77 +77,6 @@ def get_result(self):
77
77
_reraise (* ex ) # noqa
78
78
79
79
80
- def _wrapped_call (wrap_controller , func ):
81
- """ Wrap calling to a function with a generator which needs to yield
82
- exactly once. The yield point will trigger calling the wrapped function
83
- and return its ``_Result`` to the yield point. The generator then needs
84
- to finish (raise StopIteration) in order for the wrapped call to complete.
85
- """
86
- try :
87
- next (wrap_controller ) # first yield
88
- except StopIteration :
89
- _raise_wrapfail (wrap_controller , "did not yield" )
90
- call_outcome = _Result .from_call (func )
91
- try :
92
- wrap_controller .send (call_outcome )
93
- _raise_wrapfail (wrap_controller , "has second yield" )
94
- except StopIteration :
95
- pass
96
- return call_outcome .get_result ()
97
-
98
-
99
- class _LegacyMultiCall (object ):
100
- """ execute a call into multiple python functions/methods. """
101
-
102
- # XXX note that the __multicall__ argument is supported only
103
- # for pytest compatibility reasons. It was never officially
104
- # supported there and is explicitely deprecated since 2.8
105
- # so we can remove it soon, allowing to avoid the below recursion
106
- # in execute() and simplify/speed up the execute loop.
107
-
108
- def __init__ (self , hook_impls , kwargs , firstresult = False ):
109
- self .hook_impls = hook_impls
110
- self .caller_kwargs = kwargs # come from _HookCaller.__call__()
111
- self .caller_kwargs ["__multicall__" ] = self
112
- self .firstresult = firstresult
113
-
114
- def execute (self ):
115
- caller_kwargs = self .caller_kwargs
116
- self .results = results = []
117
- firstresult = self .firstresult
118
-
119
- while self .hook_impls :
120
- hook_impl = self .hook_impls .pop ()
121
- try :
122
- args = [caller_kwargs [argname ] for argname in hook_impl .argnames ]
123
- except KeyError :
124
- for argname in hook_impl .argnames :
125
- if argname not in caller_kwargs :
126
- raise HookCallError (
127
- "hook call must provide argument %r" % (argname ,))
128
- if hook_impl .hookwrapper :
129
- return _wrapped_call (hook_impl .function (* args ), self .execute )
130
- res = hook_impl .function (* args )
131
- if res is not None :
132
- if firstresult :
133
- return res
134
- results .append (res )
135
-
136
- if not firstresult :
137
- return results
138
-
139
- def __repr__ (self ):
140
- status = "%d meths" % (len (self .hook_impls ),)
141
- if hasattr (self , "results" ):
142
- status = ("%d results, " % len (self .results )) + status
143
- return "<_MultiCall %s, kwargs=%r>" % (status , self .caller_kwargs )
144
-
145
-
146
- def _legacymulticall (hook_impls , caller_kwargs , firstresult = False ):
147
- return _LegacyMultiCall (
148
- hook_impls , caller_kwargs , firstresult = firstresult ).execute ()
149
-
150
-
151
80
def _multicall (hook_impls , caller_kwargs , firstresult = False ):
152
81
"""Execute a call into multiple python functions/methods and return the
153
82
result(s).
0 commit comments