def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="<STR_LIT>"):
info = self.get_info()<EOL>if format == USTAR_FORMAT:<EOL><INDENT>return self.create_ustar_header(info, encoding, errors)<EOL><DEDENT>elif format == GNU_FORMAT:<EOL><INDENT>return self.create_gnu_header(info, encoding, errors)<EOL><DEDENT>elif format == PAX_FORMAT:<EOL><INDENT>return self.create_pax_header(info, encoding)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
Return a tar header as a string of 512 byte blocks.