3 # Script for translating trac.aros.org's RSS feed to html for including
4 # in www.aros.org's commits section.
5 # The result will be stored in htdocs
8 #import ssl # not needed on Sourceforge with Python 2.6
12 # We must set the encoding or HTMLParser().unescape() fails with error
13 # "UnicodeDecodeError: 'ascii' codec can't decode byte..."
16 sys
.setdefaultencoding('utf8')
18 # regex for parsing a RSS item
19 rssre
= re
.compile(r
'''<item>.*?
20 <title>.*?\[(?P<commit>.*?)\].*?</title>.*?
21 <dc:creator>(?P<creator>.*?)</dc:creator>.*?
22 <pubDate>(?P<pubDate>.*?)</pubDate>.*?
23 <link>(?P<link>.*?)</link>.*?
24 <description>(?P<description>.*?)</description>.*?
26 re
.DOTALL | re
.VERBOSE
)
28 count
= 14 # number of entries
29 rsspath
='https://trac.aros.org/trac/timeline?changeset=on&wiki=on&max=%d&authors=&daysback=90&format=rss' % (count
)
30 #ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
31 #rssfile = urllib2.urlopen(rsspath, context=ctx)
32 rssfile
= urllib2
.urlopen(rsspath
)
33 content
= rssfile
.read()
36 targetpath
='/home/project-web/aros/htdocs/commits.php'
37 targetfile
= open(targetpath
, 'w')
39 # output of the content in html format
45 <title>AROS commits</title>
46 <meta charset="UTF-8">
47 <link rel="stylesheet" href="/aros.css">
50 <!--This file is created by script /home/project-web/aros/scripts/updatecommits as cron job -->\n
53 for entry
in rssre
.finditer(content
):
55 <h2><a href="%s" target="_top">%s | %s | %s </a></h2>
58 HTMLParser
.HTMLParser().unescape(entry
.group('commit')),
59 HTMLParser
.HTMLParser().unescape(entry
.group('creator')),
60 HTMLParser
.HTMLParser().unescape(entry
.group('pubDate')),
61 HTMLParser
.HTMLParser().unescape(entry
.group('description'))))
63 targetfile
.write('</body>\n</html>\n')