/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
IPython
/
utils
/
/opt/imh-python/lib/python3.9/site-packages/IPython/utils
mkdir
upload
Name
Size
Mode
Actions
tests/
-
0755
rm
__pycache__/
-
0755
rm
capture.py
5161
0644
edit
dl
rm
colorable.py
786
0644
edit
dl
rm
coloransi.py
6972
0644
edit
dl
rm
contexts.py
1619
0644
edit
dl
rm
daemonize.py
200
0644
edit
dl
rm
data.py
1015
0644
edit
dl
rm
decorators.py
2680
0644
edit
dl
rm
dir2.py
2232
0644
edit
dl
rm
docs.py
86
0644
edit
dl
rm
encoding.py
2843
0644
edit
dl
rm
eventful.py
138
0644
edit
dl
rm
frame.py
3048
0644
edit
dl
rm
generics.py
706
0644
edit
dl
rm
importstring.py
1050
0644
edit
dl
rm
io.py
4631
0644
edit
dl
rm
ipstruct.py
11856
0644
edit
dl
rm
jsonutil.py
148
0644
edit
dl
rm
localinterfaces.py
169
0644
edit
dl
rm
log.py
123
0644
edit
dl
rm
module_paths.py
2327
0644
edit
dl
rm
openpy.py
3417
0644
edit
dl
rm
path.py
11937
0644
edit
dl
rm
process.py
1878
0644
edit
dl
rm
py3compat.py
1602
0644
edit
dl
rm
PyColorize.py
10875
0644
edit
dl
rm
sentinel.py
421
0644
edit
dl
rm
shimmodule.py
2669
0644
edit
dl
rm
signatures.py
474
0644
edit
dl
rm
strdispatch.py
1838
0644
edit
dl
rm
sysinfo.py
4365
0644
edit
dl
rm
syspathcontext.py
1952
0644
edit
dl
rm
tempdir.py
1867
0644
edit
dl
rm
terminal.py
3206
0644
edit
dl
rm
text.py
24428
0644
edit
dl
rm
timing.py
4275
0644
edit
dl
rm
tokenutil.py
5083
0644
edit
dl
rm
traitlets.py
143
0644
edit
dl
rm
tz.py
1380
0644
edit
dl
rm
ulinecache.py
684
0644
edit
dl
rm
version.py
1223
0644
edit
dl
rm
wildcard.py
4612
0644
edit
dl
rm
_process_cli.py
2020
0644
edit
dl
rm
_process_common.py
7003
0644
edit
dl
rm
_process_posix.py
8666
0644
edit
dl
rm
_process_win32.py
6132
0644
edit
dl
rm
_process_win32_controller.py
21329
0644
edit
dl
rm
_sysinfo.py
45
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/IPython/utils/coloransi.py
(6972B)
# -*- coding: utf-8 -*- """Tools for coloring text in ANSI terminals. """ #***************************************************************************** # Copyright (C) 2002-2006 Fernando Perez. <fperez@colorado.edu> # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #***************************************************************************** __all__ = ['TermColors','InputTermColors','ColorScheme','ColorSchemeTable'] import os from IPython.utils.ipstruct import Struct color_templates = ( # Dark colors ("Black" , "0;30"), ("Red" , "0;31"), ("Green" , "0;32"), ("Brown" , "0;33"), ("Blue" , "0;34"), ("Purple" , "0;35"), ("Cyan" , "0;36"), ("LightGray" , "0;37"), # Light colors ("DarkGray" , "1;30"), ("LightRed" , "1;31"), ("LightGreen" , "1;32"), ("Yellow" , "1;33"), ("LightBlue" , "1;34"), ("LightPurple" , "1;35"), ("LightCyan" , "1;36"), ("White" , "1;37"), # Blinking colors. Probably should not be used in anything serious. ("BlinkBlack" , "5;30"), ("BlinkRed" , "5;31"), ("BlinkGreen" , "5;32"), ("BlinkYellow" , "5;33"), ("BlinkBlue" , "5;34"), ("BlinkPurple" , "5;35"), ("BlinkCyan" , "5;36"), ("BlinkLightGray", "5;37"), ) def make_color_table(in_class): """Build a set of color attributes in a class. Helper function for building the :class:`TermColors` and :class`InputTermColors`. """ for name,value in color_templates: setattr(in_class,name,in_class._base % value) class TermColors: """Color escape sequences. This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining 'dummy' color schemes in terminals which get confused by color escapes. This class should be used as a mixin for building color schemes.""" NoColor = '' # for color schemes in color-less terminals. Normal = '\033[0m' # Reset normal coloring _base = '\033[%sm' # Template for all other colors # Build the actual color table as a set of class attributes: make_color_table(TermColors) class InputTermColors: """Color escape sequences for input prompts. This class is similar to TermColors, but the escapes are wrapped in \\001 and \\002 so that readline can properly know the length of each line and can wrap lines accordingly. Use this class for any colored text which needs to be used in input prompts, such as in calls to raw_input(). This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining 'dummy' color schemes in terminals which get confused by color escapes. This class should be used as a mixin for building color schemes.""" NoColor = '' # for color schemes in color-less terminals. if os.name == 'nt' and os.environ.get('TERM','dumb') == 'emacs': # (X)emacs on W32 gets confused with \001 and \002 so we remove them Normal = '\033[0m' # Reset normal coloring _base = '\033[%sm' # Template for all other colors else: Normal = '\001\033[0m\002' # Reset normal coloring _base = '\001\033[%sm\002' # Template for all other colors # Build the actual color table as a set of class attributes: make_color_table(InputTermColors) class NoColors: """This defines all the same names as the colour classes, but maps them to empty strings, so it can easily be substituted to turn off colours.""" NoColor = '' Normal = '' for name, value in color_templates: setattr(NoColors, name, '') class ColorScheme: """Generic color scheme class. Just a name and a Struct.""" def __init__(self,__scheme_name_,colordict=None,**colormap): self.name = __scheme_name_ if colordict is None: self.colors = Struct(**colormap) else: self.colors = Struct(colordict) def copy(self,name=None): """Return a full copy of the object, optionally renaming it.""" if name is None: name = self.name return ColorScheme(name, self.colors.dict()) class ColorSchemeTable(dict): """General class to handle tables of color schemes. It's basically a dict of color schemes with a couple of shorthand attributes and some convenient methods. active_scheme_name -> obvious active_colors -> actual color table of the active scheme""" def __init__(self, scheme_list=None, default_scheme=''): """Create a table of color schemes. The table can be created empty and manually filled or it can be created with a list of valid color schemes AND the specification for the default active scheme. """ # create object attributes to be set later self.active_scheme_name = '' self.active_colors = None if scheme_list: if default_scheme == '': raise ValueError('you must specify the default color scheme') for scheme in scheme_list: self.add_scheme(scheme) self.set_active_scheme(default_scheme) def copy(self): """Return full copy of object""" return ColorSchemeTable(self.values(),self.active_scheme_name) def add_scheme(self,new_scheme): """Add a new color scheme to the table.""" if not isinstance(new_scheme,ColorScheme): raise ValueError('ColorSchemeTable only accepts ColorScheme instances') self[new_scheme.name] = new_scheme def set_active_scheme(self,scheme,case_sensitive=0): """Set the currently active scheme. Names are by default compared in a case-insensitive way, but this can be changed by setting the parameter case_sensitive to true.""" scheme_names = list(self.keys()) if case_sensitive: valid_schemes = scheme_names scheme_test = scheme else: valid_schemes = [s.lower() for s in scheme_names] scheme_test = scheme.lower() try: scheme_idx = valid_schemes.index(scheme_test) except ValueError as e: raise ValueError('Unrecognized color scheme: ' + scheme + \ '\nValid schemes: '+str(scheme_names).replace("'', ",'')) from e else: active = scheme_names[scheme_idx] self.active_scheme_name = active self.active_colors = self[active].colors # Now allow using '' as an index for the current active scheme self[''] = self[active]
Save
cmd:
run