From 7fe8df4c560139b1fe305adeaaa2cb4ef9279fdd Mon Sep 17 00:00:00 2001 From: gryf Date: Mon, 2 Nov 2020 20:22:33 +0100 Subject: [PATCH] Calculate weechat home using string_eval_path_home. Using different path for the weechat configuration results in inability to find right replacemenet_map json file. Fix it by using string_eval_path_home method, which will return right weechat config directory. --- replacer.py | 6 +++--- test_replacer.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/replacer.py b/replacer.py index 4a76749..95aa01d 100644 --- a/replacer.py +++ b/replacer.py @@ -27,11 +27,10 @@ import weechat NAME = 'replacer' AUTHOR = 'Roman Dobosz ' -VERSION = '1.1' +VERSION = '1.2' LICENSE = 'Apache 2' DESC = 'Word replacer for WeeChat' COMMAND = 'replacer' -REPLACE_FILE = os.path.expandvars("$HOME/.weechat/replacement_map.json") COLOR_DELIMITERS = weechat.color('chat_delimiters') COLOR_NICK = weechat.color('chat_nick') @@ -67,7 +66,8 @@ class Replacer(object): self.replacement_map = {} self._path = path if not path: - self._path = REPLACE_FILE + path = '%h/replacement_map.json' + self._path = weechat.string_eval_path_home(path, {}, {}, {}) self._get_replacement_map() def _get_replacement_map(self): diff --git a/test_replacer.py b/test_replacer.py index f188c1f..90d2926 100644 --- a/test_replacer.py +++ b/test_replacer.py @@ -66,6 +66,9 @@ class Weechat(object): def _set_position(self, val): self.position = val + def string_eval_path_home(self, path, pointers, extra_vars, options): + return path + weechat = Weechat() sys.modules['weechat'] = weechat