Another spelling fix.
This commit is contained in:
parent
0a8be58623
commit
8e70b9df5e
1 changed files with 33 additions and 33 deletions
|
|
@ -9,7 +9,7 @@ by prettytable but shares no code.
|
||||||
Example usage:
|
Example usage:
|
||||||
|
|
||||||
table = Table("Heading1", "Heading2", table=[[1,2,3],[4,5,6],[7,8,9]], border="cells")
|
table = Table("Heading1", "Heading2", table=[[1,2,3],[4,5,6],[7,8,9]], border="cells")
|
||||||
table.add_collumn("This is long data", "This is even longer data")
|
table.add_column("This is long data", "This is even longer data")
|
||||||
table.add_row("This is a single row")
|
table.add_row("This is a single row")
|
||||||
print table
|
print table
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ make the table symmetric.
|
||||||
|
|
||||||
Tables can be restricted to a given width.
|
Tables can be restricted to a given width.
|
||||||
If we created the above table with the width=50 keyword to Table()
|
If we created the above table with the width=50 keyword to Table()
|
||||||
and then added the extra collumn and row, the result would be
|
and then added the extra column and row, the result would be
|
||||||
|
|
||||||
+-----------+------------+-----------+-----------+
|
+-----------+------------+-----------+-----------+
|
||||||
| Heading1 | Heading2 | | |
|
| Heading1 | Heading2 | | |
|
||||||
|
|
@ -52,7 +52,7 @@ and then added the extra collumn and row, the result would be
|
||||||
| row | | | |
|
| row | | | |
|
||||||
+-----------+------------+-----------+-----------+
|
+-----------+------------+-----------+-----------+
|
||||||
|
|
||||||
When adding new rows/collumns their data can have its
|
When adding new rows/columns their data can have its
|
||||||
own alignments (left/center/right, top/center/bottom).
|
own alignments (left/center/right, top/center/bottom).
|
||||||
|
|
||||||
Contrary to prettytable, Evtable does not allow
|
Contrary to prettytable, Evtable does not allow
|
||||||
|
|
@ -355,26 +355,26 @@ class EvTable(object):
|
||||||
headers for the table
|
headers for the table
|
||||||
|
|
||||||
Keywords:
|
Keywords:
|
||||||
table - list of collumns (list of lists) for seeding
|
table - list of columns (list of lists) for seeding
|
||||||
the table. If not given, the table will start
|
the table. If not given, the table will start
|
||||||
out empty
|
out empty
|
||||||
border - None, or one of
|
border - None, or one of
|
||||||
"table" - only a border around the whole table
|
"table" - only a border around the whole table
|
||||||
"tablecols" - table and collumn borders
|
"tablecols" - table and column borders
|
||||||
"header" - only border under header
|
"header" - only border under header
|
||||||
"cols" - only borders between collumns
|
"cols" - only borders between columns
|
||||||
"rows" - only borders between rows
|
"rows" - only borders between rows
|
||||||
"cells" - border around all cells
|
"cells" - border around all cells
|
||||||
width - fixed width of table. If not set, width is
|
width - fixed width of table. If not set, width is
|
||||||
set by the total width of each collumn.
|
set by the total width of each column.
|
||||||
This will resize individual columns to fit.
|
This will resize individual columns to fit.
|
||||||
|
|
||||||
See also Cell class for kwargs to apply to each
|
See also Cell class for kwargs to apply to each
|
||||||
individual data cell in the table.
|
individual data cell in the table.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# table itself is a 2D grid - a list of collumns
|
# table itself is a 2D grid - a list of columns
|
||||||
# x is the collumn position, y the row
|
# x is the column position, y the row
|
||||||
self.table = kwargs.pop("table", [])
|
self.table = kwargs.pop("table", [])
|
||||||
|
|
||||||
# header is a list of texts. We merge it to the table's top
|
# header is a list of texts. We merge it to the table's top
|
||||||
|
|
@ -532,12 +532,12 @@ class EvTable(object):
|
||||||
"""
|
"""
|
||||||
Balance the table. This means to make sure
|
Balance the table. This means to make sure
|
||||||
all cells on the same row have the same height,
|
all cells on the same row have the same height,
|
||||||
that all collumns have the same number of rows
|
that all columns have the same number of rows
|
||||||
and that the table fits within the given width.
|
and that the table fits within the given width.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# we make all modifications on a working copy of the
|
# we make all modifications on a working copy of the
|
||||||
# actual table. This allows us to add collumns/rows
|
# actual table. This allows us to add columns/rows
|
||||||
# and re-balance over and over without issue.
|
# and re-balance over and over without issue.
|
||||||
self.worktable = deepcopy(self.table)
|
self.worktable = deepcopy(self.table)
|
||||||
|
|
||||||
|
|
@ -559,12 +559,12 @@ class EvTable(object):
|
||||||
# add borders - these add to the width/height, so we must do this before calculating width/height
|
# add borders - these add to the width/height, so we must do this before calculating width/height
|
||||||
self._borders()
|
self._borders()
|
||||||
|
|
||||||
# equalize widths within each collumn
|
# equalize widths within each column
|
||||||
cwidths = [max(cell.get_width() for cell in col) for col in self.worktable]
|
cwidths = [max(cell.get_width() for cell in col) for col in self.worktable]
|
||||||
|
|
||||||
# width of worktable
|
# width of worktable
|
||||||
if self.width:
|
if self.width:
|
||||||
# adjust widths of collumns to fit in worktable width
|
# adjust widths of columns to fit in worktable width
|
||||||
cwidth = self.width // ncols
|
cwidth = self.width // ncols
|
||||||
rest = self.width % ncols
|
rest = self.width % ncols
|
||||||
# get the width of each col, spreading the rest among the first cols
|
# get the width of each col, spreading the rest among the first cols
|
||||||
|
|
@ -589,7 +589,7 @@ class EvTable(object):
|
||||||
|
|
||||||
def _generate_lines(self):
|
def _generate_lines(self):
|
||||||
"""
|
"""
|
||||||
Generates lines across all collumns
|
Generates lines across all columns
|
||||||
(each cell may contain multiple lines)
|
(each cell may contain multiple lines)
|
||||||
Before calling, the table must be
|
Before calling, the table must be
|
||||||
balanced.
|
balanced.
|
||||||
|
|
@ -612,27 +612,27 @@ class EvTable(object):
|
||||||
self.header = True
|
self.header = True
|
||||||
self.add_row(ypos=0, *args, **kwargs)
|
self.add_row(ypos=0, *args, **kwargs)
|
||||||
|
|
||||||
def add_collumn(self, *args, **kwargs):
|
def add_column(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Add a collumn to table. If there are more
|
Add a column to table. If there are more
|
||||||
rows in new collumn than there are rows in the
|
rows in new column than there are rows in the
|
||||||
current table, the table will expand with
|
current table, the table will expand with
|
||||||
empty rows in the other collumns. If too few,
|
empty rows in the other columns. If too few,
|
||||||
the new collumn with get new empty rows. All
|
the new column with get new empty rows. All
|
||||||
filling rows are added to the end.
|
filling rows are added to the end.
|
||||||
keyword-
|
keyword-
|
||||||
header - the header text for the collumn
|
header - the header text for the column
|
||||||
xpos - index position in table before which
|
xpos - index position in table before which
|
||||||
to input new collumn. If not given,
|
to input new column. If not given,
|
||||||
collumn will be added to the end. Uses
|
column will be added to the end. Uses
|
||||||
Python indexing (so first collumn is xpos=0)
|
Python indexing (so first column is xpos=0)
|
||||||
See Cell class for other keyword arguments
|
See Cell class for other keyword arguments
|
||||||
"""
|
"""
|
||||||
# this will replace default options with new ones without changing default
|
# this will replace default options with new ones without changing default
|
||||||
options = dict(self.options.items() + kwargs.items())
|
options = dict(self.options.items() + kwargs.items())
|
||||||
|
|
||||||
xpos = kwargs.get("xpos", None)
|
xpos = kwargs.get("xpos", None)
|
||||||
collumn = [Cell(data, **options) for data in args]
|
column = [Cell(data, **options) for data in args]
|
||||||
htable = self.nrows
|
htable = self.nrows
|
||||||
excess = self.ncols - htable
|
excess = self.ncols - htable
|
||||||
|
|
||||||
|
|
@ -641,23 +641,23 @@ class EvTable(object):
|
||||||
for col in self.table:
|
for col in self.table:
|
||||||
col.extend([Cell("", **options) for i in range(excess)])
|
col.extend([Cell("", **options) for i in range(excess)])
|
||||||
elif excess < 0:
|
elif excess < 0:
|
||||||
# we need to add new rows to new collumn
|
# we need to add new rows to new column
|
||||||
collumn.extend([Cell("", **options) for i in range(abs(excess))])
|
column.extend([Cell("", **options) for i in range(abs(excess))])
|
||||||
|
|
||||||
header = kwargs.get("header", None)
|
header = kwargs.get("header", None)
|
||||||
if header:
|
if header:
|
||||||
collumn.insert(0, Cell(unicode(header), **options))
|
column.insert(0, Cell(unicode(header), **options))
|
||||||
self.header = True
|
self.header = True
|
||||||
elif self.header:
|
elif self.header:
|
||||||
# we have a header already. Offset
|
# we have a header already. Offset
|
||||||
collumn.insert(0, Cell("", **options))
|
column.insert(0, Cell("", **options))
|
||||||
if xpos is None or xpos > len(self.table) - 1:
|
if xpos is None or xpos > len(self.table) - 1:
|
||||||
# add to the end
|
# add to the end
|
||||||
self.table.append(collumn)
|
self.table.append(column)
|
||||||
else:
|
else:
|
||||||
# insert collumn
|
# insert column
|
||||||
xpos = min(len(self.table)-1, max(0, int(xpos)))
|
xpos = min(len(self.table)-1, max(0, int(xpos)))
|
||||||
self.table.insert(xpos, collumn)
|
self.table.insert(xpos, column)
|
||||||
self._balance()
|
self._balance()
|
||||||
|
|
||||||
def add_row(self, *args, **kwargs):
|
def add_row(self, *args, **kwargs):
|
||||||
|
|
@ -665,7 +665,7 @@ class EvTable(object):
|
||||||
Add a row to table (not a header). If there are
|
Add a row to table (not a header). If there are
|
||||||
more cells in the given row than there are cells
|
more cells in the given row than there are cells
|
||||||
in the current table the table will be expanded
|
in the current table the table will be expanded
|
||||||
with empty collumns to match. These will be added
|
with empty columns to match. These will be added
|
||||||
to the end of the table. In the same way, adding
|
to the end of the table. In the same way, adding
|
||||||
a line with too few cells will lead to the last
|
a line with too few cells will lead to the last
|
||||||
ones getting padded.
|
ones getting padded.
|
||||||
|
|
@ -685,7 +685,7 @@ class EvTable(object):
|
||||||
excess = len(row) - len(self.table)
|
excess = len(row) - len(self.table)
|
||||||
|
|
||||||
if excess > 0:
|
if excess > 0:
|
||||||
# we need to add new empty collumns to table
|
# we need to add new empty columns to table
|
||||||
self.table.extend([[Cell("", **options) for i in range(htable)] for k in range(excess)])
|
self.table.extend([[Cell("", **options) for i in range(htable)] for k in range(excess)])
|
||||||
elif excess < 0:
|
elif excess < 0:
|
||||||
# we need to add more cells to row
|
# we need to add more cells to row
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue