Created
September 27, 2017 10:02
-
-
Save F30/388ff62601eaa53e9f2ce247443e3ad4 to your computer and use it in GitHub Desktop.
List GPG Ownertrust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import os | |
import gnupg | |
TRUST_LEVEL_MAP = { | |
'q': '???', | |
'n': 'Not', | |
'm': 'Marginal', | |
'f': 'Full', | |
'u': 'Ultimate' | |
} | |
def main(): | |
gpg = gnupg.GPG() | |
gpg.encoding = 'utf-8' | |
keys = gpg.list_keys() | |
trust_keys = filter(lambda k: k['ownertrust'] != '-', keys) | |
for key in trust_keys: | |
trust_level = TRUST_LEVEL_MAP[key['ownertrust']] | |
print('{} {:<59} {}'.format(key['keyid'], key['uids'][0], trust_level)) | |
return os.EX_OK | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minor suggestions update for more in-line with a different style of python3 syntax =)