本文整理汇总了Python中rmtoo.lib.configuration.Cfg.Cfg类的典型用法代码示例。如果您正苦于以下问题:Python Cfg类的具体用法?Python Cfg怎么用?Python Cfg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cfg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, config):
cfg = Cfg(config)
Interface.__init__(self, cfg)
tracer.info("called")
self.__topic_root_node = cfg.get_rvalue("topic_root_node")
self.__dirs = {}
self.__setup_directories(cfg)
示例2: __init__
def __init__(self, topic_set, params):
self.topic_set = topic_set
cfg = Cfg(params)
self.output_dir = cfg.get_value('output_directory')
self.html_header_filename = cfg.get_value('header')
self.html_footer_filename = cfg.get_value('footer')
self.read_html_arts()
示例3: main_setup_config
def main_setup_config(args):
"""Setup the config for main()"""
config = Cfg()
DefaultValues.set_default_values(config)
config.merge_cmd_line_params(args)
config.evaluate()
return config
示例4: __init__
def __init__(self, topic_set, params):
self.topic_set = topic_set
cfg = Cfg(params)
self.output_filename = cfg.get_value('output_filename')
self.effort_factor = cfg.get_value_default('effort_factor', 1)
self.req_ids = {}
self.next_id = 1
示例5: rmttest_pos_01
def rmttest_pos_01(self):
"TxtIOConfig: check new max line length setting"
config = Cfg()
config.set_value('max_input_line_length', 77)
tic = TxtIOConfig(config, 'requirement')
assert(tic.get_max_line_length() == 77)
示例6: rmttest_json_init_add_new_cmd_line_params
def rmttest_json_init_add_new_cmd_line_params(self):
'''Init Cfg with JSON and adds parameters with command line options'''
mstderr = StringIO()
init_logger(mstderr)
# Create two JSON files.
tmpdir = create_tmp_dir()
jsonfile1 = os.path.join(tmpdir, "config1.json")
with open(jsonfile1, "w") as jsonfd1:
jsonfd1.write(json.dumps({'k': 2, 'm': {'n': 5}, 'o': 7}))
jsonfile2 = os.path.join(tmpdir, "config2.json")
with open(jsonfile2, "w") as jsonfd2:
jsonfd2.write(json.dumps({'k': 3, 'm': {'w': 11}, 'p': 9}))
config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}')
config.merge_cmd_line_params(['-j', '{"m": {"p": 99}}',
'-j', 'file://' + jsonfile1,
'-j', '{"m": {"q": 100}}',
'-j', 'file://' + jsonfile2])
assert 1 == config.get_value("k"), "k is not 1"
config.evaluate()
assert 3 == config.get_value("k"), "k is not 3"
assert 11 == config.get_value("m.w")
lstderr = hide_volatile(mstderr.getvalue())
shutil.rmtree(tmpdir)
tear_down_log_handler()
assert lstderr == ""
示例7: test_json_init_add_new_cmd_line_params
def test_json_init_add_new_cmd_line_params(self):
'''Init Cfg with JSON and adds parameters with command line options'''
mstderr = StringIO.StringIO()
init_logger(mstderr)
# Create two JSON files.
tmpdir = create_tmp_dir()
jsonfile1 = os.path.join(tmpdir, "config1.json")
jsonfd1 = file(jsonfile1, "w")
jsonfd1.write(json.dumps({'k': 2 , 'm': {'n': 5}, 'o': 7}))
jsonfd1.close()
jsonfile2 = os.path.join(tmpdir, "config2.json")
jsonfd2 = file(jsonfile2, "w")
jsonfd2.write(json.dumps({'k': 3 , 'm': {'w': 11}, 'p': 9}))
jsonfd2.close()
config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}');
config.merge_cmd_line_params(['-j', '{"m": {"p": 99}}',
'-j', 'file://' + jsonfile1,
'-j', '{"m": {"q": 100}}',
'-j', 'file://' + jsonfile2])
self.failUnlessEqual(1, config.get_value("k"), "k is not 1")
config.evaluate()
self.failUnlessEqual(3, config.get_value("k"), "k is not 3")
self.failUnlessEqual(11, config.get_value("m.w"))
lstderr = hide_timestamp(mstderr.getvalue())
tear_down_log_handler()
self.failUnlessEqual(lstderr, "")
示例8: test_neg_05
def test_neg_05(self):
"TestRecordTxt2: long long line - check for lineno"
mstderr = StringIO.StringIO()
init_logger(mstderr)
cfg = Cfg.new_by_json_str('{"max_input_line_length": 7}')
tioconfig = TxtIOConfig(cfg)
txt_doc = TxtRecord.from_string("""# com
ok: yes
no
# cs
# dds
good: but too long
# dds
""",
"TooLong", tioconfig)
self.assertEqual(txt_doc.is_usable(), False)
lstderr = hide_timestamp(mstderr.getvalue())
tear_down_log_handler()
result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;TxtRecord;" \
"check_line_length;77; 80:TooLong:6:line too long: is [18], " \
"max allowed [7]\n"
self.assertEquals(result_expected, lstderr)
示例9: test_json_init_add_new_cmd_line_params
def test_json_init_add_new_cmd_line_params(self):
'''Init Cfg with JSON and adds parameters with command line options'''
log_store = MemLogStore()
# Create two JSON files.
tmpdir = create_tmp_dir()
jsonfile1 = os.path.join(tmpdir, "config1.json")
jsonfd1 = file(jsonfile1, "w")
jsonfd1.write(json.dumps({'k': 2 , 'm': {'n': 5}, 'o': 7}))
jsonfd1.close()
jsonfile2 = os.path.join(tmpdir, "config2.json")
jsonfd2 = file(jsonfile2, "w")
jsonfd2.write(json.dumps({'k': 3 , 'm': {'w': 11}, 'p': 9}))
jsonfd2.close()
config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}');
config.merge_cmd_line_params(['-j', '{"m": {"p": 99}}',
'-j', 'file://' + jsonfile1,
'-j', '{"m": {"q": 100}}',
'-j', 'file://' + jsonfile2])
self.failUnlessEqual(1, config.get_value("k"), "k is not 1")
config.evaluate(log_store)
self.failUnlessEqual(3, config.get_value("k"), "k is not 3")
self.failUnlessEqual(11, config.get_value("m.w"))
self.failUnlessEqual(MemLogStore.create_mls([]), log_store)
示例10: rmttest_positive_03
def rmttest_positive_03(self):
"TopicSet - valid with empty requirement set"
cfg = Cfg()
cfg.set_value('huhuhu.directory',
'tests/unit-test/topic-tests/testdata/topicset01')
cfg.set_value('huhuhu.name', 't01')
cfg.set_value('topics.test-name02.output', {})
cfg.set_value('topic_root_node', 'RootNode')
tvcs = TestVCS(cfg)
tobjcache = ObjectCache()
tinmod = TestInputModules()
TopicSet(cfg, tvcs, "test-name02", tobjcache, tinmod)
示例11: test_dollar_replacement_environment_variables
def test_dollar_replacement_environment_variables(self):
'''Check if the $ replacement works with environment variables.'''
os.environ["huho"] = "ThereIsSomeVal"
config = Cfg.new_by_json_str('{"k": "${ENV:huho}"}')
val = config.get_rvalue("k")
os.environ["huho"] = ""
self.failUnlessEqual("ThereIsSomeVal", val,
"k is not ThereIsSomeVal")
示例12: rmttest_dollar_replacement_environment_variables
def rmttest_dollar_replacement_environment_variables(self):
'''Check if the $ replacement works with environment variables.'''
os.environ["huho"] = "ThereIsSomeVal"
config = Cfg.new_by_json_str('{"k": "${ENV:huho}"}')
val = config.get_rvalue("k")
os.environ["huho"] = ""
assert "ThereIsSomeVal" == val, \
"k is not ThereIsSomeVal"
示例13: __init__
def __init__(self, config):
'''Constructs the standard output parameters based on the
provided config.'''
self._output_filename = None
self._start_date = None
self._end_date = None
self._config = Cfg(config)
self.__parse()
示例14: test_json_init_add_old_cmd_line_params
def test_json_init_add_old_cmd_line_params(self):
'''Init Cfg with JSON and add parameters with command line options'''
config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}');
config.merge_cmd_line_params(['-m', '/tmp/something',
'-c', '/tmp/cmad'])
self.failUnlessEqual(1, config.get_value("k"), "k is not 1")
self.failUnlessEqual({'create_makefile_dependencies': '/tmp/cmad'},
config.get_value("actions").get_dict())
示例15: __init__
def __init__(self, config):
tracer.info("called")
cfg = Cfg(config)
self.__start_vers = cfg.get_value("start_vers")
self.__end_vers = cfg.get_value("end_vers")
self.__topic_root_node = cfg.get_value("topic_root_node")
tracer.debug("start version [%s] end version [%s] "
"topic root node [%s]"
% (self.__start_vers, self.__end_vers,
self.__topic_root_node))
# When the directory is not absolute, convert it to an
# absolute path that it can be compared to the outcome of the
# git.Repo.
self.__dirs = {}
self.__repo_base_dir = None
self.__repo = None
self.__setup_directories(cfg)