def _RealGetContents(self):
fp = self.fp<EOL>try:<EOL><INDENT>endrec = _EndRecData(fp)<EOL><DEDENT>except IOError:<EOL><INDENT>raise BadZipfile("<STR_LIT>")<EOL><DEDENT>if not endrec:<EOL><INDENT>raise BadZipfile("<STR_LIT>")<EOL><DEDENT>if self.debug > <NUM_LIT:1>:<EOL><INDENT>print(endrec)<EOL><DEDENT>size_cd = endrec[_ECD_SIZE]             <EOL>offset_cd = endrec[_ECD_OFFSET]         <EOL>self.comment = endrec[_ECD_COMMENT]     <EOL>concat = endrec[_ECD_LOCATION] - size_cd - offset_cd<EOL>if endrec[_ECD_SIGNATURE] == stringEndArchive64:<EOL><INDENT>concat -= (sizeEndCentDir64 + sizeEndCentDir64Locator)<EOL><DEDENT>if self.debug > <NUM_LIT:2>:<EOL><INDENT>inferred = concat + offset_cd<EOL>print("<STR_LIT>", offset_cd, inferred, concat)<EOL><DEDENT>self.start_dir = offset_cd + concat<EOL>fp.seek(self.start_dir, <NUM_LIT:0>)<EOL>data = fp.read(size_cd)<EOL>fp = StringIO.StringIO(data)<EOL>total = <NUM_LIT:0><EOL>while total < size_cd:<EOL><INDENT>centdir = fp.read(sizeCentralDir)<EOL>if centdir[<NUM_LIT:0>:<NUM_LIT:4>] != stringCentralDir:<EOL><INDENT>raise BadZipfile("<STR_LIT>")<EOL><DEDENT>centdir = struct.unpack(structCentralDir, centdir)<EOL>if self.debug > <NUM_LIT:2>:<EOL><INDENT>print(centdir)<EOL><DEDENT>filename = fp.read(centdir[_CD_FILENAME_LENGTH])<EOL>x = ZipInfo(filename)<EOL>x.extra = fp.read(centdir[_CD_EXTRA_FIELD_LENGTH])<EOL>x.comment = fp.read(centdir[_CD_COMMENT_LENGTH])<EOL>x.header_offset = centdir[_CD_LOCAL_HEADER_OFFSET]<EOL>(x.create_version, x.create_system, x.extract_version, x.reserved,<EOL>x.flag_bits, x.compress_type, t, d,<EOL>x.CRC, x.compress_size, x.file_size) = centdir[<NUM_LIT:1>:<NUM_LIT:12>]<EOL>x.volume, x.internal_attr, x.external_attr = centdir[<NUM_LIT:15>:<NUM_LIT>]<EOL>x._raw_time = t<EOL>x.date_time = ( (d>><NUM_LIT:9>)+<NUM_LIT>, (d>><NUM_LIT:5>)&<NUM_LIT>, d&<NUM_LIT>,<EOL>t>><NUM_LIT:11>, (t>><NUM_LIT:5>)&<NUM_LIT>, (t&<NUM_LIT>) * <NUM_LIT:2> )<EOL>x._decodeExtra()<EOL>x.header_offset = x.header_offset + concat<EOL>x.filename = x._decodeFilename()<EOL>self.filelist.append(x)<EOL>self.NameToInfo[x.filename] = x<EOL>total = (total + sizeCentralDir + centdir[_CD_FILENAME_LENGTH]<EOL>+ centdir[_CD_EXTRA_FIELD_LENGTH]<EOL>+ centdir[_CD_COMMENT_LENGTH])<EOL>if self.debug > <NUM_LIT:2>:<EOL><INDENT>print("<STR_LIT>", total)<EOL><DEDENT><DEDENT>
Read in the table of contents for the ZIP file.