<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trim(self, restriction_list):
 """ Trim and reorder the attributes to the specifications in a restriction list. """

        replacement = []
        for reference in restriction_list:
            replacement.append(self.get_attribute(reference))

        if self.has_duplicates(replacement):
            raise AttributeReferenceError('Duplicate attribute reference.')
        self._contents = replacement