本文整理匯總了Python中krpc.attributes.Attributes.get_parameter_type_attrs方法的典型用法代碼示例。如果您正苦於以下問題:Python Attributes.get_parameter_type_attrs方法的具體用法?Python Attributes.get_parameter_type_attrs怎麽用?Python Attributes.get_parameter_type_attrs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類krpc.attributes.Attributes
的用法示例。
在下文中一共展示了Attributes.get_parameter_type_attrs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_parameter_type
# 需要導入模塊: from krpc.attributes import Attributes [as 別名]
# 或者: from krpc.attributes.Attributes import get_parameter_type_attrs [as 別名]
def get_parameter_type(self, pos, typ, attrs):
""" Return a type object for a parameter at the given
position, with the given protocol buffer type and attributes """
attrs = Attributes.get_parameter_type_attrs(pos, attrs)
for attr in attrs:
try:
return self.as_type(attr)
except ValueError:
pass
return self.as_type(typ)
示例2: test_get_parameter_type_attributes
# 需要導入模塊: from krpc.attributes import Attributes [as 別名]
# 或者: from krpc.attributes.Attributes import get_parameter_type_attrs [as 別名]
def test_get_parameter_type_attributes(self):
self.assertEqual([], Attributes.get_parameter_type_attrs(0, []))
self.assertEqual([], Attributes.get_parameter_type_attrs(
0, ['Class.Method(ServiceName.ClassName,MethodName)']))
self.assertEqual([], Attributes.get_parameter_type_attrs(
0, ['ReturnType.Class(ServiceName.ClassName)']))
self.assertEqual([], Attributes.get_parameter_type_attrs(
0, ['Class.Method(ServiceName.ClassName,MethodName)',
'ReturnType.Class(ServiceName.ClassName)']))
self.assertEqual([], Attributes.get_parameter_type_attrs(
1, ['ParameterType(2).Class(ServiceName.ClassName)']))
self.assertEqual(['Class(ServiceName.ClassName)'], Attributes.get_parameter_type_attrs(
2, ['ParameterType(2).Class(ServiceName.ClassName)']))
self.assertEqual(['Class(ServiceName.ClassName2)'], Attributes.get_parameter_type_attrs(
2, ['ParameterType(0).Class(ServiceName.ClassName1)',
'ParameterType(2).Class(ServiceName.ClassName2)']))
self.assertEqual(['Class(ServiceName.ClassName)'], Attributes.get_parameter_type_attrs(
1, ['Class.Method(ServiceName.ClassName,MethodName)',
'ParameterType(1).Class(ServiceName.ClassName)']))
self.assertEqual(['List(string)'], Attributes.get_parameter_type_attrs(
1, ['ParameterType(1).List(string)']))
self.assertEqual(['Dictionary(int32,string)'], Attributes.get_parameter_type_attrs(
1, ['ParameterType(1).Dictionary(int32,string)']))
self.assertEqual(['Set(string)'], Attributes.get_parameter_type_attrs(
1, ['ParameterType(1).Set(string)']))
self.assertEqual(['List(Dictionary(int32,string))'], Attributes.get_parameter_type_attrs(
1, ['ParameterType(1).List(Dictionary(int32,string))']))
self.assertEqual(['Dictionary(int32,List(ServiceName.ClassName))'], Attributes.get_parameter_type_attrs(
1, ['ParameterType(1).Dictionary(int32,List(ServiceName.ClassName))']))