code: def get_single_outfile (directory, archive, extension=""):
      
      outfile = os.path.join(directory, stripext(archive))
      if os.path.exists(outfile + extension):
          # prevent overwriting existing files
          i = 1
          newfile = "%s%d" % (outfile, i)
          while os.path.exists(newfile + extension):
              newfile = "%s%d" % (outfile, i)
              i += 1
          outfile = newfile
      return outfile + extension
docs: Get output filename if archive is in a single file format like gzip.