当前位置: 首页>>代码示例>>Python>>正文


Python InteractiveShellEmbed.set_banner方法代码示例

本文整理汇总了Python中IPython.terminal.embed.InteractiveShellEmbed.set_banner方法的典型用法代码示例。如果您正苦于以下问题:Python InteractiveShellEmbed.set_banner方法的具体用法?Python InteractiveShellEmbed.set_banner怎么用?Python InteractiveShellEmbed.set_banner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPython.terminal.embed.InteractiveShellEmbed的用法示例。


在下文中一共展示了InteractiveShellEmbed.set_banner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_shell

# 需要导入模块: from IPython.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.terminal.embed.InteractiveShellEmbed import set_banner [as 别名]
def setup_shell():

    banner = '+-----------------------------------------------------------+\n'
    banner += ' APSG '
    banner += APSG_VERSION
    banner += ' [interactive shell] - http://ondrolexa.github.io/apsg\n'
    banner += '+-----------------------------------------------------------+\n'
    banner += '\n'
    banner += 'Commands: \n'
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\n'
    banner += 'Documentation:\n'
    banner += '\thelp(Fol), ?Fol, Fol?, or Fol()? all do the same\n'
    banner += '\t"docs" will launch webbrowser showing documentation'
    banner += '\n'
    exit_msg = '\n... [Exiting the APSG interactive shell] ...\n'

    try:
        from traitlets.config import Config
        from IPython.terminal.embed import InteractiveShellEmbed

        cfg = Config()
        cfg.PromptManager.in_template = "APSG:\\#> "
        cfg.PromptManager.out_template = "APSG:\\#: "
        apsgShell = InteractiveShellEmbed(config=cfg, banner1=banner,
                                          exit_msg = exit_msg)
        apsgShell.define_magic("clear", magic_clear)
        #apsgShell.define_magic("docs", magic_docs)

    except ImportError:
        try:
            from IPython.Shell import IPShellEmbed
            argsv = ['-pi1','APSG:\\#>','-pi2','   .\\D.:','-po','APSG:\\#>','-nosep']

            apsgShell = IPShellEmbed(argsv)
            apsgShell.set_banner(banner)
            apsgShell.set_exit_msg(exit_msg)
            apsgShell.IP.api.expose_magic("clear", magic_clear)
        except ImportError:
            raise("ERROR: IPython shell failed to load")

    return apsgShell
开发者ID:drcoronel,项目名称:apsg,代码行数:45,代码来源:shell.py

示例2: setup_ipython

# 需要导入模块: from IPython.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.terminal.embed.InteractiveShellEmbed import set_banner [as 别名]
def setup_ipython():
    try:
        import IPython
        from IPython.config.loader import Config
        from IPython.terminal.embed import InteractiveShellEmbed

        cfg = Config()
        cfg.PromptManager.in_template = "SimpleCV:\\#> "
        cfg.PromptManager.out_template = "SimpleCV:\\#: "
        #~ cfg.InteractiveShellEmbed.prompt_in1 = "SimpleCV:\\#> "
        #~ cfg.InteractiveShellEmbed.prompt_out="SimpleCV:\\#: "
        scvShell = InteractiveShellEmbed(config=cfg, banner1=banner,
                                         exit_msg=exit_msg)
        scvShell.define_magic("tutorial", magic_tutorial)
        scvShell.define_magic("clear", magic_clear)
        scvShell.define_magic("example", magic_examples)
        scvShell.define_magic("forums", magic_forums)
        scvShell.define_magic("walkthrough", magic_walkthrough)
        scvShell.define_magic("docs", magic_docs)
    except ImportError:
        try:
            from IPython.Shell import IPShellEmbed

            argsv = ['-pi1', 'SimpleCV:\\#>', '-pi2', '   .\\D.:', '-po',
                     'SimpleCV:\\#>', '-nosep']
            scvShell = IPShellEmbed(argsv)
            scvShell.set_banner(banner)
            scvShell.set_exit_msg(exit_msg)
            scvShell.IP.api.expose_magic("tutorial", magic_tutorial)
            scvShell.IP.api.expose_magic("clear", magic_clear)
            scvShell.IP.api.expose_magic("example", magic_examples)
            scvShell.IP.api.expose_magic("forums", magic_forums)
            scvShell.IP.api.expose_magic("walkthrough", magic_walkthrough)
            scvShell.IP.api.expose_magic("docs", magic_docs)
        except ImportError:
            raise

    return scvShell()
开发者ID:Betrezen,项目名称:SimpleCV2,代码行数:40,代码来源:Shell.py

示例3: command

# 需要导入模块: from IPython.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.terminal.embed.InteractiveShellEmbed import set_banner [as 别名]

#.........这里部分代码省略.........

        # Query the test app to setup the environment
        tresponse = test_app.get('/_test_vars')
        request_id = int(tresponse.body)

        # Disable restoration during test_app requests
        test_app.pre_request_hook = lambda self: \
            paste.registry.restorer.restoration_end()
        test_app.post_request_hook = lambda self: \
            paste.registry.restorer.restoration_begin(request_id)

        # Restore the state of the Pylons special objects
        # (StackedObjectProxies)
        paste.registry.restorer.restoration_begin(request_id)

        # Determine the package name from the pylons.config object
        pkg_name = pylons.config['pylons.package']

        # Start the rest of our imports now that the app is loaded
        if is_minimal_template(pkg_name, True):
            model_module = None
            helpers_module = pkg_name + '.helpers'
            base_module = pkg_name + '.controllers'
        else:
            model_module = pkg_name + '.model'
            helpers_module = pkg_name + '.lib.helpers'
            base_module = pkg_name + '.lib.base'

        if model_module and can_import(model_module):
            locs['model'] = sys.modules[model_module]

        if can_import(helpers_module):
            locs['h'] = sys.modules[helpers_module]

        exec ('from pylons import app_globals, config, request, response, '
              'session, tmpl_context, url') in locs
        exec ('from pylons.controllers.util import abort, redirect') in locs
        exec 'from pylons.i18n import _, ungettext, N_' in locs
        locs.pop('__builtins__', None)

        # Import all objects from the base module
        __import__(base_module)

        base = sys.modules[base_module]
        base_public = [__name for __name in dir(base) if not \
                       __name.startswith('_') or __name == '_']
        locs.update((name, getattr(base, name)) for name in base_public)
        locs.update(dict(wsgiapp=wsgiapp, app=test_app))

        mapper = tresponse.config.get('routes.map')
        if mapper:
            locs['mapper'] = mapper

        banner = "  All objects from %s are available\n" % base_module
        banner += "  Additional Objects:\n"
        if mapper:
            banner += "  %-10s -  %s\n" % ('mapper', 'Routes mapper object')
        banner += "  %-10s -  %s\n" % ('wsgiapp',
            "This project's WSGI App instance")
        banner += "  %-10s -  %s\n" % ('app',
            'paste.fixture wrapped around wsgiapp')

        try:
            if self.options.disable_ipython:
                raise ImportError()

            # try to use IPython if possible
            try:
                try:
                    # 1.0 <= ipython
                    from IPython.terminal.embed import InteractiveShellEmbed
                except ImportError:
                    # 0.11 <= ipython < 1.0
                    from IPython.frontend.terminal.embed import InteractiveShellEmbed
                shell = InteractiveShellEmbed(banner2=banner)
            except ImportError:
                # ipython < 0.11
                from IPython.Shell import IPShellEmbed
                shell = IPShellEmbed(argv=self.args)
                shell.set_banner(shell.IP.BANNER + '\n\n' + banner)

            try:
                shell(local_ns=locs, global_ns={})
            finally:
                paste.registry.restorer.restoration_end()
        except ImportError:
            import code
            py_prefix = sys.platform.startswith('java') and 'J' or 'P'
            newbanner = "Pylons Interactive Shell\n%sython %s\n\n" % \
                (py_prefix, sys.version)
            banner = newbanner + banner
            shell = code.InteractiveConsole(locals=locs)
            try:
                import readline
            except ImportError:
                pass
            try:
                shell.interact(banner)
            finally:
                paste.registry.restorer.restoration_end()
开发者ID:AlexanderYAPPO,项目名称:pylons,代码行数:104,代码来源:commands.py


注:本文中的IPython.terminal.embed.InteractiveShellEmbed.set_banner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。