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