diff options
author | Yaroslav Halchenko <debian@onerussian.com> | 2016-10-02 11:17:36 -0400 |
---|---|---|
committer | Yaroslav Halchenko <debian@onerussian.com> | 2016-10-02 11:17:36 -0400 |
commit | 51f4a1407ef12405e16f643f5f9d2002b4b52ab9 (patch) | |
tree | 056a89bcfc54ba16a835ad5fcd3c73650bac170c /git/index/util.py | |
parent | b3b9c0242ba2893231e0ab1c13fa2a0c8a9cfc59 (diff) | |
download | gitpython-51f4a1407ef12405e16f643f5f9d2002b4b52ab9.tar.gz |
RF: use @functools.wraps within decorators instead of manual __name__ reassignment
@wraps does more and does it right ;)
Diffstat (limited to 'git/index/util.py')
-rw-r--r-- | git/index/util.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/git/index/util.py b/git/index/util.py index 0340500c..ce798851 100644 --- a/git/index/util.py +++ b/git/index/util.py @@ -2,6 +2,9 @@ import struct import tempfile import os + +from functools import wraps + from git.compat import is_win __all__ = ('TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir') @@ -48,13 +51,13 @@ def post_clear_cache(func): natively which in fact is possible, but probably not feasible performance wise. """ + @wraps(func) def post_clear_cache_if_not_raised(self, *args, **kwargs): rval = func(self, *args, **kwargs) self._delete_entries_cache() return rval - # END wrapper method - post_clear_cache_if_not_raised.__name__ = func.__name__ + return post_clear_cache_if_not_raised @@ -63,6 +66,7 @@ def default_index(func): repository index. This is as we rely on git commands that operate on that index only. """ + @wraps(func) def check_default_index(self, *args, **kwargs): if self._file_path != self._index_path(): raise AssertionError( @@ -70,7 +74,6 @@ def default_index(func): return func(self, *args, **kwargs) # END wrpaper method - check_default_index.__name__ = func.__name__ return check_default_index @@ -78,6 +81,7 @@ def git_working_dir(func): """Decorator which changes the current working dir to the one of the git repository in order to assure relative paths are handled correctly""" + @wraps(func) def set_git_working_dir(self, *args, **kwargs): cur_wd = os.getcwd() os.chdir(self.repo.working_tree_dir) @@ -88,7 +92,6 @@ def git_working_dir(func): # END handle working dir # END wrapper - set_git_working_dir.__name__ = func.__name__ return set_git_working_dir #} END decorators |