(wrapped, instance, args, kwargs)
| 79 | """ |
| 80 | @wrapt.decorator |
| 81 | def func_wrapper(wrapped, instance, args, kwargs): |
| 82 | do_meta = from_args(wrapped, ("meta",), *args, **kwargs)["meta"] |
| 83 | |
| 84 | if do_meta is None: |
| 85 | do_meta = True |
| 86 | |
| 87 | if not xarray_enabled() or not do_meta: |
| 88 | return wrapped(*args, **kwargs) |
| 89 | |
| 90 | argvars = from_args(wrapped, ("wrfin", "timeidx", "method", |
| 91 | "squeeze", "cache", "units", "meta", |
| 92 | "_key"), |
| 93 | *args, **kwargs) |
| 94 | |
| 95 | wrfin = argvars["wrfin"] |
| 96 | timeidx = argvars["timeidx"] |
| 97 | units = argvars["units"] |
| 98 | method = argvars["method"] |
| 99 | squeeze = argvars["squeeze"] |
| 100 | cache = argvars["cache"] |
| 101 | _key = argvars["_key"] |
| 102 | if cache is None: |
| 103 | cache = {} |
| 104 | |
| 105 | # Note: can't modify nonlocal var |
| 106 | if (callable(copy_varname)): |
| 107 | _copy_varname = copy_varname(wrfin) |
| 108 | else: |
| 109 | _copy_varname = copy_varname |
| 110 | |
| 111 | # Extract the copy_from argument |
| 112 | var_to_copy = None if cache is None else cache.get(_copy_varname, |
| 113 | None) |
| 114 | |
| 115 | if var_to_copy is None: |
| 116 | var_to_copy = extract_vars(wrfin, timeidx, (_copy_varname,), |
| 117 | method, squeeze, cache, |
| 118 | meta=True, _key=_key)[_copy_varname] |
| 119 | |
| 120 | # Make a copy so we don't modify a user supplied cache |
| 121 | new_cache = dict(cache) |
| 122 | new_cache[_copy_varname] = var_to_copy |
| 123 | |
| 124 | # Don't modify the original args/kargs. The args need to be a list |
| 125 | # so it can be modified. |
| 126 | new_args, cache_argloc = arg_location(wrapped, "cache", args, kwargs) |
| 127 | new_args[cache_argloc] = new_cache |
| 128 | |
| 129 | result = wrapped(*new_args) |
| 130 | |
| 131 | outname = "" |
| 132 | outdimnames = list() |
| 133 | outcoords = OrderedDict() |
| 134 | outattrs = OrderedDict() |
| 135 | |
| 136 | if copy_varname is not None: |
| 137 | outname = var_to_copy.name |
| 138 |
nothing calls this directly
no test coverage detected