Create a TerminalWriter instance configured according to the options in the config object. Every code which requires a TerminalWriter object and has access to a config object should use this function.
(
config: Config, file: TextIO | None = None
)
| 2077 | |
| 2078 | |
| 2079 | def create_terminal_writer( |
| 2080 | config: Config, file: TextIO | None = None |
| 2081 | ) -> TerminalWriter: |
| 2082 | """Create a TerminalWriter instance configured according to the options |
| 2083 | in the config object. |
| 2084 | |
| 2085 | Every code which requires a TerminalWriter object and has access to a |
| 2086 | config object should use this function. |
| 2087 | """ |
| 2088 | tw = TerminalWriter(file=file) |
| 2089 | |
| 2090 | if config.option.color == "yes": |
| 2091 | tw.hasmarkup = True |
| 2092 | elif config.option.color == "no": |
| 2093 | tw.hasmarkup = False |
| 2094 | |
| 2095 | if config.option.code_highlight == "yes": |
| 2096 | tw.code_highlight = True |
| 2097 | elif config.option.code_highlight == "no": |
| 2098 | tw.code_highlight = False |
| 2099 | |
| 2100 | return tw |
| 2101 | |
| 2102 | |
| 2103 | def _strtobool(val: str) -> bool: |
no test coverage detected