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


Python IPython.version_info方法代码示例

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


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

示例1: _add_or_remove_tags

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import version_info [as 别名]
def _add_or_remove_tags(tags_to_add=(), tags_to_remove=()):
  """Adds or removes tags from the frontend."""
  # Clear tags when this cell is done.
  output_tags = _get_or_create_tags()
  tags_to_add = tuple(tags_to_add)
  tags_to_remove = tuple(tags_to_remove)

  output_tags.update(tags_to_add)
  output_tags.difference_update(tags_to_remove)

  sys.stdout.flush()
  sys.stderr.flush()

  metadata = {
      'outputarea': {
          'nodisplay': True,
          'add_tags': tags_to_add,
          'remove_tags': tags_to_remove
      }
  }

  if ipython.in_ipython():
    if IPython.version_info[0] > 2:
      display.publish_display_data({}, metadata=metadata)
    else:
      display.publish_display_data('display', {}, metadata=metadata)

  return output_tags 
开发者ID:googlecolab,项目名称:colabtools,代码行数:30,代码来源:_tags.py

示例2: configure_ipython_prompt

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import version_info [as 别名]
def configure_ipython_prompt(
    config, prompt: typing.Optional[str] = None, output: typing.Optional[str] = None
) -> None:
    import IPython

    if IPython.version_info[0] >= 5:  # Custom prompt API changed in IPython 5.0
        from pygments.token import Token

        # https://ipython.readthedocs.io/en/stable/config/details.html#custom-prompts  # noqa: B950
        class CustomPrompt(IPython.terminal.prompts.Prompts):
            def in_prompt_tokens(self, *args, **kwargs):
                if prompt is None:
                    return super().in_prompt_tokens(*args, **kwargs)
                if isinstance(prompt, (str, bytes)):
                    return [(Token.Prompt, prompt)]
                else:
                    return prompt

            def out_prompt_tokens(self, *args, **kwargs):
                if output is None:
                    return super().out_prompt_tokens(*args, **kwargs)
                if isinstance(output, (str, bytes)):
                    return [(Token.OutPrompt, output)]
                else:
                    return prompt

        config.TerminalInteractiveShell.prompts_class = CustomPrompt
    else:
        prompt_config = config.PromptManager
        if prompt:
            prompt_config.in_template = prompt
        if output:
            prompt_config.out_template = output
    return None 
开发者ID:sloria,项目名称:konch,代码行数:36,代码来源:konch.py

示例3: OutStream

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import version_info [as 别名]
def OutStream(cls):
        if not hasattr(cls, '_OutStream'):
            cls._OutStream = None
            try:
                cls.get_ipython()
            except NameError:
                return None

            try:
                from ipykernel.iostream import OutStream
            except ImportError:
                try:
                    from IPython.zmq.iostream import OutStream
                except ImportError:
                    from IPython import version_info
                    if version_info[0] >= 4:
                        return None

                    try:
                        from IPython.kernel.zmq.iostream import OutStream
                    except ImportError:
                        return None

            cls._OutStream = OutStream

        return cls._OutStream 
开发者ID:holzschu,项目名称:Carnets,代码行数:28,代码来源:console.py

示例4: _update_ipython_widget

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import version_info [as 别名]
def _update_ipython_widget(self, value=None):
        """
        Update the progress bar to the given value (out of a total
        given to the constructor).

        This method is for use in the IPython notebook 2+.
        """

        # Create and display an empty progress bar widget,
        # if none exists.
        if not hasattr(self, '_widget'):
            # Import only if an IPython widget, i.e., widget in iPython NB
            from IPython import version_info
            if version_info[0] < 4:
                from IPython.html import widgets
                self._widget = widgets.FloatProgressWidget()
            else:
                _IPython.get_ipython()
                from ipywidgets import widgets
                self._widget = widgets.FloatProgress()
            from IPython.display import display

            display(self._widget)
            self._widget.value = 0

        # Calculate percent completion, and update progress bar
        frac = (value/self._total)
        self._widget.value = frac * 100
        self._widget.description = f' ({frac:>6.2%})' 
开发者ID:holzschu,项目名称:Carnets,代码行数:31,代码来源:console.py

示例5: main

# 需要导入模块: import IPython [as 别名]
# 或者: from IPython import version_info [as 别名]
def main():

    try:
        try:
            get_ipython
        except NameError:
            pass
        else:
            sys.exit("Running ipython inside ipython isn't supported. :(")

        options, basic_auth, oauth, kerberos_auth = get_config()

        if basic_auth:
            basic_auth = handle_basic_auth(auth=basic_auth, server=options["server"])

        if oauth.get("oauth_dance") is True:
            oauth = oauth_dance(
                options["server"],
                oauth["consumer_key"],
                oauth["key_cert"],
                oauth["print_tokens"],
                options["verify"],
            )
        elif not all(
            (
                oauth.get("access_token"),
                oauth.get("access_token_secret"),
                oauth.get("consumer_key"),
                oauth.get("key_cert"),
            )
        ):
            oauth = None

        use_kerberos = kerberos_auth.get("use_kerberos", False)
        del kerberos_auth["use_kerberos"]

        jira = JIRA(
            options=options,
            basic_auth=basic_auth,
            kerberos=use_kerberos,
            kerberos_options=kerberos_auth,
            oauth=oauth,
        )

        import IPython

        # The top-level `frontend` package has been deprecated since IPython 1.0.
        if IPython.version_info[0] >= 1:
            from IPython.terminal.embed import InteractiveShellEmbed
        else:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed

        ip_shell = InteractiveShellEmbed(
            banner1="<Jira Shell " + __version__ + " (" + jira.client_info() + ")>"
        )
        ip_shell("*** Jira shell active; client is in 'jira'." " Press Ctrl-D to exit.")
    except Exception as e:
        print(e, file=sys.stderr)
        return 2 
开发者ID:pycontribs,项目名称:jira,代码行数:61,代码来源:jirashell.py


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