本文整理汇总了Python中Direct.ReductionHelpers.build_properties_dict方法的典型用法代码示例。如果您正苦于以下问题:Python ReductionHelpers.build_properties_dict方法的具体用法?Python ReductionHelpers.build_properties_dict怎么用?Python ReductionHelpers.build_properties_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Direct.ReductionHelpers
的用法示例。
在下文中一共展示了ReductionHelpers.build_properties_dict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testbuild_properties_dict
# 需要导入模块: from Direct import ReductionHelpers [as 别名]
# 或者: from Direct.ReductionHelpers import build_properties_dict [as 别名]
def testbuild_properties_dict(self):
kkdict = {}
kkdict['first']='kkk1:kkk2'
kkdict['kkk1']=19
kkdict['kkk2']=1000
kkdict['other']='unrelated'
kkdict['second']='ssss1:ssss2:third'
kkdict['third']='Babara'
subst = {}
subst['ssss1']='kkk1'
subst['ssss2']='other'
subst_dict,descr = helpers.build_properties_dict(kkdict,subst)
self.assertEqual(len(subst_dict),6)
val = subst_dict['_first']
self.assertTrue(type(val) is helpers.ComplexProperty)
#self.assertEqual(val[0],'kkk1')
#self.assertEqual(val[1],'kkk2')
val = subst_dict['other']
self.assertFalse(type(val) is helpers.ComplexProperty)
self.assertEqual(val,'unrelated')
val = subst_dict['_second']
self.assertTrue(type(val) is helpers.ComplexProperty)
示例2: test_build_properties_dict_ksubst
# 需要导入模块: from Direct import ReductionHelpers [as 别名]
# 或者: from Direct.ReductionHelpers import build_properties_dict [as 别名]
def test_build_properties_dict_ksubst(self):
kkdict = {};
kkdict['first']='kkk1:kkk2';
kkdict['kkk1']=19;
kkdict['kkk2']=1000;
kkdict['other']='unrelated';
kkdict['second']='ssss1:ssss2:third';
kkdict['third']='Babara';
subst = {};
subst['first']=1;
subst['ssss1']='kkk1';
subst['ssss2']='other';
subst['third']=3;
subst['second']=2;
subst_dict,descr_dict = helpers.build_properties_dict(kkdict,subst)
self.assertEqual(len(subst_dict),6);
val = subst_dict['_1']
self.assertTrue(type(val) is helpers.ComplexProperty)
#self.assertEqual(val[0],'kkk1');
#self.assertEqual(val[1],'kkk2');
val = subst_dict['other']
self.assertFalse(type(val) is helpers.ComplexProperty)
self.assertEqual(val,'unrelated');
val = subst_dict['_2']
self.assertTrue(type(val) is helpers.ComplexProperty)
示例3: testbuild_properties_dict_pref
# 需要导入模块: from Direct import ReductionHelpers [as 别名]
# 或者: from Direct.ReductionHelpers import build_properties_dict [as 别名]
def testbuild_properties_dict_pref(self):
kkdict = {}
kkdict['first']='kkk1:kkk2'
kkdict['kkk1']=19
kkdict['kkk2']=1000
kkdict['other']='unrelated'
kkdict['second']='ssss1:ssss2:third'
kkdict['third']='Babara'
kkdict['descr1']='ddd'
kkdict['descr2']='kkk1:kkk2'
kkdict['descr3']=10
subst = {}
subst['ssss1']='kkk1'
subst['ssss2']='other'
subst['descr2']='des222'
prop_dict,desct = helpers.build_properties_dict(kkdict,subst,['descr1','des222','descr3'])
self.assertEqual(len(desct),3)
self.assertEqual(desct['descr3'],10)
self.assertEqual(desct['descr1'],'ddd')
self.assertTrue('des222' in desct.keys())
self.assertEqual(len(prop_dict),6)
val = prop_dict['_first']
self.assertTrue(type(val) is helpers.ComplexProperty)
#elf.assertEqual(val[0],'_kkk1')
#self.assertEqual(val[1],'_kkk2')
val = prop_dict['other']
self.assertFalse(type(val) is helpers.ComplexProperty)
self.assertEqual(val,'unrelated')
val = prop_dict['_second']
self.assertTrue(type(val) is helpers.ComplexProperty)
#self.assertEqual(val[0],'_kkk1')
#self.assertEqual(val[1],'_other')
#self.assertEqual(val[2],'_third')
val = prop_dict['third']
self.assertFalse(type(val) is helpers.ComplexProperty)
self.assertEqual(val,'Babara')
示例4: test_gen_getter
# 需要导入模块: from Direct import ReductionHelpers [as 别名]
# 或者: from Direct.ReductionHelpers import build_properties_dict [as 别名]
def test_gen_getter(self):
kkdict = {}
kkdict['first']='kkk1:kkk2'
kkdict['kkk1']=19
kkdict['kkk2']=1000
kkdict['other']='unrelated'
kkdict['second']='ssss1:ssss2:third'
kkdict['third']='Babara'
subst = {}
subst['ssss1']='kkk1'
subst['ssss2']='other'
subst_dict,descr = helpers.build_properties_dict(kkdict,subst)
self.assertEqual(helpers.gen_getter(subst_dict,'kkk1'),19)
self.assertEqual(helpers.gen_getter(subst_dict,'kkk2'),1000)
self.assertEqual(helpers.gen_getter(subst_dict,'first'),(19,1000))
self.assertEqual(helpers.gen_getter(subst_dict,'other'),'unrelated')
self.assertEqual(helpers.gen_getter(subst_dict,'second'),[19,'unrelated','Babara'])
self.assertEqual(helpers.gen_getter(subst_dict,'third'),'Babara')