def _get_loose_object(self, sha): path = self._get_shafile_path(sha) try: return ShaFile.from_path(path) except (OSError, IOError), e: if e.errno == errno.ENOENT: return None raise
def __getitem__(self, sha): """Obtain an object by SHA1.""" type_num, uncomp = self.get_raw(sha) return ShaFile.from_raw_string(type_num, uncomp)
def iterobjects(self): """Iterate over the objects in this pack.""" for offset, type, obj, crc32 in self.data.iterobjects(): assert isinstance(offset, int) yield ShaFile.from_raw_chunks( *self.data.resolve_object(offset, type, obj))
def __getitem__(self, sha1): """Retrieve the specified SHA1.""" type, uncomp = self.get_raw(sha1) return ShaFile.from_raw_string(type, uncomp)