aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/utils
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-02-15 11:42:00 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-02-15 11:57:41 +0300
commit0de9b4a47867a2f539f7f5f02078bc353f6fb044 (patch)
treee60d2593309655d66f72d1a61ea42980313379ca /contrib/python/ipython/py3/IPython/utils
parent6ecbb0cbb39049f5c9166871ffd217e60d3494bf (diff)
downloadydb-0de9b4a47867a2f539f7f5f02078bc353f6fb044.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/ipython/py3/IPython/utils')
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_process_posix.py7
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_sysinfo.py2
-rw-r--r--contrib/python/ipython/py3/IPython/utils/coloransi.py46
3 files changed, 46 insertions, 9 deletions
diff --git a/contrib/python/ipython/py3/IPython/utils/_process_posix.py b/contrib/python/ipython/py3/IPython/utils/_process_posix.py
index 59b5c23896..a429ba105a 100644
--- a/contrib/python/ipython/py3/IPython/utils/_process_posix.py
+++ b/contrib/python/ipython/py3/IPython/utils/_process_posix.py
@@ -20,8 +20,6 @@ import os
import subprocess as sp
import sys
-import pexpect
-
# Our own
from ._process_common import getoutput, arg_split
from IPython.utils.encoding import DEFAULT_ENCODING
@@ -51,6 +49,7 @@ class ProcessHandler(object):
@property
def sh(self):
if self._sh is None:
+ import pexpect
shell_name = os.environ.get("SHELL", "sh")
self._sh = pexpect.which(shell_name)
if self._sh is None:
@@ -83,6 +82,7 @@ class ProcessHandler(object):
file descriptors (so the order of the information in this string is the
correct order as would be seen if running the command in a terminal).
"""
+ import pexpect
try:
return pexpect.run(self.sh, args=['-c', cmd]).replace('\r\n', '\n')
except KeyboardInterrupt:
@@ -104,6 +104,7 @@ class ProcessHandler(object):
file descriptors (so the order of the information in this string is the
correct order as would be seen if running the command in a terminal).
"""
+ import pexpect
try:
return pexpect.run(self.sh, args=['-c', cmd]).replace('\r\n', '\n')
except KeyboardInterrupt:
@@ -121,6 +122,8 @@ class ProcessHandler(object):
-------
int : child's exitstatus
"""
+ import pexpect
+
# Get likely encoding for the output.
enc = DEFAULT_ENCODING
diff --git a/contrib/python/ipython/py3/IPython/utils/_sysinfo.py b/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
index 461aae5256..56568073d7 100644
--- a/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
+++ b/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
@@ -1,2 +1,2 @@
# GENERATED BY setup.py
-commit = "19f24dd8e"
+commit = "8b1204b6c"
diff --git a/contrib/python/ipython/py3/IPython/utils/coloransi.py b/contrib/python/ipython/py3/IPython/utils/coloransi.py
index 9300b01085..a4a14c5648 100644
--- a/contrib/python/ipython/py3/IPython/utils/coloransi.py
+++ b/contrib/python/ipython/py3/IPython/utils/coloransi.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""Tools for coloring text in ANSI terminals.
"""
@@ -9,12 +8,16 @@
# the file COPYING, distributed as part of this software.
#*****************************************************************************
-__all__ = ['TermColors','InputTermColors','ColorScheme','ColorSchemeTable']
import os
+import warnings
from IPython.utils.ipstruct import Struct
+__all__ = ["TermColors", "InputTermColors", "ColorScheme", "ColorSchemeTable"]
+
+_sentinel = object()
+
color_templates = (
# Dark colors
("Black" , "0;30"),
@@ -110,8 +113,22 @@ for name, value in color_templates:
class ColorScheme:
"""Generic color scheme class. Just a name and a Struct."""
- def __init__(self,__scheme_name_,colordict=None,**colormap):
+
+ name: str
+ colors: Struct
+
+ def __init__(self, __scheme_name_, colordict=None, **colormap):
self.name = __scheme_name_
+ if colormap:
+ warnings.warn(
+ "Passing each colors as a kwarg to ColorScheme is "
+ "considered for deprecation. Please pass a "
+ "a single dict as second parameter. If you are using this"
+ "feature, please comment an subscribe to issue "
+ "https://github.com/ipython/ipython/issues/14304",
+ PendingDeprecationWarning,
+ stacklevel=2,
+ )
if colordict is None:
self.colors = Struct(**colormap)
else:
@@ -155,18 +172,35 @@ class ColorSchemeTable(dict):
"""Return full copy of object"""
return ColorSchemeTable(self.values(),self.active_scheme_name)
- def add_scheme(self,new_scheme):
+ def __setitem__(self, key: str, value: ColorScheme):
+ assert isinstance(key, str)
+ assert isinstance(value, ColorScheme)
+ super().__setitem__(key, value)
+
+ def add_scheme(self, new_scheme):
"""Add a new color scheme to the table."""
- if not isinstance(new_scheme,ColorScheme):
+ 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):
+ def set_active_scheme(self, scheme, case_sensitive=_sentinel):
"""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."""
+ if case_sensitive is _sentinel:
+ case_sensitive = False
+ else:
+ warnings.warn(
+ "set_active_scheme(case_sensitive=...) is Pending "
+ "deprecation. Please comment on "
+ "https://github.com/ipython/ipython/issues/14306 "
+ "to let the ipython maintainer that you are affected.",
+ PendingDeprecationWarning,
+ stacklevel=2,
+ )
+
scheme_names = list(self.keys())
if case_sensitive:
valid_schemes = scheme_names