1
0
mirror of https://github.com/dbcli/pgcli synced 2024-05-31 01:17:54 +00:00
pgcli/pgcli/pgstyle.py

18 lines
593 B
Python
Raw Normal View History

from pygments.token import string_to_tokentype
from pygments.util import ClassNotFound
2015-09-24 04:07:20 +00:00
from prompt_toolkit.styles import PygmentsStyle
2015-02-04 07:31:35 +00:00
import pygments.styles
2015-02-04 07:31:35 +00:00
def style_factory(name, cli_style):
try:
style = pygments.styles.get_style_by_name(name)
except ClassNotFound:
style = pygments.styles.get_style_by_name('native')
2018-01-11 20:40:45 +00:00
custom_styles = dict([(string_to_tokentype(x), y)
for x, y in cli_style.items()])
2015-09-24 04:07:20 +00:00
return PygmentsStyle.from_defaults(style_dict=custom_styles,
pygments_style_cls=style)