Skip to content

Commit

Permalink
1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffeliger committed Mar 3, 2023
1 parent b193b4b commit b22f8ec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ After this we can staaaarrrrtttttt :D

The import should look something like this
```py
from TableAPI.tableapi import Table
from TableAPI import Table
```

To write a simple Table, create a table object with the columns and a simple row:
Expand Down Expand Up @@ -43,6 +43,14 @@ print(table.build()) # Table#Build() will return the table as a string
Here you go ;)
<hr>

#### Define a new Design
Simple as before, change the design of the table with this here:
```py
table.set_theme('|', '-', '+') # Horizontal, Vertical and last one is the dot between
```
This will display a table with the normal design
<hr>

#### Define new Header
It is possible to define a new header with following code snippet:
```py
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "tableapi_fluffy"
version = "2.0.0"
name = "TableAPI"
version = "1.1.5"
authors = [
{ name="fluffy", email="[email protected]" },
]
Expand All @@ -17,5 +17,5 @@ classifiers = [
]

[project.urls]
"Homepage" = "https://github.com/pypa/sampleproject"
"Bug Tracker" = "https://github.com/pypa/sampleproject/issues"
"Homepage" = "https://github.com/fluffeliger/tableapi"
"Bug Tracker" = "https://github.com/fluffeliger/tableapi/issues"
16 changes: 16 additions & 0 deletions src/TableAPI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ class InvalidArgSizeException(Exception):
def __init__(self, *args: object) -> None:
super().__init__(*args)

class InvalidArgsException(Exception):
def __init__(self, *args: object) -> None:
super().__init__(*args)


class InvalidIndexException(Exception):
def __init__(self, *args: object) -> None:
super().__init__(*args)
Expand Down Expand Up @@ -47,6 +52,17 @@ def __init__(self, *args: str) -> None:
self.max_column_lengths.append(0)
self.set_header(*args)

def set_theme(self, vertical: str, horizontal: str, dot: str) -> None:
'''Set the theme of the table.\n
NOTE: Every argument has to have the length of exactly one!
'''
if len(vertical) != 1 or len(horizontal) != 1 or len(dot) != 1: raise InvalidArgsException(f'The args has to be one charactor wide')
self.table_design = {
'v': vertical,
'h': horizontal,
'd': dot
}

def set_header(self, *args: str) -> None:
'''Set the header of the table.\n
NOTE: Argument length and column size must match!
Expand Down

0 comments on commit b22f8ec

Please sign in to comment.