Skip to content

Commit 9c5cb5e

Browse files
committed
Move header, body, footer back as positional arguments
1 parent 9f29aa1 commit 9c5cb5e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

table2ascii/table_to_ascii.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
class TableToAscii:
99
"""Class used to convert a 2D Python table to ASCII text"""
1010

11-
def __init__(self, options: Options):
11+
def __init__(self, header: List, body: List[List], footer: List, options: Options):
1212
"""Validate arguments and initialize fields"""
1313
# initialize fields
14-
self.__header = options.header
15-
self.__body = options.body
16-
self.__footer = options.footer
14+
self.__header = header
15+
self.__body = body
16+
self.__footer = footer
1717
self.__style = options.style
1818
self.__first_col_heading = options.first_col_heading
1919
self.__last_col_heading = options.last_col_heading
@@ -217,16 +217,21 @@ def to_ascii(self) -> str:
217217
return table.strip("\n")
218218

219219

220-
def table2ascii(**options) -> str:
220+
def table2ascii(
221+
header: List = None, body: List[List] = None, footer: List = None, **options
222+
) -> str:
221223
"""Convert a 2D Python table to ASCII text
222224
223225
### Arguments
224226
:param header: :class:`Optional[List]` List of column values in the table's header row
225227
:param body: :class:`Optional[List[List]]` 2-dimensional list of values in the table's body
226228
:param footer: :class:`Optional[List]` List of column values in the table's footer row
229+
230+
### Keyword required
231+
:param style: :class:`Optional[TableStyle]` Table style to use for styling (preset styles can be imported)
227232
:param column_widths: :class:`Optional[List[int]]` List of widths in characters for each column (defaults to auto-sizing)
228233
:param alignments: :class:`Optional[List[Alignment]]` List of alignments (ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`)
229234
:param first_col_heading: :class:`Optional[bool]` Whether to add a header column separator after the first column
230235
:param last_col_heading: :class:`Optional[bool]` Whether to add a header column separator before the last column
231236
"""
232-
return TableToAscii(Options(**options)).to_ascii()
237+
return TableToAscii(header, body, footer, Options(**options)).to_ascii()

0 commit comments

Comments
 (0)