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


Python IPython.utils方法代码示例

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


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

示例1: get_security_file

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import utils [as 别名]
def get_security_file(filename, profile='default'):
    """Return the absolute path of a security file given by filename and profile
    
    This allows users and developers to find security files without
    knowledge of the IPython directory structure. The search path
    will be ['.', profile.security_dir]
    
    Parameters
    ----------
    
    filename : str
        The file to be found. If it is passed as an absolute path, it will
        simply be returned.
    profile : str [default: 'default']
        The name of the profile to search.  Leaving this unspecified
        The file to be found. If it is passed as an absolute path, fname will
        simply be returned.
    
    Returns
    -------
    Raises :exc:`IOError` if file not found or returns absolute path to file.
    """
    # import here, because profiledir also imports from utils.path
    from IPython.core.profiledir import ProfileDir
    try:
        pd = ProfileDir.find_profile_dir_by_name(get_ipython_dir(), profile)
    except Exception:
        # will raise ProfileDirError if no such profile
        raise IOError("Profile %r not found")
    return filefind(filename, ['.', pd.security_dir]) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:32,代码来源:path.py

示例2: start

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import utils [as 别名]
def start(self) -> None:
        try:
            from IPython import start_ipython
            from IPython.utils import io
            from traitlets.config.loader import Config as IPyConfig
        except ImportError:
            raise ShellNotAvailableError(
                "IPython shell not available " "or IPython version not supported."
            )
        # Hack to show custom banner
        # TerminalIPythonApp/start_app doesn't allow you to customize the
        # banner directly, so we write it to stdout before starting the IPython app
        io.stdout.write(self.banner)
        # Pass exec_lines in order to start autoreload
        if self.ipy_autoreload:
            if not isinstance(self.ipy_autoreload, bool):
                mode = self.ipy_autoreload
            else:
                mode = 2
            logger.debug(f"Initializing IPython autoreload in mode {mode}")
            exec_lines = [
                "import konch as __konch",
                f"__konch.IPythonShell.init_autoreload({mode})",
            ]
        else:
            exec_lines = []
        ipy_config = IPyConfig()
        if self.ipy_colors:
            ipy_config.TerminalInteractiveShell.colors = self.ipy_colors
        if self.ipy_highlighting_style:
            ipy_config.TerminalInteractiveShell.highlighting_style = (
                self.ipy_highlighting_style
            )
        configure_ipython_prompt(ipy_config, prompt=self.prompt, output=self.output)
        # Use start_ipython rather than embed so that IPython is loaded in the "normal"
        # way. See https://github.com/django/django/pull/512
        start_ipython(
            display_banner=False,
            user_ns=self.context,
            config=ipy_config,
            extensions=self.ipy_extensions or [],
            exec_lines=exec_lines,
            argv=[],
        )
        return None 
开发者ID:sloria,项目名称:konch,代码行数:47,代码来源:konch.py


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