def _set_attribute_on_managed_object(self, managed_object, attribute):
attribute_name = attribute[<NUM_LIT:0>]<EOL>attribute_value = attribute[<NUM_LIT:1>]<EOL>if self._attribute_policy.is_attribute_multivalued(attribute_name):<EOL><INDENT>if attribute_name == '<STR_LIT:Name>':<EOL><INDENT>managed_object.names.extend(<EOL>[x.name_value.value for x in attribute_value]<EOL>)<EOL>for name in managed_object.names:<EOL><INDENT>if managed_object.names.count(name) > <NUM_LIT:1>:<EOL><INDENT>raise exceptions.InvalidField(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise exceptions.InvalidField(<EOL>"<STR_LIT>".format(attribute_name)<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>field = None<EOL>value = attribute_value.value<EOL>if attribute_name == '<STR_LIT>':<EOL><INDENT>field = '<STR_LIT>'<EOL><DEDENT>elif attribute_name == '<STR_LIT>':<EOL><INDENT>field = '<STR_LIT>'<EOL><DEDENT>elif attribute_name == '<STR_LIT>':<EOL><INDENT>field = '<STR_LIT>'<EOL>value = list()<EOL>for e in enums.CryptographicUsageMask:<EOL><INDENT>if e.value & attribute_value.value:<EOL><INDENT>value.append(e)<EOL><DEDENT><DEDENT><DEDENT>elif attribute_name == '<STR_LIT>':<EOL><INDENT>field = '<STR_LIT>'<EOL><DEDENT>if field:<EOL><INDENT>existing_value = getattr(managed_object, field)<EOL>if existing_value:<EOL><INDENT>if existing_value != value:<EOL><INDENT>raise exceptions.InvalidField(<EOL>"<STR_LIT>".format(<EOL>attribute_name<EOL>)<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>setattr(managed_object, field, value)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise exceptions.InvalidField(<EOL>"<STR_LIT>".format(attribute_name)<EOL>)<EOL><DEDENT><DEDENT>
Set the attribute value on the kmip.pie managed object.