Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/zipp/_functools.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

11 statements  

1import collections 

2import functools 

3 

4 

5# from jaraco.functools 4.0.2 

6def save_method_args(method): 

7 """ 

8 Wrap a method such that when it is called, the args and kwargs are 

9 saved on the method. 

10 """ 

11 args_and_kwargs = collections.namedtuple('args_and_kwargs', 'args kwargs') # noqa: PYI024 

12 

13 @functools.wraps(method) 

14 def wrapper(self, /, *args, **kwargs): 

15 attr_name = '_saved_' + method.__name__ 

16 attr = args_and_kwargs(args, kwargs) 

17 setattr(self, attr_name, attr) 

18 return method(self, *args, **kwargs) 

19 

20 return wrapper