/opt/imh-python/lib/python3.9/site-packages/IPython/core
NameSizeModeActions
magics/-0755rm
profile/-0755rm
tests/-0755rm
__pycache__/-0755rm
alias.py100340644editdlrm
application.py189370644editdlrm
async_helpers.py42970644editdlrm
autocall.py19910644editdlrm
builtin_trap.py30090644editdlrm
compilerop.py77300644editdlrm
completer.py1178500644editdlrm
completerlib.py123650644editdlrm
crashhandler.py85080644editdlrm
debugger.py388720644editdlrm
display.py425030644editdlrm
displayhook.py129620644editdlrm
displaypub.py49440644editdlrm
display_functions.py129180644editdlrm
display_trap.py20980644editdlrm
error.py17340644editdlrm
events.py52510644editdlrm
excolors.py49280644editdlrm
extensions.py57800644editdlrm
formatters.py349810644editdlrm
getipython.py9120644editdlrm
guarded_eval.py250370644editdlrm
history.py344750644editdlrm
historyapp.py59090644editdlrm
hooks.py56630644editdlrm
inputsplitter.py290410644editdlrm
inputtransformer.py181840644editdlrm
inputtransformer2.py293930644editdlrm
interactiveshell.py1537610644editdlrm
latex_symbols.py312880644editdlrm
logger.py84410644editdlrm
macro.py17340644editdlrm
magic.py288990644editdlrm
magic_arguments.py97340644editdlrm
oinspect.py398980644editdlrm
page.py117530644editdlrm
payload.py17580644editdlrm
payloadpage.py14310644editdlrm
prefilter.py255880644editdlrm
profileapp.py106310644editdlrm
profiledir.py80290644editdlrm
prompts.py6070644editdlrm
pylabtools.py140180644editdlrm
release.py21780644editdlrm
shellapp.py178450644editdlrm
splitinput.py48360644editdlrm
ultratb.py558030644editdlrm
usage.py135420644editdlrm
__init__.py00644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/IPython/core/display_trap.py (2098B)
# encoding: utf-8 """ A context manager for handling sys.displayhook. Authors: * Robert Kern * Brian Granger """ #----------------------------------------------------------------------------- # Copyright (C) 2008-2011 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- import sys from traitlets.config.configurable import Configurable from traitlets import Any #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- class DisplayTrap(Configurable): """Object to manage sys.displayhook. This came from IPython.core.kernel.display_hook, but is simplified (no callbacks or formatters) until more of the core is refactored. """ hook = Any() def __init__(self, hook=None): super(DisplayTrap, self).__init__(hook=hook, config=None) self.old_hook = None # We define this to track if a single BuiltinTrap is nested. # Only turn off the trap when the outermost call to __exit__ is made. self._nested_level = 0 def __enter__(self): if self._nested_level == 0: self.set() self._nested_level += 1 return self def __exit__(self, type, value, traceback): if self._nested_level == 1: self.unset() self._nested_level -= 1 # Returning False will cause exceptions to propagate return False def set(self): """Set the hook.""" if sys.displayhook is not self.hook: self.old_hook = sys.displayhook sys.displayhook = self.hook def unset(self): """Unset the hook.""" sys.displayhook = self.old_hook