MCPcopy Index your code
hub / github.com/python/cpython / tobuf

Method tobuf

Lib/tarfile.py:1032–1047  ·  view source on GitHub ↗

Return a tar header as a string of 512 byte blocks.

(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape")

Source from the content-addressed store, hash-verified

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.

Callers 9

test_ignore_zerosMethod · 0.95
test_ustar_limitsMethod · 0.95
test_gnu_limitsMethod · 0.95
test_pax_limitsMethod · 0.95
addfileMethod · 0.80
test_premature_eofMethod · 0.80
test_trailing_garbageMethod · 0.80
_test_partial_inputMethod · 0.80

Calls 5

get_infoMethod · 0.95
create_ustar_headerMethod · 0.95
create_gnu_headerMethod · 0.95
create_pax_headerMethod · 0.95
itemsMethod · 0.45

Tested by 7

test_ignore_zerosMethod · 0.76
test_ustar_limitsMethod · 0.76
test_gnu_limitsMethod · 0.76
test_pax_limitsMethod · 0.76
test_premature_eofMethod · 0.64
test_trailing_garbageMethod · 0.64
_test_partial_inputMethod · 0.64