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


Python IPShellEmbed.define_magic方法代码示例

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


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

示例1: setup_shell

# 需要导入模块: from IPython.Shell import IPShellEmbed [as 别名]
# 或者: from IPython.Shell.IPShellEmbed import define_magic [as 别名]
def setup_shell():

  banner = '+-----------------------------------------------------------+\n'
  banner += ' SimpleCV '
  banner += SIMPLECV_VERSION
  banner += ' [interactive shell] - http://simplecv.org\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 += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
  banner += '\t"example" gives a list of examples you can run\n'
  banner += '\t"forums" will launch a web browser for the help forums\n'
  banner += '\t"walkthrough" will launch a web browser with a walkthrough\n'
  banner += '\n'
  banner += 'Usage:\n'
  banner += '\tdot complete works to show library\n'
  banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
  banner += '\tjust by touching TAB after typing Image().\n'
  banner += '\n'
  banner += 'Documentation:\n'
  banner += '\thelp(Image), ?Image, Image?, or Image()? all do the same\n'
  banner += '\t"docs" will launch webbrowser showing documentation'
  banner += '\n'
  exit_msg = '\n... [Exiting the SimpleCV interactive shell] ...\n'
  


  #IPython version is less than 11
  if IPVER <= 10:
    #setup terminal to show SCV prompt
    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)

    return scvShell

  #IPython version 0.11 or higher
  else:
    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)

    return scvShell
开发者ID:enricmcalvo,项目名称:SimpleCV,代码行数:64,代码来源:Shell.py

示例2: setup_shell

# 需要导入模块: from IPython.Shell import IPShellEmbed [as 别名]
# 或者: from IPython.Shell.IPShellEmbed import define_magic [as 别名]
def setup_shell():
  
  banner = '+----------------------------------------------------+\n'
  banner += ' SimpleCV [interactive shell] - http://simplecv.org\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 += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
  banner += '\t"cheatsheet" gives a cheatsheet of all the shell functions\n' 
  banner += '\t"example" gives a list of examples you can run'
  banner += '\n'
  banner += 'Usage:\n'
  banner += '\tdot complete works to show library\n'
  banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
  banner += '\tjust by touching TAB after typing Image().\n'
  banner += 'API Documentation:\n'
  banner += '\t"help function_name" will give in depth documentation of API\n'
  banner += '\texample: help Image\n'
  banner += 'Editor:\n'
  banner += '\t"editor" will run the SimpleCV code editor in a browser\n'
  banner += '\t\texample:'
  banner += 'help Image or ?Image\n'
  banner += '\t\twill give the in-depth information about that class\n'
  banner += '\t"?function_name" will give the quick API documentation\n'
  banner += '\t\texample:'
  banner += '?Image.save\n'
  banner += '\t\twill give help on the image save function'
  exit_msg = '\n... [Exiting the SimpleCV interactive shell] ...\n'


  #IPython version is less than 11
  if IPVER <= 10:
    #setup terminal to show SCV prompt
    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("cheatsheet", magic_cheatsheet)
    scvShell.IP.api.expose_magic("example", magic_examples)
    scvShell.IP.api.expose_magic("editor", magic_editor)
    
    return scvShell

  #IPython version 0.11 or higher
  else:
    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("cheatsheet", magic_cheatsheet)
    scvShell.define_magic("example", magic_examples)
    scvShell.define_magic("editor", magic_editor)

    return scvShell
开发者ID:gregorynicholas,项目名称:simplecv,代码行数:65,代码来源:Shell.py


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