'sign file'

def sign_file(self, file, keyid=None, passphrase=None, clearsign=True, detach=False, binary=False):

    logger.debug('sign_file:    %s', file)
    if binary:
        args = ['-s']
    else:
        args = ['-sa']
    if detach:
        args.append('--detach-sign')
    elif clearsign:
        args.append('--clearsign')
    if keyid:
        args.append(('--default-key    "%s"' % keyid))
    args.extend(['--no-version', "--comment    ''"])
    result = self.result_map['sign'](self)
    p = self._open_subprocess(args, (passphrase is not None))
    try:
        stdin = p.stdin
        if passphrase:
            _write_passphrase(stdin, passphrase, self.encoding)
        writer = _threaded_copy_data(file, stdin)
    except IOError:
        logging.exception('error    writing    message')
        writer = None
    self._collect_output(p, result, writer, stdin)
    return result
