Python IPython.version_info() Examples
The following are 5
code examples of IPython.version_info().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
IPython
, or try the search function
.
Example #1
Source File: _tags.py From colabtools with Apache License 2.0 | 5 votes |
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
Example #2
Source File: konch.py From konch with MIT License | 5 votes |
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
Example #3
Source File: console.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #4
Source File: console.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
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%})'
Example #5
Source File: jirashell.py From jira with BSD 2-Clause "Simplified" License | 4 votes |
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