diff --git a/scripts/projects.py b/scripts/projects.py index 9ea8e188..aa5a3fcb 100644 --- a/scripts/projects.py +++ b/scripts/projects.py @@ -30,22 +30,24 @@ def err(*objs): def cache_func(func, args): d = cache depth = 0 - for a in [ func.__name__ ] + args: - if a is None: - a = 'None' + keys = [ func.__name__ ] + args + l = len(keys) + for k in keys: + if k is None: + k = 'None' depth += 1 - #debug('depth = ', depth, 'arg = ', a, 'd = ', str(d)) - if a in d: - if len(args) == depth: - return d[a] - d = d[a] + #debug('depth = ', depth, 'key = ', k, 'd = ', str(d)) + if k in d: + if l == depth: + return d[k] + d = d[k] continue - if len(args) == depth: + if l == depth: r = func(*args) - d[a] = r + d[k] = r return r - d[a] = {} - d = d[a] + d[k] = {} + d = d[k] raise Exception("cache algorithm failed for function", func.__name__, "in depth", depth) def proj_dir(name):