[Baypiggies] Schedule of upcoming events

Marilyn Davis marilyn at deliberate.com
Fri Apr 21 03:34:06 CEST 2006


On Thu, 20 Apr 2006, Shannon -jj Behrens wrote:

> On 4/20/06, Shannon -jj Behrens <jjinux at gmail.com> wrote:
> > > > I think it's better to have this stuff on baypiggies.net instead of
> > > > emailed around once in a while.  I'm sure Aahz could give you access.
> > > > Having two people work on the matrix is even better.
> > >
> > > I was trying to help get the email version straight.  I didn't mean to
> > > volunteer for web work.  I am web ignorant and staying that way for
> > > now.
> >
> > I'm not going to force you to learn HTML ;)
> >
> > However, a Web site is better than occassional email.  If we need to
> > use a wiki, or if I need to write a script, that's fine, but I think a
> > Web page is the way to go.
> >
> > That's just my $0.02.
> 
> Since this is BayPiggies, I assume you're quite happy to write Python
> ;)  In that case, give us the content in Python:
> 
> meeting = {
>     "date": "2006/06/13",
>     "speaker": "Foo Bar",
>     # ...
> }
> 
> Then, writing a script will be trivial! :-D  Generating the iCal feed
> will also be easy!

I'm not one to trust with typing tasks.  But I made this little script
to parse Dennis' format into a python dictionary.  From there, your script
should be even easier, I hope.

---

#!/usr/bin/env python
'''bap.py parses an email message to gather meeting schedule
information and put it into a dictionary of dictionaries: meeting =
{date_tuple:{'Date':'Wed, Apr 26, 2006', 'Location', 'Google (contact:
Neil)', ...

Call:

bap.py < email_message

or

bap.py file_name

The email message should be in the format that Dennis has been using.
Leading '>'s are ok.  Other stuff in the message is ok, as long as it
doesn't start with a meeting attribute.  If that's a problem, I can
fix it up.

Test data looked like:

On Thu, 20 Apr 2006, Dennis Reinhardt wrote:

> At 03:53 PM 4/20/2006, you wrote:
> >Thank you Dennis.  Good catch.  So we have:
> >
> >
> >Date                     Wed, Apr 26, 2006
> >Location                 Google (contact: Neil)
> >Working Topic Title      Django (Jacob Kaplan-Moss)
> >Topic Organizer          JJ
> >Topic URL(s)
> >Mapping/Random Access    special meeting/none
> >Refreshments
> >Dinner                   TBD
> >Posting (site+c.l.p..)   Aahz
> >--------------------------------
> >Date                     Thu, May 11, 2006
> >Location                 Google (contact: Neil)
> >Working Topic Title      Survey Results/Ctypes
> >Topic Organizer          Stephen
> >Topic URL(s)             pending, http://www.spamai.com/present/
> >Mapping/Random Access    Dennis
> >Refreshments             Donna
> >Dinner                   Brian
> >Posting (site+c.l.p..)   Aahz
> >--------------------------------
> >Date                     Thu, Jun 8, 2006

it outputs the same format, just to show it is working.
'''

import sys
import time

MEETING_ATTRIBUTES = ('Date', 'Location', 'Working Topic Title', 'Topic Organizer',
                      'Topic URL(s)', 'Mapping/Random Access',
                      'Refreshments', 'Dinner', 'Posting (site+c.l.p..)')
meeting = {}

def gather_data(lines):    
    for line in lines:
        line = line.strip('> ')
        if line.startswith('Date'):
            if line.startswith('Date:'): # header line
                continue  
            date_key = time.strptime(line[5:].strip(), "%a, %b %d, %Y")
            meeting[date_key] = {}
        for each in MEETING_ATTRIBUTES:
            if line.startswith(each):
                meeting[date_key][each] = line[len(each):].strip()
                break
    
def main(args):
    if len(args) == 1:
        stream = sys.stdin
    else:
        stream = open(args[1])
    gather_data(stream.readlines())
    report_data()
    
def report_data():
    date_keys = meeting.keys()
    date_keys.sort()
    for date in date_keys:
        for detail in MEETING_ATTRIBUTES:
            try:
                print "%-26s%s" % (detail, meeting[date][detail])
            except KeyError:
                print detail
        print "------------------------------------------"

if __name__ == '__main__':
    main(sys.argv)

''' 
Hope it helps. 

Marilyn

'''



More information about the Baypiggies mailing list