diff options
Diffstat (limited to 'utils/parser.py')
-rw-r--r-- | utils/parser.py | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/utils/parser.py b/utils/parser.py index ce5096a3..c8715859 100644 --- a/utils/parser.py +++ b/utils/parser.py @@ -7,6 +7,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +'''This file realize the function of how to parser a config file. +This contain Two part: +Frist is Init some variables the will be used. +Second is reading config file.''' + import os import yaml @@ -14,6 +19,7 @@ import yaml class Parser(): bottlenecks_config = {} + bottlenecks_test = {} @classmethod def config_init(cls): @@ -35,7 +41,7 @@ class Parser(): cls.config_dir_check(cls.bottlenecks_config["log_dir"]) @classmethod - def config_read(cls, testcase, story_name): + def story_read(cls, testcase, story_name): story_dir = os.path.join( cls.test_dir, testcase, @@ -44,15 +50,23 @@ class Parser(): with open(story_dir) as file: story_parser = yaml.load(file) for case_name in story_parser['testcase']: - testcase_dir = os.path.join( - cls.test_dir, - testcase, - 'testcase_cfg', - case_name) - with open(testcase_dir) as f: - cls.bottlenecks_config[case_name] = yaml.load(f) + Parser.testcase_read(cls, testcase, case_name) + + return cls.bottlenecks_test + + @classmethod + def testcase_read(cls, testcase, testcase_name): - return cls.bottlenecks_config + testcase_dir = os.path.join( + cls.test_dir, + testcase, + 'testcase_cfg', + testcase_name) + testcase_local = testcase_dir + ".yaml" + with open(testcase_local) as f: + cls.bottlenecks_test[testcase_name] = yaml.load(f) + + return cls.bottlenecks_test @classmethod def config_dir_check(cls, dirname): @@ -67,3 +81,4 @@ class Parser(): stack_cfg = testcase_cfg['stack_config'] # TO-DO add cli parameters to stack_config. return test_cfg, stack_cfg + |