Пример #1
0
 def dict_from_object(cls, stream_obj):
     """Parse and return a dictionary for a Stream Object object"""
     stream_dict = {}
     if stream_obj.get_Hash() is not None:
         Hashes = []
         for Hash_obj in stream_obj.get_Hash():
             Hashes.append(Hash.dict_from_object(Hash_obj))
         stream_dict['Hashes'] = Hashes
     if stream_obj.get_Name() is not None: stream_dict['name'] = Base_Object_Attribute.dict_from_object(stream_obj.get_Name())
     if stream_obj.get_Size_In_Bytes() is not None: stream_dict['size_in_bytes'] = Base_Object_Attribute.dict_from_object(stream_obj.get_Size_In_Bytes())
     return stream_dict   
Пример #2
0
 def object_from_dict(cls, stream_dict):
     """Create the Stream Object object representation from an input dictionary"""
     stream_obj = win_file_binding.StreamObjectType()
     for key, value in stream_dict:
         if key == 'Hashes' : 
             for Hash_dict in value:
                 Hash_obj = Hash.object_from_dict(Hash_dict)
                 if Hash_obj.hasContent_() : stream_obj.add_Hash(Hash_obj)
         elif key == 'name' and utils.test_value(value):
             stream_obj.set_Name(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),value))
         elif key == 'size_in_bytes' and utils.test_value(value):
             stream_obj.set_Size_In_Bytes(Base_Object_Attribute.object_from_dict(common_types_binding.UnsignedLongObjectAttributeType(datatype='UnsignedLong'),value))       
     return stream_obj
Пример #3
0
 def test_round_trip2(self):
     hash_dict = {'simple_hash_value': EMPTY_MD5,
                  'type': Hash.TYPE_MD5}
     hash_obj = Hash.object_from_dict(hash_dict)
     hash_dict2 = Hash.dict_from_object(hash_obj)
     self.assertEqual(hash_dict, hash_dict2)