-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rely on save_method_args to save method args.
- Loading branch information
Showing
2 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import collections | ||
import functools | ||
|
||
|
||
# from jaraco.functools 3.5.2 | ||
def save_method_args(method): | ||
args_and_kwargs = collections.namedtuple('args_and_kwargs', 'args kwargs') | ||
|
||
@functools.wraps(method) | ||
def wrapper(self, *args, **kwargs): | ||
attr_name = '_saved_' + method.__name__ | ||
attr = args_and_kwargs(args, kwargs) | ||
setattr(self, attr_name, attr) | ||
return method(self, *args, **kwargs) | ||
|
||
return wrapper |