254 return |
254 return |
255 |
255 |
256 # we need a cleanup pass to ensure data is strings - non-unicode and non-null |
256 # we need a cleanup pass to ensure data is strings - non-unicode and non-null |
257 self._cellvalues = self.normalizeData(data) |
257 self._cellvalues = self.normalizeData(data) |
258 if not _seqCW: colWidths = ncols*[colWidths] |
258 if not _seqCW: colWidths = ncols*[colWidths] |
259 elif len(colWidths) != ncols: |
259 elif len(colWidths)!=ncols: |
260 raise ValueError("%s data error - %d columns in data but %d in column widths" % (self.identity(),ncols, len(colWidths))) |
260 if rl_config.allowShortTableRows and isinstance(colWidths,list): |
|
261 n = len(colWidths) |
|
262 if n<ncols: |
|
263 colWidths[n:] = (ncols-n)*[colWidths[-1]] |
|
264 else: |
|
265 colWidths = colWidths[:ncols] |
|
266 else: |
|
267 raise ValueError("%s data error - %d columns in data but %d in column widths" % (self.identity(),ncols, len(colWidths))) |
261 if not _seqRH: rowHeights = nrows*[rowHeights] |
268 if not _seqRH: rowHeights = nrows*[rowHeights] |
262 elif len(rowHeights) != nrows: |
269 elif len(rowHeights) != nrows: |
263 raise ValueError("%s data error - %d rows in data but %d in row heights" % (self.identity(),nrows, len(rowHeights))) |
270 raise ValueError("%s data error - %d rows in data but %d in row heights" % (self.identity(),nrows, len(rowHeights))) |
264 for i in xrange(nrows): |
271 for i,d in enumerate(data): |
265 if len(data[i]) != ncols: |
272 n = len(d) |
266 raise ValueError("%s not enough data columns in row %d!" % (self.identity(),i)) |
273 if n!=ncols: |
|
274 if rl_config.allowShortTableRows and isinstance(d,list): |
|
275 d[n:] = (ncols-n)*[''] |
|
276 else: |
|
277 raise ValueError("%s expected %d not %d columns in row %d!" % (self.identity(),ncols,n,i)) |
267 self._rowHeights = self._argH = rowHeights |
278 self._rowHeights = self._argH = rowHeights |
268 self._colWidths = self._argW = colWidths |
279 self._colWidths = self._argW = colWidths |
269 cellrows = [] |
280 cellrows = [] |
270 for i in xrange(nrows): |
281 for i in xrange(nrows): |
271 cellcols = [] |
282 cellcols = [] |