diff options
Diffstat (limited to 'examples/plugin_new_macro.py')
-rw-r--r-- | examples/plugin_new_macro.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/plugin_new_macro.py b/examples/plugin_new_macro.py index 8dbe435d..0e44cdd3 100644 --- a/examples/plugin_new_macro.py +++ b/examples/plugin_new_macro.py @@ -4,18 +4,22 @@ # date in commands that allow macros. You can test it with the command # ":shell echo %date; read" -# Save the original macro function -import ranger.core.actions -old_get_macros = ranger.core.actions.Actions._get_macros +from __future__ import (absolute_import, print_function) -# Define a new macro function import time +import ranger.core.actions +# Save the original macro function +GET_MACROS_OLD = ranger.core.actions.Actions._get_macros # pylint: disable=protected-access + + +# Define a new macro function def get_macros_with_date(self): - macros = old_get_macros(self) + macros = GET_MACROS_OLD(self) macros['date'] = time.strftime('%m/%d/%Y') return macros + # Overwrite the old one -ranger.core.actions.Actions._get_macros = get_macros_with_date +ranger.core.actions.Actions._get_macros = get_macros_with_date # pylint: disable=protected-access |