From: Marvin Liu <yong.liu@intel.com>
To: dts@dpdk.org
Cc: Marvin Liu <yong.liu@intel.com>
Subject: [dts] [PATCH v2] framework/config: utilize eval to parse configurations
Date: Tue, 9 Jan 2018 17:55:38 -0500 [thread overview]
Message-ID: <1515538538-76050-1-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1515356602-45882-1-git-send-email-yong.liu@intel.com>
Suite config will utilize python eval command to parse configurations.
It will be easy to generate list or dictionary type of suite/case
configuration.
v2: by default paramater will taken as string, no need to use quotation
marks
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/framework/config.py b/framework/config.py
index 80f1dd3..f7f347a 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -44,7 +44,6 @@ PORTCONF = "%s/ports.cfg" % CONFIG_ROOT_PATH
CRBCONF = "%s/crbs.cfg" % CONFIG_ROOT_PATH
VIRTCONF = "%s/virt_global.cfg" % CONFIG_ROOT_PATH
IXIACONF = "%s/ixia.cfg" % CONFIG_ROOT_PATH
-SUITECONF_SAMPLE = "%s/suite_sample.cfg" % CONFIG_ROOT_PATH
GLOBALCONF = "%s/global_suite.cfg" % CONFIG_ROOT_PATH
@@ -142,23 +141,7 @@ class SuiteConf(UserConf):
conf = dict(case_confs)
for key, data_string in conf.items():
- if data_string.startswith("value_int:"):
- value = data_string[len("value_int:"):]
- case_cfg[key] = int(value)
- elif data_string.startswith("value_hex:"):
- value = data_string[len("value_hex:"):]
- case_cfg[key] = int(value, 16)
- elif data_string.startswith("list_int:"):
- value = data_string[len("list_int:"):]
- datas = value.split(',')
- int_list = map(lambda x: int(x), datas)
- case_cfg[key] = int_list
- elif data_string.startswith("list_str:"):
- value = data_string[len("list_str:"):]
- str_list = value.split(',')
- case_cfg[key] = str_list
- else:
- case_cfg[key] = data_string
+ case_cfg[key] = eval(data_string)
return case_cfg
@@ -422,6 +405,6 @@ if __name__ == '__main__':
print ixiaconf.load_ixia_config()
# example for suite configure file
- suiteconf = SuiteConf(SUITECONF_SAMPLE)
+ suiteconf = SuiteConf("suite_sample")
print suiteconf.load_case_config("case1")
print suiteconf.load_case_config("case2")
--
1.9.3
prev parent reply other threads:[~2018-01-10 6:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-07 20:23 [dts] [PATCH v1] " Marvin Liu
2018-01-09 22:55 ` Marvin Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1515538538-76050-1-git-send-email-yong.liu@intel.com \
--to=yong.liu@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).