Skip to content

Commit

Permalink
Make it possible to set more writer settings via writer class constru…
Browse files Browse the repository at this point in the history
…ctors
  • Loading branch information
thombashi committed May 4, 2021
1 parent 5b1e0f5 commit b7047e1
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion pytablewriter/writer/_table_writer.py
Expand Up @@ -276,7 +276,10 @@ def __init__(self, **kwargs) -> None:
self._iter_count = None # type: Optional[int]

self.__default_style = kwargs.get("default_style", Style())
self.__col_style_list = kwargs.get("column_styles", []) # type: List[Optional[Style]]

self.__col_style_list = [] # type: List[Optional[Style]]
self.column_styles = kwargs.get("column_styles", [])

self._style_filters = [] # type: List[StyleFilterFunc]
self._styler = self._create_styler(self)
self.style_filter_kwargs = kwargs.get("style_filter_kwargs", {}) # type: Dict[str, Any]
Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/writer/text/_borderless.py
Expand Up @@ -29,7 +29,7 @@ def __init__(self, **kwargs) -> None:
self.char_left_side_row = ""
self.char_right_side_row = ""

self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")
self.is_write_header_separator_row = False
self.is_write_value_separator_row = False
self.is_write_opening_row = False
Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/writer/text/_css.py
Expand Up @@ -28,7 +28,7 @@ def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

self.is_padding = False
self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")

self._dp_extractor.preprocessor.is_escape_html_tag = False
self._quoting_flags = copy.deepcopy(NOT_QUOTING_FLAGS)
Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/writer/text/_csv.py
Expand Up @@ -38,7 +38,7 @@ def __init__(self, **kwargs) -> None:

self._set_chars("")
self.indent_string = ""
self.column_delimiter = ","
self.column_delimiter = kwargs.get("column_delimiter", ",")
self._margin = 0

self.is_padding = False
Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/writer/text/_html.py
Expand Up @@ -49,7 +49,7 @@ def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

self.is_padding = False
self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")

self._dp_extractor.preprocessor.line_break_repl = "<br>"
self._dp_extractor.preprocessor.is_escape_html_tag = False
Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/writer/text/_latex.py
Expand Up @@ -30,7 +30,7 @@ def __init__(self, **kwargs) -> None:

self.is_write_opening_row = True
self.is_write_closing_row = True
self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")
self.column_delimiter = " & "
self.char_right_side_row = r" \\"

Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/writer/text/_rst.py
Expand Up @@ -34,7 +34,7 @@ def __init__(self, **kwargs) -> None:
self.char_opening_row_cross_point = "+"
self.char_closing_row_cross_point = "+"

self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")
self.is_write_header_separator_row = True
self.is_write_value_separator_row = True
self.is_write_opening_row = True
Expand Down
4 changes: 2 additions & 2 deletions pytablewriter/writer/text/_unicode.py
Expand Up @@ -50,7 +50,7 @@ def __init__(self, **kwargs) -> None:
self.char_closing_row = "─"
self.char_closing_row_cross_point = "┴"

self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")
self.is_write_header_separator_row = True
self.is_write_value_separator_row = True
self.is_write_opening_row = True
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(self, **kwargs) -> None:
self.char_closing_row = "━"
self.char_closing_row_cross_point = "┻"

self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")
self.is_write_header_separator_row = True
self.is_write_value_separator_row = True
self.is_write_opening_row = True
Expand Down
2 changes: 1 addition & 1 deletion pytablewriter/writer/text/sourcecode/_sourcecode.py
Expand Up @@ -45,7 +45,7 @@ def margin(self, value: int) -> None:
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

self.indent_string = " "
self.indent_string = kwargs.get("indent_string", " ")
self.column_delimiter = ", "
self._margin = 0

Expand Down

0 comments on commit b7047e1

Please sign in to comment.