Friday, April 08, 2005

more elegent solution to cvsview.py

Minor refactoring and fixing:
try:
temp = re.compile(r'\s+')
weekday,month,day,ttime,year=temp.split(date)
hour,minute,second=ttime.split(":")
imonth = {'Jan' : 1, 'Feb' : 2, 'Mar' : 3, 'Apr' : 4, 'May' : 5, 'Jun' : 6, 'Jul' : 7, 'Aug' : 8, 'Sep' : 9, 'Oct' : 10, 'Nov' : 11, 'Dec' : 12 }[month]
sysmodtime = time.mktime(time.gmtime(os.stat(path).st_mtime))#now a float
cvsmodtime = time.mktime([int(year),imonth,int(day),int(hour),int(minute),int(second),0,0,0])#should also be float representation
except OSError:
state = tree.STATE_MISSING
else:
if cvsmodtime == sysmodtime:
state = tree.STATE_NORMAL
else:
state = tree.STATE_MODIFIED

No comments: