[ale] PGP / GPG Keysigning Party Reminder... Just 3 days away now.

Michael B. Trausch mike at trausch.us
Tue Dec 6 12:36:40 EST 2011


On 12/06/2011 12:25 PM, Michael B. Trausch wrote:
> On 12/06/2011 11:51 AM, Michael H. Warfield wrote:
>> Understand, though.  We have one key on there that was "delete" by me
>> but it turns out it's still in the keyring, it just doesn't show in the
>> listing on the site.  You'll want to filter out DE2F3D50.  Scott
>> regenerated a new key and that one is not valid.
> 
> My method is pulling from the HTML, using BeautifulSoup, so if it's not
> in the HTML it won't be in my key list.
> 
> 	--- MIke
> 

If anyone is interested, here is the (rather ugly, ATM) script that I'm
using.

------------------------------------------------------
#!/usr/bin/env python

import urllib2
import datetime

from BeautifulSoup import BeautifulSoup, Tag

URL = 'http://biglumber.com/x/web?keyring=4254'

content = urllib2.urlopen(URL).read()
soup = BeautifulSoup(content)

key_table = soup('table')[0]

# Skip the header.
keys = key_table('tr')[1:]

def pdate(date):
    d = date.strip()
    if d == 'None': return None
    return datetime.datetime.strptime(d, '%Y-%m-%d').date()

def print_row(fp, key_type, key_len, created, expires, uids):
    print 'ID OK? [   ]  Fingerprint OK? [   ]  Will Sign? [   ]'

    fp_re = ''
    for i in range(1, len(fp) + 1):
        fp_re += fp[i - 1]
        if (i % 4) == 0: fp_re += ' '

    print '  Raw Fingerprint: {0}'.format(fp)
    print '  Fingerprint: {0}'.format(fp_re)
    print '  Key type and length: {0}/{1}'.format(key_type, key_len)
    print '  Created: {0}'.format(created.strftime('%a, %b %d %Y'))

    if expires is not None:
        print '  Expires: {0}'.format(expires.strftime('%a, %b %d %Y'))
    else:
        print '  Key does not expire'

    print

    print '  UIDs: '
    for uid in uids:
        print '         ', uid

for key in keys:
    fields = key('th')
    fingerprint, j, key_type, j, created_expires = fields[0].contents
    uids = fields[1].contents

    if type(fingerprint) == Tag:
        fingerprint = fingerprint.contents

    if type(fingerprint) == list:
        if len(fingerprint) > 1:
            raise Exception('invalid')
        fingerprint = fingerprint[0]

    key_type, key_length = [x.strip() for x in key_type.split('/')]
    created, expires = [pdate(x) for x in created_expires.split('/')]

    ouids = uids
    uids = []
    for uid in ouids[0]('li'):
        c = uid.contents
        name = c[0][0:-6]
        email = (c[1].contents[0].replace(' "at" ', '@').
                 replace(' DOT ', '.'))

        try:
            if name.index('(') and name.index(')'):
                comment = name[name.index('('):name.index(')') + 1]
                name = name[0:name.index('(') - 1]
        except:
            comment = None

        if comment is None:
            uids.append('"{0}" <{1}>'.format(name, email))
        else:
            uids.append('"{0}" {1} <{2}>'.format(name, comment, email))

    print_row(fingerprint, key_type, key_length, created, expires, uids)
    print
------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 729 bytes
Desc: OpenPGP digital signature
Url : http://mail.ale.org/pipermail/ale/attachments/20111206/b4a777ab/attachment.bin 


More information about the Ale mailing list