|
8 | 8 | class TableToAscii:
|
9 | 9 | """Class used to convert a 2D Python table to ASCII text"""
|
10 | 10 |
|
11 |
| - def __init__(self, options: Options): |
| 11 | + def __init__(self, header: List, body: List[List], footer: List, options: Options): |
12 | 12 | """Validate arguments and initialize fields"""
|
13 | 13 | # 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 |
17 | 17 | self.__style = options.style
|
18 | 18 | self.__first_col_heading = options.first_col_heading
|
19 | 19 | self.__last_col_heading = options.last_col_heading
|
@@ -217,16 +217,21 @@ def to_ascii(self) -> str:
|
217 | 217 | return table.strip("\n")
|
218 | 218 |
|
219 | 219 |
|
220 |
| -def table2ascii(**options) -> str: |
| 220 | +def table2ascii( |
| 221 | + header: List = None, body: List[List] = None, footer: List = None, **options |
| 222 | +) -> str: |
221 | 223 | """Convert a 2D Python table to ASCII text
|
222 | 224 |
|
223 | 225 | ### Arguments
|
224 | 226 | :param header: :class:`Optional[List]` List of column values in the table's header row
|
225 | 227 | :param body: :class:`Optional[List[List]]` 2-dimensional list of values in the table's body
|
226 | 228 | :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) |
227 | 232 | :param column_widths: :class:`Optional[List[int]]` List of widths in characters for each column (defaults to auto-sizing)
|
228 | 233 | :param alignments: :class:`Optional[List[Alignment]]` List of alignments (ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`)
|
229 | 234 | :param first_col_heading: :class:`Optional[bool]` Whether to add a header column separator after the first column
|
230 | 235 | :param last_col_heading: :class:`Optional[bool]` Whether to add a header column separator before the last column
|
231 | 236 | """
|
232 |
| - return TableToAscii(Options(**options)).to_ascii() |
| 237 | + return TableToAscii(header, body, footer, Options(**options)).to_ascii() |
0 commit comments