|
def | __init__ (self, pack_or_index_path) |
|
def | close (self) |
|
def | info (self, sha) |
|
def | stream (self, sha) |
|
def | info_at_index (self, index) |
|
def | stream_at_index (self, index) |
|
def | pack (self) |
|
def | index (self) |
|
def | is_valid_stream (self, sha, use_crc=False) |
|
def | info_iter (self) |
|
def | stream_iter (self) |
|
def | collect_streams_at_offset (self, offset) |
|
def | collect_streams (self, sha) |
|
def | write_pack (cls, object_iter, pack_write, index_write=None, object_count=None, zlib_compression=zlib.Z_BEST_SPEED) |
|
def | create (cls, object_iter, base_dir, object_count=None, zlib_compression=zlib.Z_BEST_SPEED) |
|
def | __getattr__ (self, attr) |
|
Combines the PackIndexFile and the PackFile into one, allowing the
actual objects to be resolved and iterated
def collect_streams |
( |
|
self, |
|
|
|
sha |
|
) |
| |
As ``PackFile.collect_streams``, but takes a sha instead of an offset.
Additionally, ref_delta streams will be resolved within this pack.
If this is not possible, the stream will be left alone, hence it is adivsed
to check for unresolved ref-deltas and resolve them before attempting to
construct a delta stream.
:param sha: 20 byte sha1 specifying the object whose related streams you want to collect
:return: list of streams, first being the actual object delta, the last being
a possibly unresolved base object.
:raise BadObject:
def is_valid_stream |
( |
|
self, |
|
|
|
sha, |
|
|
|
use_crc = False |
|
) |
| |
Verify that the stream at the given sha is valid.
:param use_crc: if True, the index' crc is run over the compressed stream of
the object, which is much faster than checking the sha1. It is also
more prone to unnoticed corruption or manipulation.
:param sha: 20 byte sha1 of the object whose stream to verify
whether the compressed stream of the object is valid. If it is
a delta, this only verifies that the delta's data is valid, not the
data of the actual undeltified object, as it depends on more than
just this stream.
If False, the object will be decompressed and the sha generated. It must
match the given sha
:return: True if the stream is valid
:raise UnsupportedOperation: If the index is version 1 only
:raise BadObject: sha was not found
def write_pack |
( |
|
cls, |
|
|
|
object_iter, |
|
|
|
pack_write, |
|
|
|
index_write = None , |
|
|
|
object_count = None , |
|
|
|
zlib_compression = zlib.Z_BEST_SPEED |
|
) |
| |
Create a new pack by putting all objects obtained by the object_iterator
into a pack which is written using the pack_write method.
The respective index is produced as well if index_write is not Non.
:param object_iter: iterator yielding odb output objects
:param pack_write: function to receive strings to write into the pack stream
:param indx_write: if not None, the function writes the index file corresponding
to the pack.
:param object_count: if you can provide the amount of objects in your iteration,
this would be the place to put it. Otherwise we have to pre-iterate and store
all items into a list to get the number, which uses more memory than necessary.
:param zlib_compression: the zlib compression level to use
:return: tuple(pack_sha, index_binsha) binary sha over all the contents of the pack
and over all contents of the index. If index_write was None, index_binsha will be None
**Note:** The destination of the write functions is up to the user. It could
be a socket, or a file for instance
**Note:** writes only undeltified objects