コード例 #1
0
ファイル: test_attributes.py プロジェクト: thinkyfish/krpc
 def test_get_return_type_attributes(self):
     self.assertEqual([], Attributes.get_return_type_attrs([]))
     self.assertEqual([], Attributes.get_return_type_attrs(
         ['Class.Method(ServiceName.ClassName,MethodName)']))
     self.assertEqual(
         ['Class(ServiceName.ClassName)'],
         Attributes.get_return_type_attrs(
             ['ReturnType.Class(ServiceName.ClassName)']))
     self.assertEqual(
         ['Class(ServiceName.ClassName)'], Attributes.get_return_type_attrs(
             ['Class.Method(ServiceName.ClassName,MethodName)',
              'ReturnType.Class(ServiceName.ClassName)']))
     self.assertEqual(
         ['List(string)'], Attributes.get_return_type_attrs(
             ['ReturnType.List(string)']))
     self.assertEqual(
         ['Dictionary(int32,string)'], Attributes.get_return_type_attrs(
             ['ReturnType.Dictionary(int32,string)']))
     self.assertEqual(
         ['Set(string)'], Attributes.get_return_type_attrs(
             ['ReturnType.Set(string)']))
     self.assertEqual(
         ['List(Dictionary(int32,string))'],
         Attributes.get_return_type_attrs(
             ['ReturnType.List(Dictionary(int32,string))']))
     self.assertEqual(
         ['Dictionary(int32,List(ServiceName.ClassName))'],
         Attributes.get_return_type_attrs(
             ['ReturnType.Dictionary(int32,List(ServiceName.ClassName))']))
コード例 #2
0
 def get_return_type(self, typ, attrs):
     """ Return a type object for the return value with the given
         protocol buffer type and procedure attributes """
     attrs = Attributes.get_return_type_attrs(attrs)
     for attr in attrs:
         try:
             return self.as_type(attr)
         except ValueError:
             pass
     return self.as_type(typ)
コード例 #3
0
ファイル: types.py プロジェクト: rosalesr/krpc
 def get_return_type(self, typ, attrs):
     """ Return a type object for the return value with the given
         protocol buffer type and procedure attributes """
     attrs = Attributes.get_return_type_attrs(attrs)
     for attr in attrs:
         try:
             return self.as_type(attr)
         except ValueError:
             pass
     return self.as_type(typ)
コード例 #4
0
ファイル: test_attributes.py プロジェクト: paperclip/krpc
 def test_get_return_type_attributes(self):
     self.assertEqual([], Attributes.get_return_type_attrs([]))
     self.assertEqual([], Attributes.get_return_type_attrs(
         ['Class.Method(ServiceName.ClassName,MethodName)']))
     self.assertEqual(['Class(ServiceName.ClassName)'], Attributes.get_return_type_attrs(
         ['ReturnType.Class(ServiceName.ClassName)']))
     self.assertEqual(['Class(ServiceName.ClassName)'], Attributes.get_return_type_attrs(
         ['Class.Method(ServiceName.ClassName,MethodName)',
          'ReturnType.Class(ServiceName.ClassName)']))
     self.assertEqual(['List(string)'], Attributes.get_return_type_attrs(
         ['ReturnType.List(string)']))
     self.assertEqual(['Dictionary(int32,string)'], Attributes.get_return_type_attrs(
         ['ReturnType.Dictionary(int32,string)']))
     self.assertEqual(['Set(string)'], Attributes.get_return_type_attrs(
         ['ReturnType.Set(string)']))
     self.assertEqual(['List(Dictionary(int32,string))'], Attributes.get_return_type_attrs(
         ['ReturnType.List(Dictionary(int32,string))']))
     self.assertEqual(['Dictionary(int32,List(ServiceName.ClassName))'], Attributes.get_return_type_attrs(
         ['ReturnType.Dictionary(int32,List(ServiceName.ClassName))']))