Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyPilot committed Feb 25, 2025
1 parent 89f58b5 commit eb3e438
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions example/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


t2 = FancyTable(['Name', 'Age', 'Job Title', 'Comment'])
t2.border_color = Fore.MAGENTA
t2.add_row(['Alice', '25', 'Designer', 'Dog lover'])
t2.add_row(['Bob', '35', 'Developer', 'Anime nerd'])
t2.add_section('Singapore')
Expand Down
9 changes: 6 additions & 3 deletions fancy_table/fancy_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from colorama import Fore


DEFAULT_BORDER_COLOR = Fore.LIGHTBLACK_EX


def colorize(text, color, colors_enabled):
if colors_enabled and color:
return color + text + Fore.RESET
Expand All @@ -23,7 +26,7 @@ def __init__(self, name, table):

def to_string(self, prev_row, next_row, colors_enabled):
def border(t):
return colorize(t, Fore.LIGHTBLACK_EX, colors_enabled)
return colorize(t, self._table.border_color if self._table else DEFAULT_BORDER_COLOR, colors_enabled)

widths = self._table.widths
result = list()
Expand Down Expand Up @@ -64,7 +67,7 @@ def __init__(self, row, table, color=None):

def to_string(self, prev_row, next_row, colors_enabled):
def border(t):
return colorize(t, Fore.LIGHTBLACK_EX, colors_enabled)
return colorize(t, self._table.border_color if self._table else DEFAULT_BORDER_COLOR, colors_enabled)

widths = self._table.widths
result = list()
Expand All @@ -90,7 +93,7 @@ class FancyTable:
columns: list = None
rows: list = None
widths: list = None
border_color = Fore.LIGHTBLACK_EX
border_color = DEFAULT_BORDER_COLOR

def __init__(self, columns: list, caption=None):
self.caption = caption
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fancy-table"
version = "0.1.4" # set by antonio-py-dynamic-version
version = "0.1.5" # set by antonio-py-dynamic-version
description = ""
authors = ["Antonio <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit eb3e438

Please sign in to comment.