示例#1
0
    def __init__(self):
        self.current_resource_type = None  # type: str
        self.current_resource = None
        self.session = None
        self._history = FileHistory('.cbsh-history')
        self._output_format = Application.OUTPUT_FORMAT_JSON_COLORED
        self._output_verbosity = Application.OUTPUT_VERBOSITY_NORMAL

        self._style = style_from_pygments_dict({
            Token.Toolbar:
            '#fce94f bg:#333333',

            # User input.
            # Token:          '#ff0066',

            # Prompt.
            # Token.Username: '******',
            # Token.At:       '#00aa00',
            # Token.Colon:    '#00aa00',
            # Token.Pound:    '#00aa00',
            # Token.Host:     '#000088 bg:#aaaaff',
            # Token.Path:     '#884444 underline',
        })

        self._output_style = 'fruity'
示例#2
0
文件: gruvbox.py 项目: v1nam/wand-cli
 def get_gruvbox(self):
     return style_from_pygments_dict({
         Comment.Preproc: "noinherit #8ec07c",
         Comment: "#928374 italic",
         Generic.Deleted: "noinherit #282828",
         Generic.Emph: "#83a598 underline",
         Generic.Error: "bold",
         Generic.Heading: "#b8bb26 bold",
         Generic.Inserted: "noinherit #282828",
         Generic.Output: "noinherit #504945",
         Generic.Prompt: "#ebdbb2",
         Generic.Strong: "#ebdbb2",
         Generic.Subheading: "#b8bb26 bold",
         Generic.Traceback: "#fb4934 bold",
         Generic: "#ebdbb2",
         Keyword.Type: "noinherit #fabd2f",
         Keyword: "noinherit #fe8019",
         Name.Attribute: "#b8bb26 bold",
         Name.Builtin: "#fabd2f",
         Name.Constant: "noinherit #d3869b",
         Name.Entity: "noinherit #fabd2f",
         Name.Exception: "noinherit #fb4934",
         Name.Function: "#fabd2f",
         Name.Label: "noinherit #fb4934",
         Name.Tag: "noinherit #fb4934",
         Name.Variable: "noinherit #ebdbb2",
         Name: "#ebdbb2",
         Number.Float: "noinherit #d3869b",
         Number: "noinherit #d3869b",
         Operator: "#fe8019",
         String.Symbol: "#83a598",
         String: "noinherit #b8bb26",
         Token: "noinherit #ebdbb2",
     })
示例#3
0
    def __init__(self, uri=None, **settings):
        self.output_file = settings.pop("file", None)
        verbose = settings.pop("verbose", False)
        connection_data = get_connection_data(uri, **settings)
        try:
            self.graph = Graph(uri, **settings)
        except ServiceUnavailable as error:
            raise ConsoleError("Could not connect to {} -- {}".format(
                connection_data["uri"], error))
        try:
            makedirs(HISTORY_FILE_DIR)
        except OSError:
            pass
        self.history = FileHistory(path_join(HISTORY_FILE_DIR, HISTORY_FILE))
        self.prompt_args = {
            "history":
            self.history,
            "lexer":
            PygmentsLexer(CypherLexer),
            "style":
            merge_styles([
                style_from_pygments_cls(NativeStyle),
                style_from_pygments_dict({
                    Token.Prompt:
                    "#ansi{}".format(self.prompt_colour.replace(
                        "cyan", "teal")),
                    Token.TxCounter:
                    "#ansi{} bold".format(
                        self.tx_colour.replace("cyan", "teal")),
                })
            ])
        }
        self.lexer = CypherLexer()
        self.result_writer = Table.write
        if verbose:
            from neobolt.diagnostics import watch
            self.watcher = watch("neo4j.%s" % connection_data["scheme"])

        self.commands = {
            "//": self.set_multi_line,
            "/e": self.edit,
            "/?": self.help,
            "/h": self.help,
            "/help": self.help,
            "/x": self.exit,
            "/exit": self.exit,
            "/play": self.play,
            "/csv": self.set_csv_result_writer,
            "/table": self.set_tabular_result_writer,
            "/tsv": self.set_tsv_result_writer,
            "/config": self.config,
            "/kernel": self.kernel,
        }
        self.tx = None
        self.tx_counter = 0
示例#4
0
文件: shell.py 项目: amohar/shellen
    def __prompt_init(self):
        self.history = InMemoryHistory()

        self.prompt_style = style_from_pygments_dict({
            Token:       '#ff0066',
            Token.OS:    '#ff3838',
            Token.Colon: '#ffffff',
            Token.Mode:  '#f9a9c3 bold',
            Token.Arch:  '#5db2fc',
            Token.Pound: '#ffd82a',
        })
示例#5
0
 def get_nord(self) -> Style:
     """Configuration for Nord Theme."""
     return style_from_pygments_dict(
         {
             Whitespace: self.nord4,
             Comment: f"italic {self.nord3_bright}",
             Comment.Preproc: self.nord10,
             Keyword: f"bold {self.nord9}",
             Keyword.Pseudo: f"nobold {self.nord9}",
             Keyword.Type: f"nobold {self.nord9}",
             Operator: self.nord9,
             Operator.Word: f"bold {self.nord9}",
             Name: self.nord4,
             Name.Builtin: self.nord9,
             Name.Function: self.nord8,
             Name.Class: self.nord7,
             Name.Namespace: self.nord7,
             Name.Exception: self.nord11,
             Name.Variable: self.nord4,
             Name.Constant: self.nord7,
             Name.Label: self.nord7,
             Name.Entity: self.nord12,
             Name.Attribute: self.nord7,
             Name.Tag: self.nord9,
             Name.Decorator: self.nord12,
             Punctuation: self.nord6,
             String: self.nord14,
             String.Doc: self.nord3_bright,
             String.Interpol: self.nord14,
             String.Escape: self.nord13,
             String.Regex: self.nord13,
             String.Symbol: self.nord14,
             String.Other: self.nord14,
             Number: self.nord15,
             Generic.Heading: f"bold {self.nord8}",
             Generic.Subheading: f"bold {self.nord8}",
             Generic.Deleted: self.nord11,
             Generic.Inserted: self.nord14,
             Generic.Error: self.nord11,
             Generic.Emph: "italic",
             Generic.Strong: "bold",
             Generic.Prompt: f"bold {self.nord3}",
             Generic.Output: self.nord4,
             Generic.Traceback: self.nord11,
             Error: self.nord11,
         }
     )
示例#6
0
    def read(self):
        prompt_args = {
            "history":
            self.history,
            "lexer":
            PygmentsLexer(CypherLexer),
            "style":
            merge_styles([
                style_from_pygments_cls(NativeStyle),
                style_from_pygments_dict({
                    Token.Prompt.User: "******",
                    Token.Prompt.At: "#ansigreen",
                    Token.Prompt.Host: "#ansigreen",
                    Token.Prompt.Slash: "#ansigreen",
                    Token.Prompt.Graph: "#ansiblue",
                    Token.Prompt.QID: "#ansiyellow",
                    Token.Prompt.Arrow: "#808080",
                })
            ])
        }

        if self.multi_line:
            self.multi_line = False
            return prompt(u"", multiline=True, **prompt_args)

        def get_prompt_tokens():
            graph_name = "~" if self.graph_name is None else self.graph_name
            tokens = [
                ("class:pygments.prompt.user", self.profile.user),
                ("class:pygments.prompt.at", "@"),
                ("class:pygments.prompt.host", self.profile.host),
                ("class:pygments.prompt.slash", "/"),
                ("class:pygments.prompt.graph", graph_name),
            ]
            if self.tx is None:
                tokens.append(("class:pygments.prompt.arrow", " -> "))
            else:
                tokens.append(("class:pygments.prompt.arrow", " "))
                tokens.append(("class:pygments.prompt.qid", str(self.qid)))
                tokens.append(("class:pygments.prompt.arrow", "> "))
            return tokens

        return prompt(get_prompt_tokens, **prompt_args)
示例#7
0
文件: dracula.py 项目: v1nam/wand-cli
 def get_dracula(self):
     return style_from_pygments_dict(
         {
             Comment: "#6272a4",
             Comment.Hashbang: "#6272a4",
             Comment.Multiline: "#6272a4",
             Comment.Preproc: "#ff79c6",
             Comment.Single: "#6272a4",
             Comment.Special: "#6272a4",
             Generic: "#f8f8f2",
             Generic.Deleted: "#8b080b",
             Generic.Emph: "#f8f8f2",
             Generic.Error: "#f8f8f2",
             Generic.Heading: "#f8f8f2 bold",
             Generic.Inserted: "#f8f8f2 bold",
             Generic.Output: "#44475a",
             Generic.Prompt: "#f8f8f2",
             Generic.Strong: "#f8f8f2",
             Generic.Subheading: "#f8f8f2 bold",
             Generic.Traceback: "#f8f8f2",
             Error: "#f8f8f2",
             Keyword: "#ff79c6",
             Keyword.Constant: "#ff79c6",
             Keyword.Declaration: "#8be9fd italic",
             Keyword.Namespace: "#ff79c6",
             Keyword.Pseudo: "#ff79c6",
             Keyword.Reserved: "#ff79c6",
             Keyword.Type: "#8be9fd",
             Literal: "#f8f8f2",
             Literal.Date: "#f8f8f2",
             Name: "#f8f8f2",
             Name.Attribute: "#50fa7b",
             Name.Builtin: "#8be9fd italic",
             Name.Builtin.Pseudo: "#f8f8f2",
             Name.Class: "#50fa7b",
             Name.Constant: "#f8f8f2",
             Name.Decorator: "#f8f8f2",
             Name.Entity: "#f8f8f2",
             Name.Exception: "#f8f8f2",
             Name.Function: "#50fa7b",
             Name.Label: "#8be9fd italic",
             Name.Namespace: "#f8f8f2",
             Name.Other: "#f8f8f2",
             Name.Tag: "#ff79c6",
             Name.Variable: "#8be9fd italic",
             Name.Variable.Class: "#8be9fd italic",
             Name.Variable.Global: "#8be9fd italic",
             Name.Variable.Instance: "#8be9fd italic",
             Number: "#bd93f9",
             Number.Bin: "#bd93f9",
             Number.Float: "#bd93f9",
             Number.Hex: "#bd93f9",
             Number.Integer: "#bd93f9",
             Number.Integer.Long: "#bd93f9",
             Number.Oct: "#bd93f9",
             Operator: "#ff79c6",
             Operator.Word: "#ff79c6",
             Other: "#f8f8f2",
             Punctuation: "#f8f8f2",
             String: "#f1fa8c",
             String.Backtick: "#f1fa8c",
             String.Char: "#f1fa8c",
             String.Doc: "#f1fa8c",
             String.Double: "#f1fa8c",
             String.Escape: "#f1fa8c",
             String.Heredoc: "#f1fa8c",
             String.Interpol: "#f1fa8c",
             String.Other: "#f1fa8c",
             String.Regex: "#f1fa8c",
             String.Single: "#f1fa8c",
             String.Symbol: "#f1fa8c",
             Text: "#f8f8f2",
             Whitespace: "#f8f8f2",
         }
     )
示例#8
0
"""Styles for almanac applications."""

from prompt_toolkit.styles import style_from_pygments_dict
from pygments.token import Keyword, Name, Number, Operator, String, Text


DARK_MODE_STYLE = style_from_pygments_dict({
    Operator: 'ansicyan',

    Name.RealCommand: 'ansimagenta',
    Name.NonexistentCommand: 'ansired',
    Name.Kwarg: 'ansibrightmagenta',

    Keyword.Boolean: 'ansibrightyellow',
    Number.Integer: 'ansiyellow',
    Number.Float: 'ansiyellow',

    String.SingleQuote: 'ansibrightgreen',
    String.DoubleQuote: 'ansibrightgreen',

    Text: '',
})

LIGHT_MODE_STYLE = ...  # TODO
示例#9
0
 style_from_pygments_dict({
     # Commands
     Name.Command: "#f2b44f",
     Name.SubCommand: "#f2c46f",
     Name.InvalidCommand: "bg:#ff0066 #000000",
     Name.Select: "#0000ff",
     Name.Query: "#d78700",
     Name.Key: "#ffffff",
     Name.Path: "#fff484",
     Name.Help: "#00aa00",
     Name.Exit: "#ff0066",
     # User input.
     Token: "#ff0066",
     # Prompt.
     Token.Username: "******",
     Token.At: "#00aa00",
     Token.Colon: "#00aa00",
     Token.Pound: "#00aa00",
     Token.Tier: "#ff0088",
     Token.Path: "#884444 underline",
     Token.RPrompt: "bg:#ff0066 #ffffff",
     # Toolbar Tokens
     Token.Toolbar: "#ffffff bg:#1c1c1c",
     Token.TestTier: "#ff0000 bg:#1c1c1c",
     Token.ProductionTier: "#ff0000 bg:#1c1c1c",
     Token.OfflineNodes: "#ff0000 bg:#1c1c1c",
     Token.NodesCount: "#ffffff bg:#1c1c1c",
     Token.Spacer: "#ffffff bg:#1c1c1c",
     # Alarms
     Token.MinorAlarm: "#0000ff bg:#1c1c1c",
     Token.MajorAlarm: "#d78700 bg:#1c1c1c",
     Token.CriticalAlarm: "#ff0000 bg:#1c1c1c",
     Token.AppendFailures: "#0000ff bg:#1c1c1c",
     # General
     Token.Good: "#ffffff bg:#10c010",
     Token.Bad: "#ffffff bg:#c01010",
     Token.Info: "#ffffff bg:#1010c0",
     Token.Warn: "#000000 bg:#c0c010",
 }),
示例#10
0
文件: PyNote.py 项目: BurzooTV/PyNote
bindings = load_basic_bindings()

#styles->
dialog_style = Style.from_dict({
    'dialog': 'bg:#000000',
    'dialog frame.label': 'bg:#000000 #f2f542',
    'dialog.body': 'bg:#000000 #f2f542',
    'dialog text-area': '#000000',
    'dialog shadow': 'bg:#f2f542',
})

custom_lexer_style = style_from_pygments_dict({
    Token.Comment: '#949487 bold',
    Token.Keyword: '#f2f542',
    Token.String: '#8c2807',
    Token.Operator: '#246BCE',
    Token.Operator.Word: '#246BCE',
    Token.Name.Function: '#246BCE italic',
    Token.Name.Builtin: '#246BCE'
})


#key bindings->
@bindings.add('c-r')
def _(event) -> None:
    event.app.exit(result=event.app.current_buffer.text)


@bindings.add('tab')
def _(event) -> str:
    event.current_buffer.insert_text('    ')
示例#11
0
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.styles import style_from_pygments_dict
from pygments.token import Token

from autobahn.wamp.exception import ApplicationError

from crossbar.shell.util import style_error


def _get_bottom_toolbar_tokens(cli):
    return [(Token.Toolbar, ' This is a toolbar. ')]


_style = style_from_pygments_dict({
    Token.Toolbar: '#ffffff bg:#333333',
})


class InternalCommandException(Exception):
    pass


class ExitReplException(InternalCommandException):
    pass


_internal_commands = dict()


def _register_internal_command(names, target, description=None):
示例#12
0
 def pygments_style(cls):
     return style_from_pygments_dict(cls.styles)