From b889b3329f3c518cf52ff77319faec49a78a6a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 31 Aug 2022 16:03:09 +0200 Subject: [PATCH] poezio/core/completions: Use Config from Core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio/core/completions.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/poezio/core/completions.py b/poezio/core/completions.py index 1cb934c0..a9e16f41 100644 --- a/poezio/core/completions.py +++ b/poezio/core/completions.py @@ -12,7 +12,6 @@ from slixmpp import JID, InvalidJID from poezio import common from poezio import tabs from poezio.libpoezio import XDG -from poezio.config import config from poezio.roster import roster from poezio.core.structs import POSSIBLE_SHOW, Completion @@ -80,7 +79,7 @@ class CompletionCore: def theme(self, the_input): """ Completion for /theme""" - themes_dir = config.getstr('themes_dir') + themes_dir = self.core.config.getstr('themes_dir') themes_dir = Path(themes_dir).expanduser( ) if themes_dir else XDG.data_dir / 'themes' try: @@ -221,7 +220,7 @@ class CompletionCore: nicks = [tab.own_nick] if tab else [] default = os.environ.get('USER') if os.environ.get( 'USER') else 'poezio' - nick = config.getstr('default_nick') + nick = self.core.config.getstr('default_nick') if not nick: if default not in nicks: nicks.append(default) @@ -358,8 +357,8 @@ class CompletionCore: for section in plugin.config.sections() ] else: - end_list = set(config.options('Poezio')) - end_list.update(config.default.get('Poezio', {})) + end_list = set(self.core.config.options('Poezio')) + end_list.update(self.core.config.default.get('Poezio', {})) end_list = list(end_list) end_list.sort() elif n == 2: @@ -375,14 +374,14 @@ class CompletionCore: plugin.config.default.get(section or plugin_name, {})) end_list = list(end_list) end_list.sort() - elif not config.has_option('Poezio', args[1]): - if config.has_section(args[1]): - end_list = config.options(args[1]) + elif not self.core.config.has_option('Poezio', args[1]): + if self.core.config.has_section(args[1]): + end_list = self.core.config.options(args[1]) end_list.append('') else: end_list = [] else: - end_list = [str(config.get(args[1], '')), ''] + end_list = [str(self.core.config.get(args[1], '')), ''] elif n == 3: if '|' in args[1]: plugin_name, section = args[1].split('|')[:2] @@ -396,10 +395,10 @@ class CompletionCore: or plugin_name)), '' ] else: - if not config.has_section(args[1]): + if not self.core.config.has_section(args[1]): end_list = [''] else: - end_list = [str(config.get(args[2], '', args[1])), ''] + end_list = [str(self.core.config.get(args[2], '', args[1])), ''] else: return False return Completion(the_input.new_completion, end_list, n, quotify=True) @@ -411,7 +410,7 @@ class CompletionCore: n = the_input.get_argument_position(quoted=True) if n >= len(args): args.append('') - if n == 1 or (n == 2 and config.has_section(args[1])): + if n == 1 or (n == 2 and self.core.config.has_section(args[1])): return Completion(self.set, the_input) return False @@ -419,7 +418,7 @@ class CompletionCore: "Completion for /toggle" return Completion( the_input.new_completion, - config.options('Poezio'), + self.core.config.options('Poezio'), 1, quotify=False) @@ -438,7 +437,7 @@ class CompletionCore: nicks = [tab.own_nick] if tab else [] default = os.environ.get('USER') if os.environ.get( 'USER') else 'poezio' - nick = config.getstr('default_nick') + nick = self.core.config.getstr('default_nick') if not nick: if default not in nicks: nicks.append(default)