72: #line 95 "html_weaver.ipk"
73: def _setmode(self,mode):
74: self._write('\n<'+mode+'>')
75: self.mode = mode
76:
77: def _endmode(self):
78: if self.mode:
79: self._write('</'+self.mode+'>\n')
80: self.mode = None
81:
82: def _startmode(self,mode):
83: self._endmode()
84: self._setmode(mode)
85:
86: def _ensuremode(self,mode):
87: if self.mode != mode : self._startmode(mode)
88:
89: def _writeline(self,line=''):
90: if self.enabled: self.sink.writeline(line)
91:
92: def _write(self,line):
93: if self.enabled: self.sink.write(line)
94:
95: def writeline(self,line=''):
96: self.write(line + '\n')
97:
98: def write(self,line):
99:
100:
101: if self.translating:
102: self._write(cvt_text(line))
103: else:
104: self._write(line)
105:
106: def writecode(self,line):
107: self._ensuremode('PRE')
108: self._writeline(cvt_code(line))
109:
110: def begin_displayed_text(self):
111: self._ensuremode('P')
112:
113: self.write('<BLOCKQUOTE>')
114:
115: def end_displayed_text(self):
116: self.write('</BLOCKQUOTE>')
117:
118: def begin_displayed_code(self):
119: self._write('<PRE>\n')
120:
121: def end_displayed_code(self):
122: self._write('</PRE>')
123:
124: def line_break(self):
125: self._writeline('<BR>')
126:
127: def page_break(self):
128: self._writeline('<BR><HR>')
129:
130: def write_tagged(self,tag, data):
131: self._write('<'+tag+'>')
132: self._writeline(data)
133: self._write('</'+tag+'>')
134:
135: def label_chunk(self, filename):
136: self._ensuremode('PRE')
137: self._write('<I>include</I> <STRONG>')
138: self._writeline(cvt_code(filename)+'</STRONG>')
139:
140: def _write_section_ref(self, filename, index):
141: name = filename + '['+str(index+1)+']'
142: anchor = '<A HREF="'+self.get_anchor(name)+'">'+str(index+1)+'</A>'
143: self._writeline (anchor+' ')
144:
145: def code_head(self,tangler, secno):
146: if tangler:
147: self._endmode()
148: filename =tangler.sink.get_sink_name()
149: language = tangler.get_language()
150: w = self._writeline
151: w ( '<DIV CLASS="CODE_SECTION_HEAD"><SMALL>Start <EM>'+\
152: language+'</EM> section to <STRONG>'+\
153: filename+'['+str(secno)+']</STRONG></SMALL>')
154: dict = self.master.section_index
155: if dict.has_key(filename):
156: nsections = len(dict[filename])
157: for i in range(nsections):
158: self._write_section_ref(filename, i)
159: w ('</DIV>')
160: w ( '<DIV CLASS="CODE">')
161:
162:
163: def code_foot(self,tangler, secno):
164: if tangler:
165: self._endmode()
166: filename =tangler.sink.get_sink_name()
167: language = tangler.get_language()
168: self._write( '</DIV><DIV CLASS="CODE_SECTION_FOOT"><SMALL>End <EM>'+\
169: language+'</EM> section to <STRONG>'+\
170: filename+'['+str(secno)+']</STRONG></SMALL></DIV>')
171:
172: def script_head(self,language,filename):
173: self._endmode()
174: self._writeline( '<DIV CLASS="CODE_SECTION_HEAD"><SMALL>Start <EM>'+\
175: language+'</EM> section from <STRONG>'+\
176: filename+'</STRONG></SMALL></DIV>')
177: self._writeline( '<DIV CLASS="CODE">')
178:
179: def script_foot(self,language,filename):
180: self._endmode()
181: self._write( '</DIV><DIV CLASS="CODE_SECTION_FOOT"><SMALL>End <EM>'+\
182: language+'</EM> section from <STRONG>'+\
183: filename+'</STRONG></SMALL></DIV>')
184:
185: def test_output_head(self,command, status):
186: self._endmode()
187: self._writeline( '<DIV CLASS="TEST_OUTPUT_SECTION_HEAD"><SMALL>Start <EM>'+\
188: 'output</EM> section of <STRONG>'+\
189: cvt_code(command)+'</STRONG></SMALL></DIV>')
190: if status:
191: self._writeline( '<DIV CLASS="TEST_OUTPUT_RESULT">'+\
192: '<BIG>Command returned <STRONG>'+\
193: str(status)+'</STRONG></BIG></DIV>')
194: if status: div_class = 'BAD_TEST_OUTPUT'
195: else: div_class = 'TEST_OUTPUT'
196: self._writeline( '<DIV CLASS="'+div_class+'">')
197:
198: def test_output_foot(self,command,status):
199: self._endmode()
200: self._writeline( '</DIV><DIV CLASS="TEST_OUTPUT_SECTION_FOOT">')
201: self._writeline('<SMALL>End <EM>output</EM> section to <STRONG>'+\
202: cvt_code(command)+'</STRONG></SMALL></DIV>')
203:
204: def expected_head(self,command):
205: self._endmode()
206: self._writeline( '<DIV CLASS="EXPECTED_OUTPUT_SECTION_HEAD">'+\
207: '<SMALL>Start <EM>expected</EM> section of <STRONG>'+\
208: cvt_code(command)+'</STRONG></SMALL></DIV>')
209: div_class = 'EXPECTED_OUTPUT'
210: self._writeline( '<DIV CLASS="'+div_class+'">')
211:
212: def expected_foot(self,command):
213: self._endmode()
214: self._writeline( '</DIV><DIV CLASS="EXPECTED_OUTPUT_SECTION_FOOT">')
215: self._writeline('<SMALL>End <EM>expected</EM> section to <STRONG>'+\
216: cvt_code(command)+'</STRONG></SMALL></DIV>')
217:
218: def diff_head(self,command):
219: self._endmode()
220: self._writeline( '<DIV CLASS="DIFF_SECTION_HEAD"><SMALL>Start <EM>diff</EM> section of <STRONG>'+\
221: cvt_code(command)+'</STRONG></SMALL></DIV>')
222: div_class = 'DIFF'
223: self._writeline( '<DIV CLASS="'+div_class+'">')
224:
225: def diff_foot(self,command):
226: self._endmode()
227: self._writeline( '</DIV><DIV CLASS="DIFF_SECTION_FOOT">')
228: self._writeline('<SMALL>End <EM>diff</EM> section to <STRONG>'+\
229: cvt_code(command)+'</STRONG></SMALL></DIV>')
230: