def pygments_style_by_name(name): """Gets or makes a pygments color style by its name.""" if name in STYLES: return STYLES[name] pstyle = get_style_by_name(name) palette = make_palette(pstyle.styles.values()) astyle = make_pygments_style(palette) STYLES[name] = astyle return astyle
def pygments_style_by_name(name): """Gets or makes a pygments color style by its name.""" if name in STYLES: return STYLES[name] pstyle = get_style_by_name(name) palette = make_palette(pstyle.styles.values()) astyle = make_pygments_style(palette) STYLES[name] = astyle return astyle
def ansi_style_by_name(name): """Gets or makes an ANSI color style by name. If the styles does not exist, it will look for a style using the pygments name. """ if name in ANSI_STYLES: return ANSI_STYLES[name] elif not HAS_PYGMENTS: raise KeyError('could not find style {0!r}'.format(name)) from xonsh.pygments_cache import get_style_by_name pstyle = get_style_by_name(name) palette = make_palette(pstyle.styles.values()) astyle = make_ansi_style(palette) ANSI_STYLES[name] = astyle return astyle
def ansi_style_by_name(name): """Gets or makes an ANSI color style by name. If the styles does not exist, it will look for a style using the pygments name. """ if name in ANSI_STYLES: return ANSI_STYLES[name] elif not HAS_PYGMENTS: raise KeyError("could not find style {0!r}".format(name)) from xonsh.pygments_cache import get_style_by_name pstyle = get_style_by_name(name) palette = make_palette(pstyle.styles.values()) astyle = make_ansi_style(palette) ANSI_STYLES[name] = astyle return astyle
def ansi_style_by_name(name): """Gets or makes an ANSI color style by name. If the styles does not exist, it will look for a style using the pygments name. """ if name in ANSI_STYLES: return ANSI_STYLES[name] elif not HAS_PYGMENTS: raise KeyError("could not find style {0!r}".format(name)) from xonsh.pygments_cache import get_style_by_name from pygments.util import ClassNotFound try: pstyle = get_style_by_name(name) except (ModuleNotFoundError, ClassNotFound): pstyle = get_style_by_name("default") palette = make_palette(pstyle.styles.values()) astyle = make_ansi_style(palette) ANSI_STYLES[name] = astyle return astyle