mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Consolidated some code.
This commit is contained in:
parent
33f5bad484
commit
7b1b72e225
2 changed files with 22 additions and 23 deletions
|
|
@ -22,15 +22,16 @@ class cached_property(object):
|
|||
|
||||
def memoize_by_cwd(func):
|
||||
"""Memoize a function call based on os.getcwd()."""
|
||||
cache = {}
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args):
|
||||
cwd = os.getcwd()
|
||||
key = (cwd,) + args
|
||||
try:
|
||||
return cache[key]
|
||||
return wrapper._cache[key]
|
||||
except KeyError:
|
||||
ret = cache[key] = func(*args)
|
||||
ret = wrapper._cache[key] = func(*args)
|
||||
return ret
|
||||
|
||||
wrapper._cache = {}
|
||||
|
||||
return wrapper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue