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


Python Tree.getval方法代碼示例

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


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

示例1: test_getval_empty

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_getval_empty(self):
     tree = Tree()
     _ = tree[1][2][3]
     self.assertIsNotNone(tree.getval([1]))
     self.assertIsNotNone(tree.getval([1, 2]))
     self.assertIsNone(tree.getval([1, 2, 3]))
     self.assertIsNone(tree.getval([1, 2, 3, 4]))
開發者ID:Jeswang,項目名稱:icarus,代碼行數:9,代碼來源:test_tree.py

示例2: test_nested_setitem

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_nested_setitem(self):
     tree = Tree()
     tree['a'] = {'b': {'c': 1}, 'd': 2}
     self.assertIsInstance(tree, Tree)
     self.assertIsInstance(tree['a'], Tree)
     self.assertIsInstance(tree['a']['b'], Tree)
     self.assertEqual(tree.getval(['a', 'b', 'c']), 1)
     self.assertEqual(tree.getval(['a', 'd']), 2)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:10,代碼來源:test_tree.py

示例3: test_nested_update

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_nested_update(self):
     tree = Tree()
     tree['a'].update({'b': {'c': 1}, 'd': 2})
     self.assertIsInstance(tree, Tree)
     self.assertIsInstance(tree['a'], Tree)
     self.assertIsInstance(tree['a']['b'], Tree)
     self.assertEqual(tree.getval(['a', 'b', 'c']), 1)
     self.assertEqual(tree.getval(['a', 'd']), 2)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:10,代碼來源:test_tree.py

示例4: test_init_from_nested_dict

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_init_from_nested_dict(self):
     tree = Tree({'a': {'c': {'e': 1}}, 'b': {'d': 2}})
     self.assertEqual(tree.getval(['a', 'c', 'e']), 1)
     self.assertEqual(tree.getval(['b', 'd']), 2)
     self.assertIsInstance(tree, Tree)
     self.assertIsInstance(tree['a'], Tree)
     self.assertIsInstance(tree['a']['c'], Tree)
     self.assertIsInstance(tree.getval(['a', 'c']), Tree)
     self.assertIsInstance(tree['b'], Tree)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:11,代碼來源:test_tree.py

示例5: test_update_new_brach

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_update_new_brach(self):
     tree = Tree()
     tree['a'].update({'b': 1, 'c': 2})
     self.assertIsInstance(tree, Tree)
     self.assertIsInstance(tree['a'], Tree)
     self.assertEqual(tree.getval(['a', 'b']), 1)
     self.assertEqual(tree.getval(['a', 'c']), 2)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:9,代碼來源:test_tree.py

示例6: test_update_base

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_update_base(self):
     tree = Tree()
     tree.update({'b': 1, 'c': 2})
     self.assertIsInstance(tree, Tree)
     self.assertEqual(tree.getval(['b']), 1)
     self.assertEqual(tree.getval(['c']), 2)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:8,代碼來源:test_tree.py

示例7: test_init_from_dict_kwargs

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_init_from_dict_kwargs(self):
     tree = Tree({'c': 3}, a=1, b=2)
     self.assertEqual(tree.getval(['a']), 1)
     self.assertEqual(tree.getval(['b']), 2)
     self.assertEqual(tree.getval(['c']), 3)
     self.assertIsInstance(tree, Tree)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:8,代碼來源:test_tree.py

示例8: test_init_from_nested_kwargs

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_init_from_nested_kwargs(self):
     tree = Tree(a=1, b=dict(c=2))
     self.assertEqual(tree.getval(['a']), 1)
     self.assertEqual(tree.getval(['b', 'c']), 2)
     self.assertIsInstance(tree, Tree)
     self.assertIsInstance(tree['b'], Tree)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:8,代碼來源:test_tree.py

示例9: test_init_from_dict

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_init_from_dict(self):
     tree = Tree({'a': 1, 'b': 2})
     self.assertEqual(tree.getval(['a']), 1)
     self.assertEqual(tree.getval(['b']), 2)
     self.assertIsInstance(tree, Tree)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:7,代碼來源:test_tree.py

示例10: test_getval_none

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_getval_none(self):
     tree = Tree()
     self.assertIsNone(tree.getval([1]))
     self.assertIsNone(tree.getval([1, 2]))
     self.assertIsNone(tree.getval([3, 4, 5]))
開發者ID:Jeswang,項目名稱:icarus,代碼行數:7,代碼來源:test_tree.py

示例11: test_getval

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_getval(self):
     tree = Tree()
     tree[1][2][3] = 4
     self.assertEqual(tree.getval([1, 2, 3]), 4)
     self.assertEqual(tree.getval([1, 2])[3], 4)
     self.assertEqual(tree.getval([1])[2][3], 4)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:8,代碼來源:test_tree.py

示例12: test_getset

# 需要導入模塊: from icarus.util import Tree [as 別名]
# 或者: from icarus.util.Tree import getval [as 別名]
 def test_getset(self):
     tree = Tree()
     tree.setval([1, 2, 3, 4], 5)
     self.assertEqual(tree.getval([1, 2, 3, 4]), 5)
開發者ID:Jeswang,項目名稱:icarus,代碼行數:6,代碼來源:test_tree.py


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