##// END OF EJS Templates
Prepare removal of unnecessary options of ColorSchemeTable.
Matthias Bussonnier -
Show More
@@ -15,6 +15,8 b' from IPython.utils.ipstruct import Struct'
15
15
16 __all__ = ["TermColors", "InputTermColors", "ColorScheme", "ColorSchemeTable"]
16 __all__ = ["TermColors", "InputTermColors", "ColorScheme", "ColorSchemeTable"]
17
17
18 _sentinel = object()
19
18 color_templates = (
20 color_templates = (
19 # Dark colors
21 # Dark colors
20 ("Black" , "0;30"),
22 ("Black" , "0;30"),
@@ -159,18 +161,35 b' class ColorSchemeTable(dict):'
159 """Return full copy of object"""
161 """Return full copy of object"""
160 return ColorSchemeTable(self.values(),self.active_scheme_name)
162 return ColorSchemeTable(self.values(),self.active_scheme_name)
161
163
162 def add_scheme(self,new_scheme):
164 def __setitem__(self, key: str, value: ColorScheme):
165 assert isinstance(key, str)
166 assert isinstance(value, ColorScheme)
167 super().__setitem__(key, value)
168
169 def add_scheme(self, new_scheme):
163 """Add a new color scheme to the table."""
170 """Add a new color scheme to the table."""
164 if not isinstance(new_scheme,ColorScheme):
171 if not isinstance(new_scheme, ColorScheme):
165 raise ValueError('ColorSchemeTable only accepts ColorScheme instances')
172 raise ValueError('ColorSchemeTable only accepts ColorScheme instances')
166 self[new_scheme.name] = new_scheme
173 self[new_scheme.name] = new_scheme
167
174
168 def set_active_scheme(self,scheme,case_sensitive=0):
175 def set_active_scheme(self, scheme, case_sensitive=_sentinel):
169 """Set the currently active scheme.
176 """Set the currently active scheme.
170
177
171 Names are by default compared in a case-insensitive way, but this can
178 Names are by default compared in a case-insensitive way, but this can
172 be changed by setting the parameter case_sensitive to true."""
179 be changed by setting the parameter case_sensitive to true."""
173
180
181 if case_sensitive is _sentinel:
182 case_sensitive = False
183 else:
184 warnings.warn(
185 "set_active_scheme(case_sensitive=...) is Pending "
186 "deprecation. Please comment on "
187 "https://github.com/ipython/ipython/issues/14306 "
188 "to let the ipython maintainer that you are affected.",
189 PendingDeprecationWarning,
190 stacklevel=2,
191 )
192
174 scheme_names = list(self.keys())
193 scheme_names = list(self.keys())
175 if case_sensitive:
194 if case_sensitive:
176 valid_schemes = scheme_names
195 valid_schemes = scheme_names
General Comments 0
You need to be logged in to leave comments. Login now