Okay, I'm mentally retarded when it comes to python, I've
been playing with this for way more time than I have free and
it's driving me crazy! I wanna parse a log for some info to
use, sounds easy but it's not. I used to do a bit of PHP and
I know I could do it super easy with that so this is driving
me crazy that it doens't just work. I'm obviously doing
something wrong somewhere I just can't figure out
where.
I'm using code something like this, I want to get a list of
what was installed and when.
import re
r = open('/var/log/pacman.log')
log = r.read()
r.close()
exp = re.compile('\[(.+)\] installed (.+)', re.MULTILINE)
prnt exp.match(log)
Every time it prints 'None" which isn't what I'm after. Basic
debugging says log contains the data I'm chasing. Here's some
sample data from my log, just so you know what I'm working
with.
[03/31/05 12:56] installed envision (CVS_20050330-1)
[03/31/05 12:56] installed xmms2 (050327-3)
[03/31/05 12:56] installed ruby-efl (CVS_20050330-1)
[03/31/05 12:56] installed euphoria (CVS_20050330-1)
[03/31/05 12:56] installed evidence (CVS_20050330-1)
[03/31/05 12:56] installed ruby (1.8.2-4)
[03/31/05 12:59] installed gnome-bluetooth (0.5.1-1)
[03/31/05 13:00] upgraded evas (CVS_20050330-1 -> CVS_20050330-1)
[03/31/05 13:18] installed libast (0.6-1)
Any tips would be greatly appreciated.
Thanks :)