|
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 | |
|---|
| 3 | import feedparser |
|---|
| 4 | import random |
|---|
| 5 | import datetime |
|---|
| 6 | |
|---|
| 7 | def 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 | |
|---|
| 22 | def 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 | |
|---|
| 32 | def 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 | |
|---|
| 46 | if __name__ == "__main__": |
|---|
| 47 | make_talk(datetime.date(2008,5,1)) |
|---|