Skip to content

Commit 009d5ab

Browse files
authored
fix: reduce extra space left and right of plain (#53)
1 parent e6890b5 commit 009d5ab

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

table2ascii/preset_style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ class PresetStyle:
4646
ascii_rounded = TableStyle.from_string(r"/===\|| |=|=||-|-|\|=/")
4747
ascii_rounded_box = TableStyle.from_string(r"/===\||||=||||-|||\||/")
4848
markdown = TableStyle.from_string(" ||||-||| ")
49-
plain = TableStyle.from_string(" ")
49+
plain = TableStyle.from_string(" ").set(left_and_right_edge="")

table2ascii/table_style.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,21 @@ def from_string(cls, string: str) -> "TableStyle":
7575
TableStyle.from_string("╔═╦═╗║║ ╟─╫─╢ ╚╩═╝")
7676
"""
7777
return cls(*string)
78+
79+
def set(self, **kwargs) -> "TableStyle":
80+
"""
81+
Set attributes of the TableStyle
82+
83+
Args:
84+
kwargs: The attributes to set
85+
86+
Returns:
87+
A TableStyle object with the attributes set
88+
89+
Example::
90+
91+
TableStyle().set(top_left_corner="╔", top_and_bottom_edge="═")
92+
"""
93+
for key, value in kwargs.items():
94+
setattr(self, key, value)
95+
return self

tests/test_styles.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,9 @@ def test_plain():
661661
style=PresetStyle.plain,
662662
)
663663
expected = (
664-
" # G H R S \n"
665-
" 1 30 40 35 30 \n"
666-
" 2 30 40 35 30 \n"
667-
" SUM 130 140 135 130 "
664+
" # G H R S \n"
665+
" 1 30 40 35 30 \n"
666+
" 2 30 40 35 30 \n"
667+
" SUM 130 140 135 130 "
668668
)
669669
assert text == expected

0 commit comments

Comments
 (0)