本文整理汇总了Python中vital.ConfigBlock类的典型用法代码示例。如果您正苦于以下问题:Python ConfigBlock类的具体用法?Python ConfigBlock怎么用?Python ConfigBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_fail
def test_write_fail(self):
cb = ConfigBlock()
cb.set_value('foo', 'bar')
nose.tools.assert_raises(VitalConfigBlockIoException,
cb.write,
'/not/valid')
示例2: get_config
def get_config(self, cb=None):
"""
Return this algorithm's current configuration.
As algorithms are named, the configuration returned will be contained
inside a sub-block whose name matches this algorithm's name in order
to separate
:param cb: An optional existing ConfigBlock instance to add this
algorithm's configuration to.
:type cb: ConfigBlock
:return: This named algorithm's current configuration. If a config block
was given to this method, the same config block is returned.
:rtype: vital.ConfigBlock
"""
if cb is None:
cb = ConfigBlock()
self._call_cfunc(
'vital_algorithm_%s_get_type_config' % self.type_name(),
[ctypes.c_char_p, self.C_TYPE_PTR, ConfigBlock.c_ptr_type()],
[self.name, self, cb],
ConfigBlock.c_ptr_type()
)
return cb
示例3: test_subblock_view_match
def test_subblock_view_match(self):
cb = ConfigBlock()
bname = 'block'
va = 'va'
cb.set_value(bname, va)
sb = cb.subblock_view(bname)
keys = sb.available_keys()
nose.tools.assert_equal(len(keys), 0)
示例4: test_check_conf
def test_check_conf(self):
ci = ConvertImage('ci')
c = ConfigBlock()
nt.assert_false(ci.check_config(c))
c.set_value('ci:type', '')
nt.assert_false(ci.check_config(c))
c.set_value('ci:type', 'not_an_impl')
nt.assert_false(ci.check_config(c))
示例5: test_subblock_view_prefix_match
def test_subblock_view_prefix_match(self):
cb = ConfigBlock()
bname = 'block'
ka = 'ka'
va = 'va'
# intentionally not adding block separator
cb.set_value(bname + ka, va)
sb = cb.subblock_view(bname)
keys = sb.available_keys()
nose.tools.assert_equal(len(keys), 0)
示例6: test_set_conf
def test_set_conf(self):
ci = ConvertImage('ci')
nt.assert_false(ci)
nt.assert_is_none(ci.impl_name())
c = ConfigBlock()
c.set_value('ci:type', 'bypass')
ci.set_config(c)
nt.assert_true(ci)
nt.assert_equal(ci.impl_name(), 'bypass')
示例7: test_read_only_unset
def test_read_only_unset(self):
cb = ConfigBlock()
cb.set_value('a', '1')
cb.mark_read_only('a')
cb.unset_value('a')
nose.tools.assert_true(cb.has_value('a'))
nose.tools.assert_equal(cb.get_value('a'), '1')
示例8: test_get_value_no_exist
def test_get_value_no_exist(self):
cb = ConfigBlock()
k1 = 'a'
k2 = 'b'
v2 = '2'
nose.tools.assert_raises(
VitalConfigBlockNoSuchValueException,
cb.get_value, k1
)
nose.tools.assert_equal(cb.get_value(k2, v2), v2)
示例9: test_read_only
def test_read_only(self):
cb = ConfigBlock()
cb.set_value('a', '1')
cb.mark_read_only('a')
nose.tools.assert_equal(cb.get_value('a'), '1')
cb.set_value('a', '2')
nose.tools.assert_equal(cb.get_value('a'), '1')
示例10: test_get_value_nested
def test_get_value_nested(self):
cb = ConfigBlock()
k1 = 'a'
k2 = 'b'
v = 'c'
cb.set_value(k1 + ConfigBlock.BLOCK_SEP + k2, v)
nose.tools.assert_equal(cb.get_value(k1 + ConfigBlock.BLOCK_SEP + k2),
v)
sb = cb.subblock(k1)
nose.tools.assert_equal(sb.get_value(k2), v)
示例11: test_get_value_bool_default
def test_get_value_bool_default(self):
cb = ConfigBlock()
nose.tools.assert_raises(
VitalConfigBlockNoSuchValueException,
cb.get_value_bool, 'not-a-key'
)
nose.tools.assert_true(
cb.get_value_bool('not-a-key', True)
)
nose.tools.assert_false(
cb.get_value_bool('not-a-key', False)
)
示例12: default_config_block
def default_config_block():
c = ConfigBlock()
c.set_value('image_list_file',
'',
'Path to an input file containing new-line separated paths to '
'sequential image files')
c.set_value('mask_list_file',
'',
'Optional path to an input file containing new-line '
'separated paths to mask images. This list should be '
'parallel in association to files specified in '
'``image_list_file``. Mask image must be the same size as '
'the image they are associated with.\n'
'\n'
'Leave this blank if no image masking is desired.')
c.set_value('output_tracks_file',
'',
'Path to a file to write output tracks to. If this file '
'exists, it will be overwritten.')
image_reader, image_converter, feature_tracker = base_algorithms()
image_reader.get_config(c)
image_converter.get_config(c)
feature_tracker.get_config(c)
return c
示例13: test_set_value
def test_set_value(self):
cb = ConfigBlock()
# Basic value string
cb.set_value('foo', 'bar')
# Should attempt casting non-string to string
cb.set_value('bar', 124789)
# Setting with a description
cb.set_value('baz', 'a', "This is a description")
示例14: test_get_value
def test_get_value(self):
cb = ConfigBlock()
cb.set_value('a', 'b')
cb.set_value('longer_value:foo', "BarBazThing")
nose.tools.assert_equal(cb.get_value('a'), 'b')
nose.tools.assert_equal(cb.get_value('longer_value:foo'),
'BarBazThing')
示例15: test_set_value_description
def test_set_value_description(self):
cb = ConfigBlock()
bname = 'sub'
ka = 'ka'
kb = 'kb'
kc = 'kc'
va = 'va'
vb = 'vb'
vc = 'vc'
da = 'da'
db = 'db'
cb.set_value(ka, va, da)
cb.set_value(bname + ConfigBlock.BLOCK_SEP + kb, vb, db)
cb.set_value(kc, vc)
sb = cb.subblock('sub')
nose.tools.assert_equal(cb.get_description(ka), da)
nose.tools.assert_equal(sb.get_description(kb), db)
nose.tools.assert_equal(cb.get_description(kc), "")