(name, cli_style)
| 91 | |
| 92 | |
| 93 | def style_factory_output(name, cli_style): |
| 94 | try: |
| 95 | style = pygments.styles.get_style_by_name(name).styles |
| 96 | except ClassNotFound: |
| 97 | style = pygments.styles.get_style_by_name("native").styles |
| 98 | |
| 99 | for token in cli_style: |
| 100 | if token.startswith("Token."): |
| 101 | token_type, style_value = parse_pygments_style(token, style, cli_style) |
| 102 | style.update({token_type: style_value}) |
| 103 | elif token in PROMPT_STYLE_TO_TOKEN: |
| 104 | token_type = PROMPT_STYLE_TO_TOKEN[token] |
| 105 | style.update({token_type: cli_style[token]}) |
| 106 | else: |
| 107 | # TODO: cli helpers will have to switch to ptk.Style |
| 108 | logger.error("Unhandled style / class name: %s", token) |
| 109 | |
| 110 | class OutputStyle(PygmentsStyle): |
| 111 | default_style = "" |
| 112 | styles = style |
| 113 | |
| 114 | return OutputStyle |
no test coverage detected