parameters: (fpin)
return_statement: return
docstring: Return data from the "End of Central Directory" record, or None.
  
      The data is a list of the nine items in the ZIP "End of central dir"
      record followed by a tenth item, the file seek offset of this record.
docstring_summary: Return data from the "End of Central Directory" record, or None.
docstring_tokens: Return data from the End of Central Directory record or None .
function: def _EndRecData(fpin):
      """Return data from the "End of Central Directory" record, or None.
  
      The data is a list of the nine items in the ZIP "End of central dir"
      record followed by a tenth item, the file seek offset of this record."""
  
      # Determine file size
      fpin.seek(0, 2)
      filesize = fpin.tell()
  
      # Check to see if this is ZIP file with no archive comment (the
      # "end of central directory" structure should be the last item in the
      # file if this is the case).
      try:
          fpin.seek(-sizeEndCentDir, 2)
      except IOError:
          return None
      data = fpin.read()
      if data[0:4] == stringEndArchive and data[-2:] == "\000\000":
          # the signature is correct and there's no comment, unpack structure
          endrec = struct.unpack(structEndArchive, data)
          endrec=list(endrec)
  
          # Append a blank comment and record start offset
          endrec.append("")
          endrec.append(filesize - sizeEndCentDir)
  
          # Try to read the "Zip64 end of central directory" structure
          return _EndRecData64(fpin, -sizeEndCentDir, endrec)
  
      # Either this is not a ZIP file, or it is a ZIP file with an archive
      # comment.  Search the end of the file for the "end of central directory"
      # record signature. The comment is the last item in the ZIP file and may be
      # up to 64K long.  It is assumed that the "end of central directory" magic
      # number does not appear in the comment.
      maxCommentStart = max(filesize - (1 << 16) - sizeEndCentDir, 0)
      fpin.seek(maxCommentStart, 0)
      data = fpin.read()
      start = data.rfind(stringEndArchive)
      if start >= 0:
          # found the magic number; attempt to unpack and interpret
          recData = data[start:start+sizeEndCentDir]
          endrec = list(struct.unpack(structEndArchive, recData))
          comment = data[start+sizeEndCentDir:]
          # check that comment length is correct
          if endrec[_ECD_COMMENT_SIZE] == len(comment):
              # Append the archive comment and start offset
              endrec.append(comment)
              endrec.append(maxCommentStart + start)
  
              # Try to read the "Zip64 end of central directory" structure
              return _EndRecData64(fpin, maxCommentStart + start - filesize,
                                   endrec)
  
      # Unable to find a valid end of central directory structure
      return
function_tokens: def _EndRecData ( fpin ) : # Determine file size fpin . seek ( 0 , 2 ) filesize = fpin . tell ( ) # Check to see if this is ZIP file with no archive comment (the # "end of central directory" structure should be the last item in the # file if this is the case). try : fpin . seek ( - sizeEndCentDir , 2 ) except IOError : return None data = fpin . read ( ) if data [ 0 : 4 ] == stringEndArchive and data [ - 2 : ] == "\000\000" : # the signature is correct and there's no comment, unpack structure endrec = struct . unpack ( structEndArchive , data ) endrec = list ( endrec ) # Append a blank comment and record start offset endrec . append ( "" ) endrec . append ( filesize - sizeEndCentDir ) # Try to read the "Zip64 end of central directory" structure return _EndRecData64 ( fpin , - sizeEndCentDir , endrec ) # Either this is not a ZIP file, or it is a ZIP file with an archive # comment.  Search the end of the file for the "end of central directory" # record signature. The comment is the last item in the ZIP file and may be # up to 64K long.  It is assumed that the "end of central directory" magic # number does not appear in the comment. maxCommentStart = max ( filesize - ( 1 << 16 ) - sizeEndCentDir , 0 ) fpin . seek ( maxCommentStart , 0 ) data = fpin . read ( ) start = data . rfind ( stringEndArchive ) if start >= 0 : # found the magic number; attempt to unpack and interpret recData = data [ start : start + sizeEndCentDir ] endrec = list ( struct . unpack ( structEndArchive , recData ) ) comment = data [ start + sizeEndCentDir : ] # check that comment length is correct if endrec [ _ECD_COMMENT_SIZE ] == len ( comment ) : # Append the archive comment and start offset endrec . append ( comment ) endrec . append ( maxCommentStart + start ) # Try to read the "Zip64 end of central directory" structure return _EndRecData64 ( fpin , maxCommentStart + start - filesize , endrec ) # Unable to find a valid end of central directory structure return