Skip to content

Instantly share code, notes, and snippets.

@gadamc
Created January 28, 2013 23:13
Show Gist options
  • Save gadamc/4660174 to your computer and use it in GitHub Desktop.
Save gadamc/4660174 to your computer and use it in GitHub Desktop.
create a log file from SVN and use the following python code to edit it and make some plots
#!/usr/bin/env python
import datetime
import re
from ROOT import TH1D, TFile
fname = 'mylog'
tlf = open(fname,'r')
stdate = int(datetime.datetime(2010,1,1).strftime('%s'))
endate = int(datetime.datetime(2013,4,1).strftime('%s'))
orf = TFile(fname + '.root','recreate')
hist = TH1D('hist','hist',30, stdate, endate)
authordic = {}
def getDate(rd):
try:
date_epoch = datetime.datetime.strptime(revDate, '%Y-%m-%d %H:%M:%S -0800').strftime('%s')
return date_epoch
except:
date_epoch = datetime.datetime.strptime(revDate, '%Y-%m-%d %H:%M:%S -0700').strftime('%s')
return date_epoch
for aline in tlf:
if re.match('r[0-9]+',aline):
sline = aline.split('|')
#print sline
revDate = sline[2].split('(')[0].strip(' ')
revNum = sline[0].split('r')[1].strip(' ')
author = sline[1].strip(' ')
if author not in authordic:
authordic[author] = 1
elif author in authordic:
authordic[author] = authordic[author] + 1
date_epoch = float(getDate(revDate))
hist.Fill(date_epoch)
print revNum, ":", date_epoch
print authordic
hist.Draw()
raw_input()
hist.Write()
orf.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment