summaryrefslogtreecommitdiff
path: root/scripts/poezio_gpg_export
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-08-09 00:59:03 +0200
committermathieui <mathieui@mathieui.net>2018-08-09 00:59:44 +0200
commitadbe62a05739080ef7adf0ba1114653c906f820e (patch)
treeeaf966ce9ce6a7a853a912bfbee1f8145b1c0001 /scripts/poezio_gpg_export
parent05d1800f81ba2e16002751864f1704592efadca3 (diff)
downloadpoezio-adbe62a05739080ef7adf0ba1114653c906f820e.tar.gz
poezio-adbe62a05739080ef7adf0ba1114653c906f820e.tar.bz2
poezio-adbe62a05739080ef7adf0ba1114653c906f820e.tar.xz
poezio-adbe62a05739080ef7adf0ba1114653c906f820e.zip
Remove some more things linked with the gpg plugin
Diffstat (limited to 'scripts/poezio_gpg_export')
-rwxr-xr-xscripts/poezio_gpg_export82
1 files changed, 0 insertions, 82 deletions
diff --git a/scripts/poezio_gpg_export b/scripts/poezio_gpg_export
deleted file mode 100755
index 5b18218f..00000000
--- a/scripts/poezio_gpg_export
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python3
-
-"""
-Parses the output of gpg into a list suitable for the poezio
-GPG plugin. Double-check the output and use at your own risk.
-"""
-
-import subprocess
-import pprint
-import re
-import os
-
-addr_re = re.compile(r'^uid\s+\[\s+full\s+\]\s.*<(.*@.*)>$')
-id_re = re.compile(r'^pub\s+.*/(........) .*')
-
-def extract_block(total):
- """
- GPG output blocks are separated by newlines
- """
- if '' in total:
- index = total.index('')
- else:
- index = len(total)
- block = total[:index]
- total = total[index+1:]
- return (block, total)
-
-def parse_block(blocks, block):
- """
- Keep the blocks with trusted keys
- and extract addresses and UIDs
- """
-
- uid = ''
- addrs = []
- blocksize = len(block)
-
- for i, line in enumerate(reversed(block)):
- if line.startswith('uid'):
- match = addr_re.match(line)
- if match:
- addr = match.groups()[0]
- if addr not in addrs:
- addrs.append(addr)
- else:
- del block[blocksize-1-i]
- elif line.startswith('pub'):
- uid = id_re.match(line).groups()[0]
-
- if addrs:
- blocks[uid] = addrs
-
-def output(blocks):
- print('[keys]')
- for uid in blocks:
- for addr in blocks[uid]:
- print('%s = %s' % (addr, uid))
-
-def main():
-
- os.putenv('LANG', 'en_US.UTF-8')
-
- gpg_proc = subprocess.Popen(
- [
- "/usr/bin/gpg",
- "--list-keys",
- "--list-options",
- "show-uid-validity"
- ],
- stdout=subprocess.PIPE)
-
- result, _ = gpg_proc.communicate()
- result = result.decode().strip().splitlines()[2:]
- blocks = {}
-
- while result:
- block, result = extract_block(result)
- parse_block(blocks, block)
- output(blocks)
-
-if __name__ == '__main__':
- main()