61: #line 84 "html_weaver.ipk" 62: def _setmode(self,mode): 63: self._write('\n<'+mode+'>') 64: self.mode = mode 65: 66: def _endmode(self): 67: if self.mode: 68: self._write('</'+self.mode+'>\n') 69: self.mode = None 70: 71: def _startmode(self,mode): 72: self._endmode() 73: self._setmode(mode) 74: 75: def _ensuremode(self,mode): 76: if self.mode != mode : self._startmode(mode) 77: 78: def _writeline(self,line): 79: if self.enabled: self.sink.writeline(line) 80: 81: def _write(self,line): 82: if self.enabled: self.sink.write(line) 83: 84: def writeline(self,line=''): 85: self.write(line + '\n') 86: 87: def write(self,line): 88: #hack to correct bug in popular broswers 89: #if not self.mode: self._setmode('P') 90: if self.translating: 91: self._write(cvt_text(line)) 92: else: 93: self._write(line) 94: 95: def writecode(self,line): 96: self._ensuremode('PRE') 97: self._writeline(cvt_code(line)) 98: 99: def begin_displayed_text(self): 100: self._ensuremode('P') 101: # note this is HTML 2, HTML 3 uses BQ instead 102: self.write('<BLOCKQUOTE>') 103: 104: def end_displayed_text(self): 105: self.write('</BLOCKQUOTE>') 106: 107: def begin_displayed_code(self): 108: self._write('<PRE>\n') 109: 110: def end_displayed_code(self): 111: self._write('</PRE>') 112: 113: def line_break(self): 114: self._writeline('<BR>') 115: 116: def page_break(self): 117: self.writeline('<BR><HR>') 118: 119: def write_tagged(self,tag, data): 120: self._write('<'+tag+'>') 121: self._writeline(data) 122: self._write('</'+tag+'>') 123: 124: 125: def code_head(self,tangler, secno): 126: if tangler: 127: self._endmode() 128: filename =tangler.sink.get_sink_name() 129: language = tangler.get_language() 130: 131: self._writeline( '<DIV CLASS="CODE_SECTION_HEAD"><SMALL>Start <EM>'+\ 132: language+'</EM> section to <STRONG>'+\ 133: filename+'['+str(secno)+']</STRONG></SMALL></DIV>') 134: self._writeline( '<DIV CLASS="CODE">') 135: 136: def code_foot(self,tangler, secno): 137: if tangler: 138: self._endmode() 139: filename =tangler.sink.get_sink_name() 140: language = tangler.get_language() 141: self._write( '</DIV><DIV CLASS="CODE_SECTION_FOOT"><SMALL>End <EM>'+\ 142: language+'</EM> section to <STRONG>'+\ 143: filename+'['+str(secno)+']</STRONG></SMALL></DIV>') 144: 145: def script_head(self,language,filename): 146: self._endmode() 147: self._writeline( '<DIV CLASS="CODE_SECTION_HEAD"><SMALL>Start <EM>'+\ 148: language+'</EM> section from <STRONG>'+\ 149: filename+'</STRONG></SMALL></DIV>') 150: self._writeline( '<DIV CLASS="CODE">') 151: 152: def script_foot(self,language,filename): 153: self._endmode() 154: self._write( '</DIV><DIV CLASS="CODE_SECTION_FOOT"><SMALL>End <EM>'+\ 155: language+'</EM> section from <STRONG>'+\ 156: filename+'</STRONG></SMALL></DIV>') 157: 158: def test_output_head(self,command, status): 159: self._endmode() 160: self._writeline( '<DIV CLASS="TEST_OUTPUT_SECTION_HEAD"><SMALL>Start <EM>'+\ 161: 'output</EM> section of <STRONG>'+\ 162: command+'</STRONG></SMALL></DIV>') 163: if status: 164: self._writeline( '<DIV CLASS="TEST_OUTPUT_RESULT"><BIG>Command returned <STRONG>'+\ 165: str(status)+'</STRONG></BIG></DIV>') 166: if status: div_class = 'BAD_TEST_OUTPUT' 167: else: div_class = 'TEST_OUTPUT' 168: self._writeline( '<DIV CLASS="'+div_class+'">') 169: 170: def test_output_foot(self,command,status): 171: self._endmode() 172: self._writeline( '</DIV><DIV CLASS="TEST_OUTPUT_SECTION_FOOT">') 173: self._writeline('<SMALL>End <EM>output</EM> section to <STRONG>'+command+'</STRONG></SMALL></DIV>') 174: 175: def expected_head(self,command): 176: self._endmode() 177: self._writeline( '<DIV CLASS="EXPECTED_OUTPUT_SECTION_HEAD"><SMALL>Start <EM>expected</EM> section of <STRONG>'+command+'</STRONG></SMALL></DIV>') 178: div_class = 'EXPECTED_OUTPUT' 179: self._writeline( '<DIV CLASS="'+div_class+'">') 180: 181: def expected_foot(self,command): 182: self._endmode() 183: self._writeline( '</DIV><DIV CLASS="EXPECTED_OUTPUT_SECTION_FOOT">') 184: self._writeline('<SMALL>End <EM>expected</EM> section to <STRONG>'+command+'</STRONG></SMALL></DIV>') 185: 186: def diff_head(self,command): 187: self._endmode() 188: self._writeline( '<DIV CLASS="DIFF_SECTION_HEAD"><SMALL>Start <EM>diff</EM> section of <STRONG>'+command+'</STRONG></SMALL></DIV>') 189: div_class = 'DIFF' 190: self._writeline( '<DIV CLASS="'+div_class+'">') 191: 192: def diff_foot(self,command): 193: self._endmode() 194: self._writeline( '</DIV><DIV CLASS="DIFF_SECTION_FOOT">') 195: self._writeline('<SMALL>End <EM>diff</EM> section to <STRONG>'+command+'</STRONG></SMALL></DIV>') 196: