6.4.5.3. Body Output and Mode Control

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