X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Fparser.py;h=c871585915acb30faff5bd59ecb2754307d56a4f;hb=c6755e612b322facefc4edc32e948ab2b00bb3b0;hp=ce5096a3bf31a64bfffb6fb52512e76ebf344228;hpb=14f84a307691cc17d02ec10dd07cf5f3e2c03705;p=bottlenecks.git 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 +