code: def compress_artifact_if_supported(artifact_path):
      
      content_type, encoding = guess_content_type_and_encoding(artifact_path)
      log.debug('"{}" is encoded with "{}" and has mime/type "{}"'.format(artifact_path, encoding, content_type))
  
      if encoding is None and content_type in _GZIP_SUPPORTED_CONTENT_TYPE:
          log.info('"{}" can be gzip\'d. Compressing...'.format(artifact_path))
          with open(artifact_path, 'rb') as f_in:
              text_content = f_in.read()
  
          with gzip.open(artifact_path, 'wb') as f_out:
              f_out.write(text_content)
  
          encoding = 'gzip'
          log.info('"{}" compressed'.format(artifact_path))
      else:
          log.debug('"{}" is not supported for compression.'.format(artifact_path))
  
      return content_type, encoding
docs: Compress artifacts with GZip if they're known to be supported.
  
      This replaces the artifact given by a gzip binary.
  
      Args:
          artifact_path (str): the path to compress
  
      Returns:
          content_type, content_encoding (tuple):  Type and encoding of the file. Encoding equals 'gzip' if compressed.