]>
git.ipfire.org Git - ipfire-3.x.git/blob - tools/alog2html
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
21 # Author: 08-2008 - Heiner Schmeling #
22 ###############################################################################
25 HEADER
='''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
29 <title>Beschreibung der Seite</title>
30 <style type="text/css">
35 .black{color:#000000;}
37 .green{color:#00ff00;}
38 .yellow{color:#ff0000;}
40 .magenta{color:#ff0000;}
42 .white{color:#ffffff;}
43 .ul {text-decoration:underline}
46 .bggray {background-color:#eeeeee;}
48 .tal {text-align:left;}
49 .tar {text-align:right;}
50 .tac {text-align:center;}
54 <TABLE BORDER="0" cellspacing="0">
65 lineNr
= 0 # Counter for readed lines
66 hg_colStr
='' # define variable for Backgroundcolor
68 ### definition for lots of variable 'linelist'
69 ## linelist=[[pos,fgcolor,hgcolor,bold,text]]
70 # pos = current Cursorposition
71 # fgcolor = Vordergrund Farbe
72 # hgcolor = Hintergrund Farbe
73 # bold = ist Bold aktiv (0/1)
82 line
= raw_input() # read from standard device
83 lineNr
+= 1 # increment linecounter
85 break # break/exit is "End Of File"
88 if len(line
)>0 and line
[-1]=='\x0d' : # evtl. vorhandenen '/r' entfernen
90 line
=line
.replace(sBEL
,sSpace
).strip()
92 isBoldOn
= 0 # is Bold active ?
93 linelist
= [] # define emty list
101 line_split
= line
.split(sESC
) # Split readed line with sESC separator
102 cnt_line_split
= len(line_split
) # len/count of line_split
104 ### decode escape sequences
105 for splitNr
in range(0,cnt_line_split
):
107 lsStr
= line_split
[splitNr
] # string of array (line split string)
109 num_cnt
= 0 # count for numbers
111 if splitNr
== 0 : # split nr 0 have not EscapeSequences
112 new_String
=line_split
[0]
114 test_
= [pos
,colStr
,hg_colStr
,BoldOn
,lsStr
]
115 linelist
.append(test_
)
118 lsStr_len
= len(lsStr
) # Ueberpruefung der Teilstring-Laenge
122 for x1
in range(0,lsStr_len
):
127 if lsStr
[x1
-1] == '0' and isBoldOn
== 1:
130 elif lsStr
[x1
-1] == '1' and isBoldOn
== 0:
134 print 'ERROR: BOLD nicht 0 oder 1'
136 print 'ERROR: >2 Zahlen in fuer BOLD'
137 num_cnt
= 0 # reset count for numbers
139 elif zeichen
.isdigit() :
142 elif zeichen
== 'J' :
145 elif zeichen
== 'H' :
148 elif zeichen
== 'G' :
150 pos
= int(lsStr
[x1
-num_cnt
:x1
])
152 elif zeichen
== 'm' :
174 colStr
='' # reset Color
178 if colStr
<>'' or BoldOn
<>'' :
179 new_String
+='<span class="%s%s">%s</span>' % (colStr
,BoldOn
,lsStr
[x1
+1:])
181 new_String
+=lsStr
[x1
+1:]
185 if not _lsStr
.isspace() :
186 test_
= [pos
,colStr
,hg_colStr
,BoldOn
,_lsStr
]
187 linelist
.append(test_
)
189 new_line_split
.append(_lsStr
)
193 print '<tr class="bggray">'
197 ### first table entry 'linecounter'
198 print '\t<td class="tar">%d: </td>' % (lineNr
)
200 ### other table entrys
201 linelist_cnt
=len(linelist
)
202 if linelist_cnt
> 0 :
204 cnt_bracket
=0 # Count string '[' for Tab's
205 for cnt
in range(0,linelist_cnt
):
206 cnt_bracket
+=linelist
[cnt
][4].count('[')
208 if linelist
[0][4].count('*') == 3 and linelist_cnt
== 5 : # Find 3 x '*'
209 for cnt
in range(0,13):
210 if cnt
== 0 : print '\t<td class="b">%s</td>' % (linelist
[0][4])
211 elif cnt
== 2 : print '\t<td class="tac b">%s</td>' % (linelist
[1][4])
212 elif cnt
== 5 : print '\t<td class="tac b">%s</td>' % (linelist
[2][4])
213 elif cnt
== 8 : print '\t<td class="tac b">%s</td>' % (linelist
[3][4])
214 elif cnt
== 11 : print '\t<td class="tac b">%s</td>' % (linelist
[4][4])
215 else : print '\t<td></td>'
217 cnt_tabs
= linelist_cnt
-(cnt_bracket
*3)
218 for cnt
in range(0,cnt_tabs
) :
220 if linelist
[cnt
][1] or linelist
[cnt
][2] :
221 print '\t<td class="'+linelist
[cnt
][1]+linelist
[cnt
][2]+'">',
224 if linelist
[cnt
][3] :
225 print '<b>'+linelist
[cnt
][4]+'</b>',
227 print linelist
[cnt
][4],
230 if linelist
[0][0] == 0 :
234 for cnt
in range(start
, 13-cnt_bracket
*3 ) : # Fill empty tabs
237 for cnt
in range(cnt_tabs
,linelist_cnt
) :
239 if linelist
[cnt
][1] or linelist
[cnt
][2] or linelist
[cnt
][3] :
240 print '\t<td class="tar '+linelist
[cnt
][1]+linelist
[cnt
][2]+linelist
[cnt
][3]+'">',
243 print linelist
[cnt
][4]+'</td>'
245 print '<p class="red b">traceerror line %s in modul alog2html : <span class="blue">%s</span></p>' % (lineNr
, line
)
249 for cnt
in range(0, 13) : # Fill empty tabs
252 ### close table </tr>