root/hodgestar/PythonCode/SmallScripts/ctpug-talk-generator.py

Revision 382, 1.3 kB (checked in by simon, 4 years ago)

Add Jeremy.

  • Property svn:mime-type set to text/python-source
  • Property svn:eol-style set to native
Line 
1"""Generate topics for CTPUG Talks."""
2
3import feedparser
4import random
5import datetime
6
7def daily_python_url_entries(oLastTalk):
8    """Gather entries from the Daily Python-URL RSS feed that
9       are more recent than the last talk.
10       
11       http://www.pythonware.com/daily/rss.xml
12       """
13    sFeedUrl = "http://www.pythonware.com/daily/rss.xml"
14    oFeed = feedparser.parse(sFeedUrl)
15    aEntries = []
16    for oE in oFeed.entries:
17        oUpdatedOn = datetime.datetime(*oE.updated_parsed[:6])
18        if oUpdatedOn.date() >= oLastTalk:
19            aEntries.append(oE)
20    return aEntries
21
22def speakers():
23    """Return a list of available speakers."""
24    return [
25        "Neil Muller",
26        "Neil Blakey-Milner",
27        "Jonathan Hitchcock",
28        "Simon Cross",
29        "Jeremy Thurgood",
30    ]
31
32def make_talk(oLastTalk):
33    """Randomly select a topic and a talk."""
34    aTopics = daily_python_url_entries(oLastTalk)
35    aSpeakers = speakers()
36
37    oTopic = random.choice(aTopics)
38    sSpeaker = random.choice(aSpeakers)
39
40    print sSpeaker, "will give a talk on:"
41    print "----------------------------"
42    print oTopic.summary_detail['value']
43    print "----------------------------"
44    print oTopic.link
45
46if __name__ == "__main__":
47    make_talk(datetime.date(2008,5,1))
Note: See TracBrowser for help on using the browser.