import sys
import feedparser
import urllib2
from urllib2 import HTTPError, URLError
import logging
import re
def __fetch_feed(url):
try:
feed = feedparser.parse(url)
return feed.entries[0]
except HTTPError, e:
logging.error('Failed with HTTP status code %d' % e.code)
return None
except URLError, e:
logging.error('Failed to connect with network.')
logging.debug('Network failure reason, %s.' % e.reason)
return None
def __append(entry, suffix, append_fn):
latest = __fetch_feed('cmdln_%s.xml' % suffix)
if entry.title.find(latest.title) != -1:
logging.info('Up to date.')
return
f = open('cmdln_%s.xml' % suffix)
o = open('cmdln_%s_out.xml' % suffix, 'w')
first = False
try:
for line in f:
if line.find('
View the More news, commentary, and alternate feeds available at http://thecommandline.net/. View the