# copyright 1999 McMillan Enterprises, Inc. # license: use as you please. No warranty. # # A subclass of Archive that can be understood # by a C program. See uplaunch.cpp for unpacking # from C. #carchive_rt is a stripped down version of MEInc.Dist.carchive. #It has had all building logic removed. #It's purpose is to bootstrap the Python installation. import archive_rt import struct import zlib import strop class CTOC: ENTRYSTRUCT = 'iiiibc' #(structlen, dpos, dlen, ulen, flag, typcd) followed by name def __init__(self): self.data = [] def frombinary(self, s): entrylen = struct.calcsize(self.ENTRYSTRUCT) p = 0 while p -1: ## typcd = 'M' ## self.toc.add(where, dlen, ulen, flag, typcd, nm) ## self.lib.write(s) ## ## def save_toc(self, tocpos): ## self.tocpos = tocpos ## tocstr = self.toc.tobinary() ## self.toclen = len(tocstr) ## self.lib.write(tocstr) ## ## def save_trailer(self, tocpos): ## totallen = tocpos + self.toclen + self.TRLLEN ## trl = struct.pack(self.TRLSTRUCT, self.MAGIC, totallen, ## tocpos, self.toclen) ## self.lib.write(trl) def openEmbedded(self, name): ndx = self.toc.find(name) if ndx == -1: raise KeyError, "Member '%s' not found in %s" % (name, self.path) (dpos, dlen, ulen, flag, typcd, nm) = self.toc.get(ndx) if flag: raise ValueError, "Cannot open compressed archive %s in place" return CArchive(self.path, self.pkgstart+dpos, dlen)