#!/usr/bin/python2
import re, time
from string import find
def compareandreversereflist(item1, item2):
if item1[1] > item2[1]:
return (-1)
elif item1[1] == item2[1]:
return (0)
else:
return (1)
pattern = re.compile(r'^((?:\d+\.?){4}) \S \S \[(.*?)\] \"\S+ (\S+) \S+" \d{3} - \"(.*?)\" \".*?\"$')
logfile = open('/logs/blogs.cocoondev.org/http/access_log', 'r')
referrers = {}
for line in logfile.readlines():
linematch = re.match(pattern, line)
if linematch:
refmatch = str(linematch.group(4))
pathmatch = str(linematch.group(3))
if find(pathmatch,'/stevenn/') != -1:
if refmatch != '-':
if find(refmatch,'http://blogs.cocoondev.org/stevenn/') == -1:
if not(referrers.has_key(refmatch)):
referrers[refmatch] = 1
else:
referrers[refmatch] = referrers[refmatch] + 1
list = referrers.items()
list.sort(compareandreversereflist)
print """<html>
<head>
<title>Referrer report</title>
</head>
<body>
<h1 align="center">Referrer report</h1>
<hr>
<ul>"""
for item in list:
print ' <li><a href="' + item[0] + '">' + item[0] + '</a>: ' + str(item[1]) + '</li>'
print """ </ul>
<hr>"""
print ' <p align="center">Generated on ' + time.ctime(time.time()) + '</p>'
print """ </body>
</html>"""
Hm... How difficult should it be to embed that infamous IE RichText/HTML editing thingy into a wxPython app?
It's not hard to embed the IE WebBrowser control into a wxPython app. In fact, one of the wxPython demos does it for you already ;-)
(You need to set the document.designMode field to "On" yourself if you want to use it as an editor rather than a browser, but that's not a lot of work).