MCPcopy Index your code
hub / github.com/dbcli/pgcli / style_factory_output

Function style_factory_output

pgcli/pgstyle.py:93–114  ·  view source on GitHub ↗
(name, cli_style)

Source from the content-addressed store, hash-verified

91
92
93def 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

Callers 1

__init__Method · 0.85

Calls 2

parse_pygments_styleFunction · 0.85
updateMethod · 0.80

Tested by

no test coverage detected