parameters: (self)
return_statement: return (colspecs, headrows, bodyrows)
docstring: From the data collected by `scan_cell()`, convert to the final data
          structure.
docstring_summary: From the data collected by `scan_cell()`, convert to the final data
          structure.
docstring_tokens: From the data collected by scan_cell () convert to the final data structure .
function: def structure_from_cells(self):
          """
          From the data collected by `scan_cell()`, convert to the final data
          structure.
          """
          rowseps = self.rowseps.keys()   # list of row boundaries
          rowseps.sort()
          rowindex = {}
          for i in range(len(rowseps)):
              rowindex[rowseps[i]] = i    # row boundary -> row number mapping
          colseps = self.colseps.keys()   # list of column boundaries
          colseps.sort()
          colindex = {}
          for i in range(len(colseps)):
              colindex[colseps[i]] = i    # column boundary -> col number map
          colspecs = [(colseps[i] - colseps[i - 1] - 1)
                      for i in range(1, len(colseps))] # list of column widths
          # prepare an empty table with the correct number of rows & columns
          onerow = [None for i in range(len(colseps) - 1)]
          rows = [onerow[:] for i in range(len(rowseps) - 1)]
          # keep track of # of cells remaining; should reduce to zero
          remaining = (len(rowseps) - 1) * (len(colseps) - 1)
          for top, left, bottom, right, block in self.cells:
              rownum = rowindex[top]
              colnum = colindex[left]
              assert rows[rownum][colnum] is None, (
                    'Cell (row %s, column %s) already used.'
                    % (rownum + 1, colnum + 1))
              morerows = rowindex[bottom] - rownum - 1
              morecols = colindex[right] - colnum - 1
              remaining -= (morerows + 1) * (morecols + 1)
              # write the cell into the table
              rows[rownum][colnum] = (morerows, morecols, top + 1, block)
          assert remaining == 0, 'Unused cells remaining.'
          if self.head_body_sep:          # separate head rows from body rows
              numheadrows = rowindex[self.head_body_sep]
              headrows = rows[:numheadrows]
              bodyrows = rows[numheadrows:]
          else:
              headrows = []
              bodyrows = rows
          return (colspecs, headrows, bodyrows)
function_tokens: def structure_from_cells ( self ) : rowseps = self . rowseps . keys ( ) # list of row boundaries rowseps . sort ( ) rowindex = { } for i in range ( len ( rowseps ) ) : rowindex [ rowseps [ i ] ] = i # row boundary -> row number mapping colseps = self . colseps . keys ( ) # list of column boundaries colseps . sort ( ) colindex = { } for i in range ( len ( colseps ) ) : colindex [ colseps [ i ] ] = i # column boundary -> col number map colspecs = [ ( colseps [ i ] - colseps [ i - 1 ] - 1 ) for i in range ( 1 , len ( colseps ) ) ] # list of column widths # prepare an empty table with the correct number of rows & columns onerow = [ None for i in range ( len ( colseps ) - 1 ) ] rows = [ onerow [ : ] for i in range ( len ( rowseps ) - 1 ) ] # keep track of # of cells remaining; should reduce to zero remaining = ( len ( rowseps ) - 1 ) * ( len ( colseps ) - 1 ) for top , left , bottom , right , block in self . cells : rownum = rowindex [ top ] colnum = colindex [ left ] assert rows [ rownum ] [ colnum ] is None , ( 'Cell (row %s, column %s) already used.' % ( rownum + 1 , colnum + 1 ) ) morerows = rowindex [ bottom ] - rownum - 1 morecols = colindex [ right ] - colnum - 1 remaining -= ( morerows + 1 ) * ( morecols + 1 ) # write the cell into the table rows [ rownum ] [ colnum ] = ( morerows , morecols , top + 1 , block ) assert remaining == 0 , 'Unused cells remaining.' if self . head_body_sep : # separate head rows from body rows numheadrows = rowindex [ self . head_body_sep ] headrows = rows [ : numheadrows ] bodyrows = rows [ numheadrows : ] else : headrows = [ ] bodyrows = rows return ( colspecs , headrows , bodyrows )