don't check when its clang masquerading as gcc
[AROS.git] / scripts / updatecommits
blobed9ca07f24bae188814c3acb2e5bdb422eb4ebfe
1 #!/usr/bin/python
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
7 import urllib2
8 #import ssl # not needed on Sourceforge with Python 2.6
9 import re
10 import HTMLParser
12 # We must set the encoding or HTMLParser().unescape() fails with error
13 # "UnicodeDecodeError: 'ascii' codec can't decode byte..."
14 import sys
15 reload(sys)
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>.*?
25 </item>''',
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()
34 rssfile.close()
36 targetpath='/home/project-web/aros/htdocs/commits.php'
37 targetfile = open(targetpath, 'w')
39 # output of the content in html format
41 targetfile.write('''
42 <!DOCTYPE html>
43 <html>
44 <head>
45 <title>AROS commits</title>
46 <meta charset="UTF-8">
47 <link rel="stylesheet" href="/aros.css">
48 </head>
49 <body>
50 <!--This file is created by script /home/project-web/aros/scripts/updatecommits as cron job -->\n
51 ''')
53 for entry in rssre.finditer(content):
54 targetfile.write('''
55 <h2><a href="%s" target="_top">%s | %s | %s </a></h2>
56 %s\n''' % (
57 entry.group('link'),
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')
65 targetfile.close()