/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/macro.py (1734B)
"""Support for interactive macros in IPython""" #***************************************************************************** # Copyright (C) 2001-2005 Fernando Perez # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #***************************************************************************** import re from IPython.utils.encoding import DEFAULT_ENCODING coding_declaration = re.compile(r"#\s*coding[:=]\s*([-\w.]+)") class Macro(object): """Simple class to store the value of macros as strings. Macro is just a callable that executes a string of IPython input when called. """ def __init__(self,code): """store the macro value, as a single string which can be executed""" lines = [] enc = None for line in code.splitlines(): coding_match = coding_declaration.match(line) if coding_match: enc = coding_match.group(1) else: lines.append(line) code = "\n".join(lines) if isinstance(code, bytes): code = code.decode(enc or DEFAULT_ENCODING) self.value = code + '\n' def __str__(self): return self.value def __repr__(self): return 'IPython.macro.Macro(%s)' % repr(self.value) def __getstate__(self): """ needed for safe pickling via %store """ return {'value': self.value} def __add__(self, other): if isinstance(other, Macro): return Macro(self.value + other.value) elif isinstance(other, str): return Macro(self.value + other) raise TypeError