diff options
Diffstat (limited to 'examples/plugin_hello_world.py')
-rw-r--r-- | examples/plugin_hello_world.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/plugin_hello_world.py b/examples/plugin_hello_world.py index 0158a653..b1451be1 100644 --- a/examples/plugin_hello_world.py +++ b/examples/plugin_hello_world.py @@ -3,13 +3,15 @@ # This is a sample plugin that displays "Hello World" in ranger's console after # it started. +from __future__ import (absolute_import, print_function) + # We are going to extend the hook "ranger.api.hook_ready", so first we need # to import ranger.api: import ranger.api # Save the previously existing hook, because maybe another module already # extended that hook and we don't want to lose it: -old_hook_ready = ranger.api.hook_ready +HOOK_READY_OLD = ranger.api.hook_ready # Create a replacement for the hook that... @@ -19,7 +21,8 @@ def hook_ready(fm): 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) + return HOOK_READY_OLD(fm) + # Finally, "monkey patch" the existing hook_ready function with our replacement: ranger.api.hook_ready = hook_ready |