From c3b4f997c17e9f6a2516527a12915bcab741331e Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Tue, 20 Oct 2020 10:09:31 +0800 Subject: [PATCH 1/3] add config.ini file and parser for config.ini --- common/parser_config.py | 50 +++++++++++++++++++++++++++++++++++++++++ config/config.ini | 5 +++++ core/runner.py | 7 ++++-- 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 common/parser_config.py diff --git a/common/parser_config.py b/common/parser_config.py new file mode 100644 index 0000000..b9f63a1 --- /dev/null +++ b/common/parser_config.py @@ -0,0 +1,50 @@ +#/bin/env python3 +# -*- encoding=utf8 -*- +""" +created by: miaokaibo +date: 2020-10-20 9:55 + +parser config.ini +""" +import os +import configparser + + +class ParserConfigIni(object): + """ + get parmers from config.ini file + """ + def __init__(self): + """ + init parmers by config.ini + return: None + """ + self.update_enable_flag = {} + config_path = os.path.join( + os.path.split(os.path.realpath(__file__))[0], + "../config/config.ini") + self.config = configparser.ConfigParser() + self.config.read(config_path, encoding='utf-8') + self._init_update_enable_flag() + + def _init_update_enable_flag(self): + """ + init update enable flag for branch from config.ini + return: None + """ + branch_list = self.config.options("update_enable") + for b in branch_list: + self.update_enable_flag[b] = self.config.get("update_enable", b) + + def get_update_enable_flag(self): + """ + get update enable flag for branch + return: update enable flag dict + """ + return self.update_enable_flag + + +if __name__ == "__main__": + p = ParserConfigIni() + update_enable_flag = p.get_update_enable_flag() + print(update_enable_flag) diff --git a/config/config.ini b/config/config.ini index e69de29..489e1fd 100644 --- a/config/config.ini +++ b/config/config.ini @@ -0,0 +1,5 @@ +[update_enable] +master = True +openEuler-20.03-LTS = True +openEuler-20.03-LTS-Next = True +openEuler-20.09 = True diff --git a/core/runner.py b/core/runner.py index 99d7dd0..b198380 100644 --- a/core/runner.py +++ b/core/runner.py @@ -1,9 +1,11 @@ #/bin/env python3 # -*- encoding=utf8 -*- """ +created by: miaokaibo +date: 2020-10-20 9:55 + main script for running """ - from common.log_obs import log @@ -17,7 +19,8 @@ class Runner(object): kwargs: dict, init dict by "a"="A" style return: """ - print(kwargs) + self.kwargs = kwargs + print(self.kwargs) def run(self): """ -- Gitee From 09442ec94b0ba64708e58bb2f8563cfdcbd7d0e4 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Tue, 20 Oct 2020 10:49:30 +0800 Subject: [PATCH 2/3] replace enable by enabled --- common/parser_config.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/parser_config.py b/common/parser_config.py index b9f63a1..3daae4e 100644 --- a/common/parser_config.py +++ b/common/parser_config.py @@ -19,7 +19,7 @@ class ParserConfigIni(object): init parmers by config.ini return: None """ - self.update_enable_flag = {} + self.update_enabled_flag = {} config_path = os.path.join( os.path.split(os.path.realpath(__file__))[0], "../config/config.ini") @@ -34,17 +34,17 @@ class ParserConfigIni(object): """ branch_list = self.config.options("update_enable") for b in branch_list: - self.update_enable_flag[b] = self.config.get("update_enable", b) + self.update_enabled_flag[b] = self.config.get("update_enable", b) - def get_update_enable_flag(self): + def get_update_enabled_flag(self): """ - get update enable flag for branch + get update enabled flag for branch return: update enable flag dict """ - return self.update_enable_flag + return self.update_enabled_flag if __name__ == "__main__": p = ParserConfigIni() - update_enable_flag = p.get_update_enable_flag() - print(update_enable_flag) + update_enabled_flag = p.get_update_enabled_flag() + print(update_enabled_flag) -- Gitee From 320790cc82dd325e5cddd4a8237b7486952daa6f Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Tue, 20 Oct 2020 10:50:46 +0800 Subject: [PATCH 3/3] replace enable by enabled --- common/parser_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/parser_config.py b/common/parser_config.py index 3daae4e..2c9ed42 100644 --- a/common/parser_config.py +++ b/common/parser_config.py @@ -25,9 +25,9 @@ class ParserConfigIni(object): "../config/config.ini") self.config = configparser.ConfigParser() self.config.read(config_path, encoding='utf-8') - self._init_update_enable_flag() + self._init_update_enabled_flag() - def _init_update_enable_flag(self): + def _init_update_enabled_flag(self): """ init update enable flag for branch from config.ini return: None -- Gitee