'Generate --gen-key input per gpg doc/DETAILS'

def gen_key_input(self, **kwargs):

    parms = {}
    for (key, val) in list(kwargs.items()):
        key = key.replace('_', '-').title()
        parms[key] = val
    parms.setdefault('Key-Type', 'RSA')
    parms.setdefault('Key-Length', 1024)
    parms.setdefault('Name-Real', 'Autogenerated    Key')
    parms.setdefault('Name-Comment', 'Generated    by    gnupg.py')
    try:
        logname = os.environ['LOGNAME']
    except KeyError:
        logname = os.environ['USERNAME']
    hostname = socket.gethostname()
    parms.setdefault('Name-Email', ('%s@%s' % (logname.replace('    ', '_'), hostname)))
    out = ('Key-Type:    %s\n' % parms.pop('Key-Type'))
    for (key, val) in list(parms.items()):
        out += ('%s:    %s\n' % (key, val))
    out += '%commit\n'
    return out
