MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / tobuf

Method tobuf

tools/python-3.11.9-amd64/Lib/tarfile.py:981–996  ·  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

979 return info
980
981 def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
982 """Return a tar header as a string of 512 byte blocks.
983 """
984 info = self.get_info()
985 for name, value in info.items():
986 if value is None:
987 raise ValueError("%s may not be None" % name)
988
989 if format == USTAR_FORMAT:
990 return self.create_ustar_header(info, encoding, errors)
991 elif format == GNU_FORMAT:
992 return self.create_gnu_header(info, encoding, errors)
993 elif format == PAX_FORMAT:
994 return self.create_pax_header(info, encoding)
995 else:
996 raise ValueError("invalid format")
997
998 def create_ustar_header(self, info, encoding, errors):
999 """Return the object as a ustar header block.

Callers 1

addfileMethod · 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

no test coverage detected