當前位置: 首頁>>代碼示例>>Python>>正文


Python vital.ConfigBlock類代碼示例

本文整理匯總了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')
開發者ID:Kitware,項目名稱:vital,代碼行數:7,代碼來源:test_config_block.py

示例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
開發者ID:Kitware,項目名稱:kwiver,代碼行數:28,代碼來源:algorithm.py

示例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)
開發者ID:Kitware,項目名稱:vital,代碼行數:8,代碼來源:test_config_block.py

示例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))
開發者ID:ALouis38,項目名稱:vital,代碼行數:10,代碼來源:test_algo_convert_image.py

示例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)
開發者ID:Kitware,項目名稱:vital,代碼行數:10,代碼來源:test_config_block.py

示例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')
開發者ID:Purg,項目名稱:vital,代碼行數:10,代碼來源:test_algo_convert_image.py

示例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')
開發者ID:ALouis38,項目名稱:vital,代碼行數:7,代碼來源:test_config_block.py

示例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)
開發者ID:Kitware,項目名稱:vital,代碼行數:11,代碼來源:test_config_block.py

示例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')
開發者ID:ALouis38,項目名稱:vital,代碼行數:8,代碼來源:test_config_block.py

示例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)
開發者ID:Kitware,項目名稱:vital,代碼行數:13,代碼來源:test_config_block.py

示例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)
        )
開發者ID:Kitware,項目名稱:vital,代碼行數:14,代碼來源:test_config_block.py

示例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
開發者ID:Kitware,項目名稱:maptk,代碼行數:27,代碼來源:track_features.py

示例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")
開發者ID:Kitware,項目名稱:vital,代碼行數:8,代碼來源:test_config_block.py

示例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')
開發者ID:Kitware,項目名稱:vital,代碼行數:9,代碼來源:test_config_block.py

示例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), "")
開發者ID:Kitware,項目名稱:vital,代碼行數:20,代碼來源:test_config_block.py


注:本文中的vital.ConfigBlock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。