From b22f8ecaa57b4a47d97b3767f5d702b5b5eefb84 Mon Sep 17 00:00:00 2001 From: fluffy Date: Fri, 3 Mar 2023 20:42:17 +0100 Subject: [PATCH] 1.1.5 --- README.md | 10 +++++++++- pyproject.toml | 8 ++++---- src/TableAPI/__init__.py | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4d11f7c..e58a864 100644 --- a/README.md +++ b/README.md @@ -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: @@ -43,6 +43,14 @@ 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: +```py +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: ```py diff --git a/pyproject.toml b/pyproject.toml index aea756c..e2376bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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="me@fluffel.net" }, ] @@ -17,5 +17,5 @@ classifiers = [ ] [project.urls] -"Homepage" = "https://github.com/pypa/sampleproject" -"Bug Tracker" = "https://github.com/pypa/sampleproject/issues" \ No newline at end of file +"Homepage" = "https://github.com/fluffeliger/tableapi" +"Bug Tracker" = "https://github.com/fluffeliger/tableapi/issues" \ No newline at end of file diff --git a/src/TableAPI/__init__.py b/src/TableAPI/__init__.py index 431c6f4..51f03e2 100644 --- a/src/TableAPI/__init__.py +++ b/src/TableAPI/__init__.py @@ -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) @@ -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!