Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script which outputs a key list with 'X'-es on the keys you've verified.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
Usage: {} <ksp-fosdem.txt> <result.txt>
Marks which keys you have verified from a keysigning party.
Tested on FOSDEM keysigning party 2017.
import sys
import re
def ask(num):
userinput = None
while userinput is None:
userinput = input("{:03d}? (y/N/<num>): ".format(num))
except EOFError:
print("\nEnter y for yes, anything else for no. A number is a shortcut to enter no and jump to that number.")
return userinput
def main(infile, outfile):
with open(infile, 'r') as IN:
lines = IN.readlines()
header = True
xline = re.compile(r'(\d+).+Fingerprint OK.+ID OK')
okline = "{:03d} [x] Fingerprint OK [x] ID OK"
next_num = 0
with open(outfile, 'w') as OUT:
for line in lines:
if header:
print(line, end='', file=OUT)
header = "BEGIN KEY LIST" not in line
m = xline.match(line)
if m:
num = int(
if num >= next_num:
userinput = ask(num)
if userinput.lower() == "y":
print(okline.format(num), file=OUT)
print(line, end='', file=OUT)
usernum = int(userinput)
next_num = usernum
except ValueError:
print(line, end='', file=OUT)
print(line, end='', file=OUT)
if __name__ == "__main__":
if len(sys.argv) != 3:
main(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.