Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion table2ascii/preset_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ class PresetStyle:
ascii_rounded = TableStyle.from_string(r"/===\|| |=|=||-|-|\|=/")
ascii_rounded_box = TableStyle.from_string(r"/===\||||=||||-|||\||/")
markdown = TableStyle.from_string(" ||||-||| ")
plain = TableStyle.from_string(" ")
plain = TableStyle.from_string(" ").set(left_and_right_edge="")
18 changes: 18 additions & 0 deletions table2ascii/table_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,21 @@ def from_string(cls, string: str) -> "TableStyle":
TableStyle.from_string("╔═╦═╗║║ ╟─╫─╢ ╚╩═╝")
"""
return cls(*string)

def set(self, **kwargs) -> "TableStyle":
"""
Set attributes of the TableStyle

Args:
kwargs: The attributes to set

Returns:
A TableStyle object with the attributes set

Example::

TableStyle().set(top_left_corner="╔", top_and_bottom_edge="═")
"""
for key, value in kwargs.items():
setattr(self, key, value)
return self
8 changes: 4 additions & 4 deletions tests/test_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ def test_plain():
style=PresetStyle.plain,
)
expected = (
" # G H R S \n"
" 1 30 40 35 30 \n"
" 2 30 40 35 30 \n"
" SUM 130 140 135 130 "
" # G H R S \n"
" 1 30 40 35 30 \n"
" 2 30 40 35 30 \n"
" SUM 130 140 135 130 "
)
assert text == expected