[ale] PGP / GPG Keysigning Party Reminder... Just 3 days away now.
Scott Castaline
skotchman at gmail.com
Tue Dec 6 17:55:20 EST 2011
On 12/06/2011 12:36 PM, Michael B. Trausch wrote:
> 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
>
Diamond in the rough! Works fine, thanks
Scott C.
More information about the Ale
mailing list