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


Python ConfigBlock.subblock方法代碼示例

本文整理匯總了Python中vital.ConfigBlock.subblock方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigBlock.subblock方法的具體用法?Python ConfigBlock.subblock怎麽用?Python ConfigBlock.subblock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vital.ConfigBlock的用法示例。


在下文中一共展示了ConfigBlock.subblock方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_subblock_match

# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock [as 別名]
    def test_subblock_match(self):
        cb = ConfigBlock()

        b_name = 'block'
        va = 'va'

        cb.set_value(b_name, va)
        sb = cb.subblock(b_name)
        keys = sb.available_keys()
        nose.tools.assert_equal(len(keys), 0)
開發者ID:Kitware,項目名稱:vital,代碼行數:12,代碼來源:test_config_block.py

示例2: test_subblock_prefix_match

# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock [as 別名]
    def test_subblock_prefix_match(self):
        cb = ConfigBlock()

        b_name = 'block'
        ka = 'ka'
        va = 'va'

        # intentionally not adding block separator
        cb.set_value(b_name + ka, va)
        sb = cb.subblock(b_name)
        keys = sb.available_keys()
        nose.tools.assert_equal(len(keys), 0)
開發者ID:Kitware,項目名稱:vital,代碼行數:14,代碼來源:test_config_block.py

示例3: test_get_value_nested

# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock [as 別名]
    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,代碼行數:15,代碼來源:test_config_block.py

示例4: test_set_value_description

# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock [as 別名]
    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,代碼行數:22,代碼來源:test_config_block.py

示例5: test_subblock_nested

# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock [as 別名]
    def test_subblock_nested(self):
        cb = ConfigBlock()

        block_name = 'block'
        other_name = 'other'
        nestd_name = block_name + ConfigBlock.BLOCK_SEP + other_name

        ka = 'ka'
        kb = 'kb'
        va = 'va'
        vb = 'vb'

        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + kb, vb)

        sb = cb.subblock(nestd_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_equal(sb.get_value(ka), va)
        nose.tools.assert_true(sb.has_value(kb))
        nose.tools.assert_equal(sb.get_value(kb), vb)
開發者ID:Kitware,項目名稱:vital,代碼行數:23,代碼來源:test_config_block.py

示例6: test_subblock

# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import subblock [as 別名]
    def test_subblock(self):
        cb = ConfigBlock()

        block_name = 'block'
        other_name = 'other_block'
        ka = 'keya'
        kb = 'keyb'
        kc = 'keyc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb.set_value(block_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(block_name + ConfigBlock.BLOCK_SEP + kb, vb)
        cb.set_value(other_name + ConfigBlock.BLOCK_SEP + kc, vc)

        sb = cb.subblock(block_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_equal(sb.get_value(ka), va)
        nose.tools.assert_true(sb.has_value(kb))
        nose.tools.assert_equal(sb.get_value(kb), vb)
        nose.tools.assert_false(sb.has_value(kc))
開發者ID:Kitware,項目名稱:vital,代碼行數:25,代碼來源:test_config_block.py


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