Python pygments.lexers 模块,BashLexer() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用pygments.lexers.BashLexer()

项目:healthchecks_asgards    作者:andela    | 项目源码 | 文件源码
def handle(self, *args, **options):

        try:
            from pygments import lexers
        except ImportError:
            self.stdout.write("This command requires Pygments package.")
            self.stdout.write("Please install it with:\n\n")
            self.stdout.write("  pip install Pygments\n\n")
            return

        # Invocation examples
        _process("bash", lexers.BashLexer())
        _process("browser", lexers.JavascriptLexer())
        _process("crontab", lexers.BashLexer())
        _process("python", lexers.PythonLexer())
        _process("php", lexers.PhpLexer())
        _process("powershell", lexers.shell.PowerShellLexer())
        _process("node", lexers.JavascriptLexer())

        # API examples
        _process("list_checks_request", lexers.BashLexer())
        _process("list_checks_response", lexers.JsonLexer())
        _process("create_check_request", lexers.BashLexer())
        _process("create_check_response", lexers.JsonLexer())
        _process("pause_check_request", lexers.BashLexer())
        _process("pause_check_response", lexers.JsonLexer())
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def setUp(self):
        self.lexer = lexers.IPythonLexer()
        self.bash_lexer = BashLexer()
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def setUp(self):
        self.lexer = lexers.IPythonLexer()
        self.bash_lexer = BashLexer()
项目:blender    作者:gastrodia    | 项目源码 | 文件源码
def setUp(self):
        self.lexer = lexers.IPythonLexer()
        self.bash_lexer = BashLexer()
项目:yatta_reader    作者:sound88    | 项目源码 | 文件源码
def setUp(self):
        self.lexer = lexers.IPythonLexer()
        self.bash_lexer = BashLexer()
项目:chitin    作者:SamStudio8    | 项目源码 | 文件源码
def shell():
    c = Chitin()

    cmd_history = FileHistory(os.path.expanduser('~') + '/.chitin.history')
    print(WELCOME)
    message = VERSION

    def get_bottom_toolbar_tokens(cli):
        return [(Token.Toolbar, ' '+message)]

    style = style_from_dict({
        Token.Toolbar: '#ffffff bg:#333333',
    })
    completer = SystemCompleter()
    del completer.completers["executable"]

    # Check whether files in and around the current directory have been changed...
    for failed in util.check_integrity_set(set(".")):
        print("[WARN] '%s' has been modified outside of lab book." % failed)
    try:
        while True:
            cmd_str = ""
            while len(cmd_str.strip()) == 0:
                cmd_str = prompt(u'===> ',
                        history=cmd_history,
                        auto_suggest=AutoSuggestFromHistory(),
                        completer=completer,
                        lexer=PygmentsLexer(BashLexer),
                        get_bottom_toolbar_tokens=get_bottom_toolbar_tokens,
                        style=style,
                        on_abort=AbortAction.RETRY,
                )


            fields = cmd_str.split(" ")
            command_set = [" ".join(fields)]

            skip, special_command_set = c.attempt_special(cmd_str)
            if skip:
                continue
            if len(special_command_set) > 0:
                command_set = special_command_set

            #####################################
            handled = c.super_handle(command_set)
            if handled:
                if "message" in handled:
                    message = handled["message"]
                else:
                    message = VERSION
            #####################################

    except EOFError:
        print("Bye!")