Return a tar header as a string of 512 byte blocks.
(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape")
| 1030 | return info |
| 1031 | |
| 1032 | def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"): |
| 1033 | """Return a tar header as a string of 512 byte blocks. |
| 1034 | """ |
| 1035 | info = self.get_info() |
| 1036 | for name, value in info.items(): |
| 1037 | if value is None: |
| 1038 | raise ValueError("%s may not be None" % name) |
| 1039 | |
| 1040 | if format == USTAR_FORMAT: |
| 1041 | return self.create_ustar_header(info, encoding, errors) |
| 1042 | elif format == GNU_FORMAT: |
| 1043 | return self.create_gnu_header(info, encoding, errors) |
| 1044 | elif format == PAX_FORMAT: |
| 1045 | return self.create_pax_header(info, encoding) |
| 1046 | else: |
| 1047 | raise ValueError("invalid format") |
| 1048 | |
| 1049 | def create_ustar_header(self, info, encoding, errors): |
| 1050 | """Return the object as a ustar header block. |