本文整理匯總了Python中rubick.config_model.Configuration.set_default方法的典型用法代碼示例。如果您正苦於以下問題:Python Configuration.set_default方法的具體用法?Python Configuration.set_default怎麽用?Python Configuration.set_default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rubick.config_model.Configuration
的用法示例。
在下文中一共展示了Configuration.set_default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_subsection_keys
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_subsection_keys(self):
c = Configuration()
c.set_default('%s.param1' % self.section, '123')
c.set('%s.param2' % self.section, '456')
self.assertEqual(
['param1', 'param2'], sorted(c.section(self.section).keys()))
示例2: test_subsection_items
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_subsection_items(self):
c = Configuration()
c.set('%s.param1' % self.section, 'value1')
c.set_default('%s.param2' % self.section, 'value2')
self.assertEqual(
[('param1', 'value1'), ('param2', 'value2')],
sorted(c.section(self.section).items()))
示例3: test_subsection_contains
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_subsection_contains(self):
c = Configuration()
c.set('section1.param1', '123')
c.set_default('section2.param2', '234')
self.assertTrue('param1' in c.section('section1'))
self.assertTrue('param2' in c.section('section2'))
self.assertFalse('param1' in c.section('section2'))
示例4: config
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def config(self):
config = Configuration()
schema = ConfigSchemaRegistry.get_schema('rabbitmq', Version(1000000))
if schema:
for parameter in schema.parameters:
if not parameter.default:
continue
config.set_default(parameter.name, parameter.default)
else:
print("RabbitMQ schema not found")
return config
示例5: _parse_config_resources
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def _parse_config_resources(self, resources, schema=None):
config = Configuration(schema)
# Apply defaults
if schema:
for parameter in filter(lambda p: p.default, schema.parameters):
if not parameter.section or parameter.section == 'DEFAULT':
config.set_default(parameter.name, parameter.default)
else:
config.set_default(
'%s.%s' %
(parameter.section, parameter.name), parameter.default)
for resource in reversed(resources):
self._parse_config_file(
Mark(resource.path), resource.contents, config, schema,
issue_reporter=resource)
return config
示例6: test_is_default_returns_false_if_both_values_set
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_is_default_returns_false_if_both_values_set(self):
c = Configuration()
c.set_default(self.fullparam, self.default_value)
c.set(self.fullparam, self.value)
self.assertFalse(c.is_default(self.fullparam))
示例7: test_is_default_returns_true_if_only_default_value_set
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_is_default_returns_true_if_only_default_value_set(self):
c = Configuration()
c.set_default(self.fullparam, self.default_value)
self.assertTrue(c.is_default(self.fullparam))
示例8: test_contains_default
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_contains_default(self):
c = Configuration()
c.set_default(self.fullparam, self.default_value)
self.assertTrue(c.contains(self.fullparam))
self.assertFalse(c.contains(self.fullparam, ignoreDefault=True))
示例9: test_normal_overrides_default
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_normal_overrides_default(self):
c = Configuration()
c.set(self.fullparam, self.value)
c.set_default(self.fullparam, self.default_value)
self.assertEqual(self.value, c.get(self.fullparam))
示例10: test_keys
# 需要導入模塊: from rubick.config_model import Configuration [as 別名]
# 或者: from rubick.config_model.Configuration import set_default [as 別名]
def test_keys(self):
c = Configuration()
c.set_default('section1.param1', '123')
c.set('section2.param1', '456')
self.assertEqual(['section1', 'section2'], sorted(c.keys()))