170: #line 187 "text_weaver.ipk" 171: def __htabrule(self,colw): 172: self._write('+') 173: for w in colw: 174: self._write('-'*(w+2)+'+') 175: self._writeline() 176: 177: def __tabrow(self,colw,data): 178: self._write('|') 179: for i in range(len(colw)): 180: w = colw[i] 181: entry = ' '* w 182: if i<len(data): 183: entry = (data[i]+entry)[:w] 184: self._write(' '+entry+' |') 185: self._writeline() 186: 187: def begin_table(self,*headings, **kwds): 188: self.table_headings = headings 189: self.table_data = [] 190: 191: def table_row(self,data): 192: self.table_data.append(data) 193: 194: def table_rule(self): 195: self.table_data.append(table_rule_object) 196: 197: def end_table(self): 198: width = len(self.table_headings) 199: for row in self.table_data: 200: if row is not table_rule_object: 201: w = len(row) 202: if w>width : width = w 203: colw = [0] * width 204: for i in range(len(self.table_headings)): 205: w = len(self.table_headings[i]) 206: if colw[i]<w: colw[i]=w 207: for row in self.table_data: 208: if row is not table_rule_object: 209: for i in range(len(row)): 210: w = len(row[i]) 211: if colw[i]<w: colw[i]=w 212: self._flush() 213: self._writeline() 214: self.__htabrule(colw) 215: self.__tabrow(colw,self.table_headings) 216: self.__htabrule(colw) 217: for data in self.table_data: 218: if data is table_rule_object: 219: self.__htabrule(colw) 220: else: 221: self.__tabrow(colw,data) 222: self.__htabrule(colw) 223: del self.table_headings 224: del self.table_data 225: