#!/usr/bin/env python # -*- coding: ISO-8859-1 -*- #inspired from http://qwiki.stanford.edu/images/d/df/Latex2qwiki.txt import sys, re, os ISSM_DIR=os.getenv('ISSM_DIR'); if(not ISSM_DIR): raise NameError('ISSM_DIR undefined') infile = open('temp','r') outfile = open('temp.html','w') file_text = infile.readlines() #write header outfile.write('\n') style_r='style="text-align:right;"' style_c='style="text-align:center;"' style_l='style="text-align:left;"' color = ' bgcolor=#7AA9DD ' #dark blue color1 = ' bgcolor=#C6E2FF ' #light blue color2 = ' bgcolor=#FFFFFF ' #white count = 0 toggle = 0 for i in range(len(file_text)): #Get current lines except if first line if(i==0): continue line = file_text[i] pattern=r"----------------" if (re.search(pattern,line)): count+=1 continue if(count==1): mystr = '\n' column = 1 for i in line.split(): if(column==1): mystr += ''; column+=1 else: mystr += '' mystr += '\n\n' elif(count==2): total = 0 column = 1 if(toggle): mystr = '\n\n' if(column>=2): total += int(i) if(toggle): mystr += '' else: mystr += '' column += 1 if(toggle): mystr += '\n\n' else: mystr += '\n\n' toggle = 1 - toggle elif(count==3): total = 0 column = 1 if(toggle): mystr = '\n\n' if(column>=2): total += int(i) if(toggle): mystr += '' else: mystr += '' column += 1 if(toggle): mystr += '\n\n' else: mystr += '\n\n' else: continue outfile.write(mystr) #write header outfile.write('
'+i+''+i+'Total
' else: mystr = '
' for i in line.split(): if(not i.isdigit()): mystr += ' '+i+' ' else: if(column==1): mystr += ''+i+''+i+''+str(total)+'
'+str(total)+'
' else: mystr = '
' for i in line.split(): if(not i.isdigit()): mystr += ' '+i+' ' else: if(column==1): mystr += ''+i+''+i+''+str(total)+'
'+str(total)+'
\n') #close all files infile.close() outfile.close()