TableAPI
TableAPI is a very simple "API" to create tables in the python console. Its not much but i love this project lmao :)
Getting Started
First things first: Install the latest version with pip here. After this we can staaaarrrrtttttt :D
The import should look something like this
from TableAPI import Table
To write a simple Table, create a table object with the columns and a simple row:
table = Table('A', 'B')
table.add_row('This is', 'a simple test')
Now we have a table, but how do we render it in the console? Well, we have to print the build of the table. Very simple.
print(table.build())
In the console should be a simple table now.
Worst Documentation Ever
Create a Table
There are two ways to create a Table. First one, define the column titles directly in the constructor:
table = Table('A', 'B')
or define the amount of columns and have no titles:
table = Table(2) # Has to be bigger than 0
Build a Table
Simple, it will return a string, which you can print in the console
table = Table('A', 'B')
print(table.build()) # Table#Build() will return the table as a string
Here you go ;)
Define a new Design
Simple as before, change the design of the table with this here:
table.set_theme('|', '-', '+') # Horizontal, Vertical and last one is the dot between
This will display a table with the normal design
Define new Header
It is possible to define a new header with following code snippet:
table.set_header('A', 'B')
NOTE: The amount of strings must match with the amount of columns!
Add a Row
To add a row to a table just write:
table.add_row('A', 'B')
NOTE: The amount of strings must match with the amount of columns!
Remove a Row
To remove a row from a table just write:
table.remove_row(0) # 0 => Row Index
NOTE: Index must be smaller than row size and bigger than zero, else it will return None!
Get a Row Object
There is also a way to get the Row object out of the table. You can write:
table.get_row(0) # 0 => Row Index
NOTE: Index must be smaller than row size and bigger than zero, else it will return None!
Edit a Field
To Edit a Field of a table in a specific row and column, this snippet could help:
table.edit_field(0, 1) # 0 => Row Index
# 1 => Column Index
NOTE: Row-Index must be smaller than the row size and bigger than zero! NOTE: Column-Index must be smaller than the column size and bigger than zero!
Exceptions
There are some exceptions that can come up and here is explained, how you can work with them
InvalidArgSizeException
This Exception will come up if the argument size is not matching a valid pattern. For Example, if you write
table = Table(2, 2)
# or
table = Table()
it will raise this exception, because you can only define 1 column integer or multiple strings. If the Constructor is empty, it doesnt work.
InvalidIndexException
This Exception will raise, if the Index on a function that doesnt return something, cannot find a specific Index like this:
table = Table(1)
table.get_row(200) # There is no row 200
The Exception just means, that the index isnt available.
FieldNotFoundException
This Exception will raise, if the field isnt available:
table = Table(1)
table.edit_field(69, 69) # There is no row 69 and column 69
The Exception just means, that the Field on the row-index and column-index isn't available.
Have fun coding <3
~fluffy
Metadata
Release files for TableAPI 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| TableAPI-1.1.5.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| TableAPI-1.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.6 kB
Release files / TableAPI-1.1.5.tar.gz
| Download URL | TableAPI-1.1.5.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a0c2ff8744dc02dca64784c28db20625e011edf5e9b7f42ff7c01fd48d305a7
|
|
BLAKE2b-256 checksum How to use checksums |
12ddf6514eadfc0bcdaa3e9766957217faa2c8095ff68cae7922244fae580e6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / TableAPI-1.1.5-py3-none-any.whl
| Download URL | TableAPI-1.1.5-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1c31ab92843d644aeddd173cfb3a4c8c9f41dac3a9d16e81e19f365461fcc97
|
|
BLAKE2b-256 checksum How to use checksums |
696eaedc6e32f76e5b90fc7c95927a6f7894a825103cf78b6617930a28831419
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|