Wrap a call to a custom_getter to use the old_getter internally.
(custom_getter, old_getter)
| 2698 | |
| 2699 | |
| 2700 | def _maybe_wrap_custom_getter(custom_getter, old_getter): |
| 2701 | """Wrap a call to a custom_getter to use the old_getter internally.""" |
| 2702 | if old_getter is None: |
| 2703 | return custom_getter |
| 2704 | |
| 2705 | # The new custom_getter should call the old one |
| 2706 | def wrapped_custom_getter(getter, *args, **kwargs): |
| 2707 | # Call: |
| 2708 | # custom_getter( |
| 2709 | # lambda: old_getter(true_getter, ...), *args, **kwargs) |
| 2710 | # which means custom_getter will call old_getter, which |
| 2711 | # will call the true_getter, perform any intermediate |
| 2712 | # processing, and return the results to the current |
| 2713 | # getter, which will also perform additional processing. |
| 2714 | return custom_getter(functools.partial(old_getter, getter), *args, **kwargs) |
| 2715 | |
| 2716 | return wrapped_custom_getter |
| 2717 | |
| 2718 | |
| 2719 | def _get_unique_variable_scope(prefix): |