code: def guess_mime_file_text (file_prog, filename):
      
      cmd = [file_prog, "--brief", filename]
      try:
          output = backtick(cmd).strip()
      except OSError:
          # ignore errors, as file(1) is only a fallback
          return None
      # match output against known strings
      for matcher, mime in FileText2Mime.items():
          if output.startswith(matcher) and mime in ArchiveMimetypes:
              return mime
      return None
docs: Determine MIME type of filename with file(1).