当前位置: 首页>>代码示例>>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;未经允许,请勿转载。