From e05ce661c55fa0602c6974da2b5db6c95b490841 Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Mon, 6 Nov 2017 15:13:24 +0100 Subject: [PATCH] zulip_bots: Enforce default config file schema. This requires the bot's config section to be named after the bot. All config entries must be contained in this section. --- zulip_bots/zulip_bots/lib.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index 1b6f5cc..4f9daaf 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/zulip_bots/zulip_bots/lib.py @@ -119,10 +119,9 @@ class ExternalBotHandler(object): else: self._rate_limit.show_error_and_exit() - def get_config_info(self, bot_name, section=None, optional=False): - # type: (str, Optional[str], Optional[bool]) -> Dict[str, Any] + def get_config_info(self, bot_name, optional=False): + # type: (str, Optional[bool]) -> Dict[str, Any] conf_file_path = os.path.realpath(os.path.join(self._root_dir, bot_name + '.conf')) - section = section or bot_name config = configparser.ConfigParser() try: with open(conf_file_path) as conf: @@ -131,7 +130,7 @@ class ExternalBotHandler(object): if optional: return dict() raise - return dict(config.items(section)) + return dict(config.items(bot_name)) def open(self, filepath): # type: (str) -> IO[str]