code: def is_probably_packed( pe ):
      
  
      # Calculate the lenth of the data up to the end of the last section in the
      # file. Overlay data won't be taken into account
      #
      total_pe_data_length = len( pe.trim() )
      # Assume that the file is packed when no data is available
      if not total_pe_data_length:
          return True
      has_significant_amount_of_compressed_data = False
  
      # If some of the sections have high entropy and they make for more than 20% of the file's size
      # it's assumed that it could be an installer or a packed file
  
      total_compressed_data = 0
      for section in pe.sections:
          s_entropy = section.get_entropy()
          s_length = len( section.get_data() )
          # The value of 7.4 is empircal, based on looking at a few files packed
          # by different packers
          if s_entropy > 7.4:
              total_compressed_data += s_length
  
      if ((1.0 * total_compressed_data)/total_pe_data_length) > .2:
          has_significant_amount_of_compressed_data = True
  
      return has_significant_amount_of_compressed_data
docs: Returns True is there is a high likelihood that a file is packed or contains compressed data.
  
      The sections of the PE file will be analyzed, if enough sections
      look like containing compressed data and the data makes
      up for more than 20% of the total file size, the function will
      return True.