dulwich.archive module

Generates tarballs for Git trees.

class dulwich.archive.ChunkedBytesIO(contents)

Bases: object

Turn a list of bytestrings into a file-like object.

This is similar to creating a BytesIO from a concatenation of the bytestring list, but saves memory by NOT creating one giant bytestring first:

BytesIO(b''.join(list_of_bytestrings)) =~= ChunkedBytesIO(
dulwich.archive.tar_stream(store, tree, mtime, prefix=b'', format='')

Generate a tar stream for the contents of a Git tree.

Returns a generator that lazily assembles a .tar.gz archive, yielding it in pieces (bytestrings). To obtain the complete .tar.gz binary file, simply concatenate these chunks.

  • store – Object store to retrieve objects from

  • tree – Tree object for the tree root

  • mtime – UNIX timestamp that is assigned as the modification time for all files, and the gzip header modification time if format=’gz’

  • format – Optional compression format for tarball