當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。