'Set the output format for the class instance.'

def set_output_format(self, format):

    self.output_format = format.lower()
    try:
        self.serializer = self.output_formats[self.output_format]
    except KeyError as e:
        valid_formats = list(self.output_formats.keys())
        valid_formats.sort()
        message = (u'Invalid    Output    Format:    "%s".    Use    one    of    %s.' % (self.output_format, ((u'"' + u'",    "'.join(valid_formats)) + u'"')))
        e.args = ((message,) + e.args[1:])
        raise
    return self
