smartcols API Reference¶
Note
str represents both the types str and unicode. It is not compatible with the bytes type.
Warning
Don’t try to use copy.copy() or copy.deepcopy(), it’s not
implemented and can break things.
Cell¶
- class smartcols.Cell¶
Cell.
There is no way to create cell, only way to get this object is from
smartcols.Line.
Title¶
- class smartcols.Title¶
Title.
There is no way to create title, only way to get this object is from
smartcols.Table.
Column¶
Line¶
- class smartcols.Line(self, parent=None)¶
Line.
- Parameters:
parent (smartcols.Line) – Parent line (used if table has column with tree-output)
Get cell
>>> table = smartcols.Table() >>> column = table.new_column("FOO") >>> line = table.new_line() >>> line[column] <smartcols.Cell object at 0x7f8fb6cc9900>
Set text to cell
>>> table = smartcols.Table() >>> column = table.new_column("FOO") >>> line = table.new_line() >>> line[column] = "bar"
Symbols¶
- class smartcols.Symbols(self)¶
Symbols.
Table¶
- class smartcols.Table(self)¶
Table.
Create and print table
>>> table = smartcols.Table() >>> column_name = table.new_column("NAME") >>> column_age = table.new_column("AGE") >>> column_age.right = True >>> ln = table.new_line() >>> ln[column_name] = "Igor Gnatenko" >>> ln[column_age] = "18" >>> print(table) NAME AGE Igor Gnatenko 18
Useful Functions¶
- smartcols.init_debug(mask=0)¶
Initialize debugging features. If mask equals to 0, then this function reads the LIBSMARTCOLS_DEBUG environment variable to get mask.
Don’t call this function multiple times.
- Parameters:
mask (int) – Debug mask (0xffff to enable full debugging)
- smartcols.cmpstr_cells(c1, c2, data=None)¶
Shorthand wrapper around strcmp(). data is ignored.
- Parameters:
c1 (smartcols.Cell) – First cell
c2 (smartcols.Cell) – Second cell
data (
objector None) – (unused) Additional data
- smartcols.wrapnl_chunksize(cl, data, userdata=None)¶
Split string by newline character and return size of the largest chunk.
- Parameters:
cl (smartcols.Column) – (unused) Column
data (str) – String
userdata (
objector None) – (unused) Additional data
- Returns:
Size of the largest chunk
- Return type:
- smartcols.wrapnl_nextchunk()¶
wrapnl_chunksize(cl, data, userdata=None)
- Parameters:
cl (smartcols.Column) – (unused) Column
data (str) – String
userdata (
objector None) – (unused) Additional data
- Returns:
Chunk text and separator
- Return type:
Enumerations used by functions¶
- class smartcols.CellPosition¶
Cell position. Currently used only in
smartcols.Title.- left¶
- Align text to the left.
- center¶
- Align text to the center.
- right¶
- Align text to the right.