Python IPython.utils() Examples
The following are 2
code examples of IPython.utils().
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: path.py From Computable with MIT License | 5 votes |
def get_security_file(filename, profile='default'): """Return the absolute path of a security file given by filename and profile This allows users and developers to find security files without knowledge of the IPython directory structure. The search path will be ['.', profile.security_dir] Parameters ---------- filename : str The file to be found. If it is passed as an absolute path, it will simply be returned. profile : str [default: 'default'] The name of the profile to search. Leaving this unspecified The file to be found. If it is passed as an absolute path, fname will simply be returned. Returns ------- Raises :exc:`IOError` if file not found or returns absolute path to file. """ # import here, because profiledir also imports from utils.path from IPython.core.profiledir import ProfileDir try: pd = ProfileDir.find_profile_dir_by_name(get_ipython_dir(), profile) except Exception: # will raise ProfileDirError if no such profile raise IOError("Profile %r not found") return filefind(filename, ['.', pd.security_dir])
Example #2
Source File: konch.py From konch with MIT License | 4 votes |
def start(self) -> None: try: from IPython import start_ipython from IPython.utils import io from traitlets.config.loader import Config as IPyConfig except ImportError: raise ShellNotAvailableError( "IPython shell not available " "or IPython version not supported." ) # Hack to show custom banner # TerminalIPythonApp/start_app doesn't allow you to customize the # banner directly, so we write it to stdout before starting the IPython app io.stdout.write(self.banner) # Pass exec_lines in order to start autoreload if self.ipy_autoreload: if not isinstance(self.ipy_autoreload, bool): mode = self.ipy_autoreload else: mode = 2 logger.debug(f"Initializing IPython autoreload in mode {mode}") exec_lines = [ "import konch as __konch", f"__konch.IPythonShell.init_autoreload({mode})", ] else: exec_lines = [] ipy_config = IPyConfig() if self.ipy_colors: ipy_config.TerminalInteractiveShell.colors = self.ipy_colors if self.ipy_highlighting_style: ipy_config.TerminalInteractiveShell.highlighting_style = ( self.ipy_highlighting_style ) configure_ipython_prompt(ipy_config, prompt=self.prompt, output=self.output) # Use start_ipython rather than embed so that IPython is loaded in the "normal" # way. See https://github.com/django/django/pull/512 start_ipython( display_banner=False, user_ns=self.context, config=ipy_config, extensions=self.ipy_extensions or [], exec_lines=exec_lines, argv=[], ) return None