diff options
-rw-r--r-- | examples/plugin_hello_world.py | 10 | ||||
-rw-r--r-- | ranger/ext/cached_function.py | 20 |
2 files changed, 15 insertions, 15 deletions
diff --git a/examples/plugin_hello_world.py b/examples/plugin_hello_world.py index 187f428e..e43eb61d 100644 --- a/examples/plugin_hello_world.py +++ b/examples/plugin_hello_world.py @@ -11,11 +11,11 @@ old_hook_ready = ranger.api.hook_ready # Create a replacement for the hook that... def hook_ready(fm): - # ...does the desired action... - fm.notify("Hello World") - # ...and calls the saved hook. If you don't care about the return value, simply - # return the return value of the previous hook to be on the safe side. - return old_hook_ready(fm) + # ...does the desired action... + fm.notify("Hello World") + # ...and calls the saved hook. If you don't care about the return value, + # simply return the return value of the previous hook to be safe. + return old_hook_ready(fm) # Finally, "monkey patch" the existing hook_ready function with our replacement: ranger.api.hook_ready = hook_ready diff --git a/ranger/ext/cached_function.py b/ranger/ext/cached_function.py index bbd6d2d4..daee6397 100644 --- a/ranger/ext/cached_function.py +++ b/ranger/ext/cached_function.py @@ -2,14 +2,14 @@ # This software is distributed under the terms of the GNU GPL version 3. def cached_function(fnc): - cache = {} - def inner_cached_function(*args): - try: - return cache[args] - except: - value = fnc(*args) - cache[args] = value - return value - inner_cached_function._cache = cache - return inner_cached_function + cache = {} + def inner_cached_function(*args): + try: + return cache[args] + except: + value = fnc(*args) + cache[args] = value + return value + inner_cached_function._cache = cache + return inner_cached_function |