Known subclasses: dulwich.contrib.swift.SwiftPackData

The data contained in a packfile.

Pack files can be accessed both sequentially for exploding a pack, and directly with the help of an index to retrieve a specific object.

The objects within are either complete or a delta against another.

The header is variable length. If the MSB of each byte is set then it indicates that the subsequent byte is still part of the header. For the first byte the next MS bits are the type, which tells you the type of object, and whether it is a delta. The LS byte is the lowest bits of the size. For each subsequent byte the LS 7 bits are the next MS bits of the size, i.e. the last byte of the header contains the MS bits of the size.

For the complete objects the data is stored as zlib deflated data. The size in the header is the uncompressed object size, so to uncompress you need to just keep feeding data to zlib until you get an object back, or it errors on bad data. This is done here by just giving the complete buffer from the start of the deflated object on. This is bad, but until I get mmap sorted out it will have to do.

Currently there are no integrity checks done. Also no attempt is made to try and detect the delta case, or a request for an object at the wrong position. It will all just throw a zlib or KeyError.

Method __init__ Create a PackData object representing the pack in the given filename.
Method filename Undocumented
Method path Undocumented
Class Method from_file Undocumented
Class Method from_path Undocumented
Method close Undocumented
Method __enter__ Undocumented
Method __exit__ Undocumented
Method __len__ Returns the number of objects in this pack.
Method calculate_checksum Calculate the checksum for this pack.
Method get_ref Get the object for a ref SHA, only looking in this pack.
Method resolve_object Resolve an object, possibly resolving deltas when necessary.
Method iterobjects Undocumented
Method iterentries Yield entries summarizing the contents of this pack.
Method sorted_entries Return entries in this pack, sorted by SHA.
Method create_index_v1 Create a version 1 file for this data file.
Method create_index_v2 Create a version 2 index file for this data file.
Method create_index Create an index file for this data file.
Method get_stored_checksum Return the expected checksum stored in this pack.
Method check Check the consistency of this pack.
Method get_compressed_data_at Given offset in the packfile return compressed data that is there.
Method get_object_at Given an offset in to the packfile return the object that is there.
Method _get_size Undocumented
Method _iter_unpacked Undocumented
def __init__(self, filename, file=None, size=None):

Create a PackData object representing the pack in the given filename.

The file must exist and stay readable until the object is disposed of. It must also stay the same size. It will be mapped whenever needed.

Currently there is a restriction on the size of the pack as the python mmap implementation is flawed.

@property
def filename(self):
Undocumented
@property
def path(self):
Undocumented
@classmethod
def from_file(cls, file, size):
Undocumented
@classmethod
def from_path(cls, path):
Undocumented
def close(self):
Undocumented
def __enter__(self):
Undocumented
def __exit__(self, exc_type, exc_val, exc_tb):
Undocumented
def _get_size(self):
Undocumented
def __len__(self):
Returns the number of objects in this pack.
def calculate_checksum(self):
Calculate the checksum for this pack.
Returns20-byte binary SHA1 digest
def get_ref(self, sha):
Get the object for a ref SHA, only looking in this pack.
def resolve_object(self, offset, type, obj, get_ref=None):
Resolve an object, possibly resolving deltas when necessary.
ReturnsTuple with object type and contents.
def iterobjects(self, progress=None, compute_crc32=True):
Undocumented
def _iter_unpacked(self):
Undocumented
def iterentries(self, progress=None):
Yield entries summarizing the contents of this pack.
ParametersprogressProgress function, called with current and total object count.
Returnsiterator of tuples with (sha, offset, crc32)
def sorted_entries(self, progress=None):
Return entries in this pack, sorted by SHA.
ParametersprogressProgress function, called with current and total object count
ReturnsList of tuples with (sha, offset, crc32)
def create_index_v1(self, filename, progress=None):
Create a version 1 file for this data file.
ParametersfilenameIndex filename.
progressProgress report function
ReturnsChecksum of index file
def create_index_v2(self, filename, progress=None):
Create a version 2 index file for this data file.
ParametersfilenameIndex filename.
progressProgress report function
ReturnsChecksum of index file
def create_index(self, filename, progress=None, version=2):
Create an index file for this data file.
ParametersfilenameIndex filename.
progressProgress report function
ReturnsChecksum of index file
def get_stored_checksum(self):
Return the expected checksum stored in this pack.
def check(self):
Check the consistency of this pack.
def get_compressed_data_at(self, offset):

Given offset in the packfile return compressed data that is there.

Using the associated index the location of an object can be looked up, and then the packfile can be asked directly for that object using this function.

def get_object_at(self, offset):

Given an offset in to the packfile return the object that is there.

Using the associated index the location of an object can be looked up, and then the packfile can be asked directly for that object using this function.

API Documentation for Dulwich, generated by pydoctor at 2018-11-17 19:05:54.