##// END OF EJS Templates
utils: coloransi: Escape Unicode U0001 and U0002 non-printable characters....
utils: coloransi: Escape Unicode U0001 and U0002 non-printable characters. Fixes #13637. These Unicode characters, would cause problems when processed by LaTeX to generate the info or PDF documentation targets. * IPython/utils/coloransi.py (InputTermColors): Escape the backslashes in \001 and \002 so that they are shown as literals '\001' and '\002' strings in the Sphinx-generated documentation rather than as non-printable Unicode characters.

File last commit:

r26726:72a79cb1
r27688:f20e3b80
Show More
__init__.py
62 lines | 1.2 KiB | text/x-python | PythonLexer
import importlib
import os
aliases = {
'qt4': 'qt',
'gtk2': 'gtk',
}
backends = [
"qt",
"qt4",
"qt5",
"qt6",
"gtk",
"gtk2",
"gtk3",
"gtk4",
"tk",
"wx",
"pyglet",
"glut",
"osx",
"asyncio",
]
registered = {}
def register(name, inputhook):
"""Register the function *inputhook* as an event loop integration."""
registered[name] = inputhook
class UnknownBackend(KeyError):
def __init__(self, name):
self.name = name
def __str__(self):
return ("No event loop integration for {!r}. "
"Supported event loops are: {}").format(self.name,
', '.join(backends + sorted(registered)))
def get_inputhook_name_and_func(gui):
if gui in registered:
return gui, registered[gui]
if gui not in backends:
raise UnknownBackend(gui)
if gui in aliases:
return get_inputhook_name_and_func(aliases[gui])
gui_mod = gui
if gui == "qt5":
os.environ["QT_API"] = "pyqt5"
gui_mod = "qt"
elif gui == "qt6":
os.environ["QT_API"] = "pyqt6"
gui_mod = "qt"
mod = importlib.import_module('IPython.terminal.pt_inputhooks.'+gui_mod)
return gui, mod.inputhook