'Returns the location of the GnuPG keyring'

def gnupghome(self):

    self.event.running_gpg(_('Checking    GnuPG    home    directory'))
    rv = self.run(['--version'], novercheck=True)[1]['stdout'][0]
    for l in rv.splitlines():
        if l.startswith('Home:    '):
            return os.path.expanduser(l[6:].strip())
    return os.path.expanduser(os.getenv('GNUPGHOME', '~/.gnupg'))
