aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py2/IPython/terminal/embed.py
diff options
context:
space:
mode:
authorNikita Slyusarev <nslus@yandex-team.com>2022-02-10 16:46:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:52 +0300
commitcd77cecfc03a3eaf87816af28a33067c4f0cdb59 (patch)
tree1308e0bae862d52e0020d881fe758080437fe389 /contrib/python/ipython/py2/IPython/terminal/embed.py
parentcdae02d225fb5b3afbb28990e79a7ac6c9125327 (diff)
downloadydb-cd77cecfc03a3eaf87816af28a33067c4f0cdb59.tar.gz
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/ipython/py2/IPython/terminal/embed.py')
-rw-r--r--contrib/python/ipython/py2/IPython/terminal/embed.py66
1 files changed, 33 insertions, 33 deletions
diff --git a/contrib/python/ipython/py2/IPython/terminal/embed.py b/contrib/python/ipython/py2/IPython/terminal/embed.py
index 5ad70431e42..9f8be00a778 100644
--- a/contrib/python/ipython/py2/IPython/terminal/embed.py
+++ b/contrib/python/ipython/py2/IPython/terminal/embed.py
@@ -14,7 +14,7 @@ import warnings
from IPython.core import ultratb, compilerop
from IPython.core import magic_arguments
from IPython.core.magic import Magics, magics_class, line_magic
-from IPython.core.interactiveshell import DummyMod, InteractiveShell
+from IPython.core.interactiveshell import DummyMod, InteractiveShell
from IPython.terminal.interactiveshell import TerminalInteractiveShell
from IPython.terminal.ipapp import load_default_config
@@ -117,33 +117,33 @@ class InteractiveShellEmbed(TerminalInteractiveShell):
display_banner = CBool(True)
exit_msg = Unicode()
- # When embedding, by default we don't change the terminal title
- term_title = Bool(False,
- help="Automatically set the terminal title"
- ).tag(config=True)
-
- _inactive_locations = set()
-
- @property
- def embedded_active(self):
+ # When embedding, by default we don't change the terminal title
+ term_title = Bool(False,
+ help="Automatically set the terminal title"
+ ).tag(config=True)
+
+ _inactive_locations = set()
+
+ @property
+ def embedded_active(self):
return (self._call_location_id not in InteractiveShellEmbed._inactive_locations)\
and (self._init_location_id not in InteractiveShellEmbed._inactive_locations)
-
+
def _disable_init_location(self):
"""Disable the current Instance creation location"""
InteractiveShellEmbed._inactive_locations.add(self._init_location_id)
- @embedded_active.setter
- def embedded_active(self, value):
+ @embedded_active.setter
+ def embedded_active(self, value):
if value:
InteractiveShellEmbed._inactive_locations.discard(
self._call_location_id)
InteractiveShellEmbed._inactive_locations.discard(
self._init_location_id)
- else:
+ else:
InteractiveShellEmbed._inactive_locations.add(
self._call_location_id)
-
+
def __init__(self, **kw):
if kw.get('user_global_ns', None) is not None:
raise DeprecationWarning(
@@ -154,7 +154,7 @@ class InteractiveShellEmbed(TerminalInteractiveShell):
frame = sys._getframe(1)
clid = '%s:%s' % (frame.f_code.co_filename, frame.f_lineno)
self._init_location_id = clid
-
+
super(InteractiveShellEmbed,self).__init__(**kw)
# don't use the ipython crash handler so that user exceptions aren't
@@ -219,9 +219,9 @@ class InteractiveShellEmbed(TerminalInteractiveShell):
else:
self.old_banner2 = ''
- if self.display_banner:
- self.show_banner()
-
+ if self.display_banner:
+ self.show_banner()
+
# Call the embedding code with a stack depth of 1 so it can skip over
# our call and get the original caller's namespaces.
self.mainloop(local_ns, module, stack_depth=stack_depth,
@@ -264,11 +264,11 @@ class InteractiveShellEmbed(TerminalInteractiveShell):
"""
if (global_ns is not None) and (module is None):
- raise DeprecationWarning("'global_ns' keyword argument is deprecated, and has been removed in IPython 5.0 use `module` keyword argument instead.")
-
- if (display_banner is not None):
- warnings.warn("The display_banner parameter is deprecated since IPython 4.0", DeprecationWarning)
+ raise DeprecationWarning("'global_ns' keyword argument is deprecated, and has been removed in IPython 5.0 use `module` keyword argument instead.")
+ if (display_banner is not None):
+ warnings.warn("The display_banner parameter is deprecated since IPython 4.0", DeprecationWarning)
+
# Get locals and globals from caller
if ((local_ns is None or module is None or compile_flags is None)
and self.default_user_namespaces):
@@ -278,14 +278,14 @@ class InteractiveShellEmbed(TerminalInteractiveShell):
local_ns = call_frame.f_locals
if module is None:
global_ns = call_frame.f_globals
- try:
- module = sys.modules[global_ns['__name__']]
- except KeyError:
- warnings.warn("Failed to get module %s" % \
- global_ns.get('__name__', 'unknown module')
- )
- module = DummyMod()
- module.__dict__ = global_ns
+ try:
+ module = sys.modules[global_ns['__name__']]
+ except KeyError:
+ warnings.warn("Failed to get module %s" % \
+ global_ns.get('__name__', 'unknown module')
+ )
+ module = DummyMod()
+ module.__dict__ = global_ns
if compile_flags is None:
compile_flags = (call_frame.f_code.co_flags &
compilerop.PyCF_MASK)
@@ -320,7 +320,7 @@ class InteractiveShellEmbed(TerminalInteractiveShell):
self.set_completer_frame()
with self.builtin_trap, self.display_trap:
- self.interact()
+ self.interact()
# now, purge out the local namespace of IPython's hidden variables.
if local_ns is not None:
@@ -378,7 +378,7 @@ def embed(**kwargs):
if saved_shell_instance is not None:
cls = type(saved_shell_instance)
cls.clear_instance()
- frame = sys._getframe(1)
+ frame = sys._getframe(1)
shell = InteractiveShellEmbed.instance(_init_location_id='%s:%s' % (
frame.f_code.co_filename, frame.f_lineno), **kwargs)
shell(header=header, stack_depth=2, compile_flags=compile_flags,