|
1 | 1 | import inspect
|
2 | 2 | import warnings
|
3 |
| -from .callers import _MultiCall, HookCallError, _raise_wrapfail, _Result |
| 3 | +from .callers import _MultiCall, HookCallError, _Result, _LegacyMultiCall |
4 | 4 |
|
5 | 5 | __version__ = '0.5.3.dev'
|
6 | 6 |
|
@@ -166,25 +166,6 @@ def get(self, name):
|
166 | 166 | return self.__class__(self.root, self.tags + (name,))
|
167 | 167 |
|
168 | 168 |
|
169 |
| -def _wrapped_call(wrap_controller, func): |
170 |
| - """ Wrap calling to a function with a generator which needs to yield |
171 |
| - exactly once. The yield point will trigger calling the wrapped function |
172 |
| - and return its ``_Result`` to the yield point. The generator then needs |
173 |
| - to finish (raise StopIteration) in order for the wrapped call to complete. |
174 |
| - """ |
175 |
| - try: |
176 |
| - next(wrap_controller) # first yield |
177 |
| - except StopIteration: |
178 |
| - _raise_wrapfail(wrap_controller, "did not yield") |
179 |
| - call_outcome = _Result.from_call(func) |
180 |
| - try: |
181 |
| - wrap_controller.send(call_outcome) |
182 |
| - _raise_wrapfail(wrap_controller, "has second yield") |
183 |
| - except StopIteration: |
184 |
| - pass |
185 |
| - return call_outcome.get_result() |
186 |
| - |
187 |
| - |
188 | 169 | class _TracedHookExecution(object):
|
189 | 170 | def __init__(self, pluginmanager, before, after):
|
190 | 171 | self.pluginmanager = pluginmanager
|
@@ -485,54 +466,6 @@ def subset_hook_caller(self, name, remove_plugins):
|
485 | 466 | return orig
|
486 | 467 |
|
487 | 468 |
|
488 |
| -class _LegacyMultiCall(object): |
489 |
| - """ execute a call into multiple python functions/methods. """ |
490 |
| - |
491 |
| - # XXX note that the __multicall__ argument is supported only |
492 |
| - # for pytest compatibility reasons. It was never officially |
493 |
| - # supported there and is explicitely deprecated since 2.8 |
494 |
| - # so we can remove it soon, allowing to avoid the below recursion |
495 |
| - # in execute() and simplify/speed up the execute loop. |
496 |
| - |
497 |
| - def __init__(self, hook_impls, kwargs, specopts={}, hook=None): |
498 |
| - self.hook = hook |
499 |
| - self.hook_impls = hook_impls |
500 |
| - self.caller_kwargs = kwargs # come from _HookCaller.__call__() |
501 |
| - self.caller_kwargs["__multicall__"] = self |
502 |
| - self.specopts = hook.spec_opts if hook else specopts |
503 |
| - |
504 |
| - def execute(self): |
505 |
| - caller_kwargs = self.caller_kwargs |
506 |
| - self.results = results = [] |
507 |
| - firstresult = self.specopts.get("firstresult") |
508 |
| - |
509 |
| - while self.hook_impls: |
510 |
| - hook_impl = self.hook_impls.pop() |
511 |
| - try: |
512 |
| - args = [caller_kwargs[argname] for argname in hook_impl.argnames] |
513 |
| - except KeyError: |
514 |
| - for argname in hook_impl.argnames: |
515 |
| - if argname not in caller_kwargs: |
516 |
| - raise HookCallError( |
517 |
| - "hook call must provide argument %r" % (argname,)) |
518 |
| - if hook_impl.hookwrapper: |
519 |
| - return _wrapped_call(hook_impl.function(*args), self.execute) |
520 |
| - res = hook_impl.function(*args) |
521 |
| - if res is not None: |
522 |
| - if firstresult: |
523 |
| - return res |
524 |
| - results.append(res) |
525 |
| - |
526 |
| - if not firstresult: |
527 |
| - return results |
528 |
| - |
529 |
| - def __repr__(self): |
530 |
| - status = "%d meths" % (len(self.hook_impls),) |
531 |
| - if hasattr(self, "results"): |
532 |
| - status = ("%d results, " % len(self.results)) + status |
533 |
| - return "<_MultiCall %s, kwargs=%r>" % (status, self.caller_kwargs) |
534 |
| - |
535 |
| - |
536 | 469 | def varnames(func):
|
537 | 470 | """Return tuple of positional and keywrord argument names for a function,
|
538 | 471 | method, class or callable.
|
|
0 commit comments