diff --git a/tasks/vendoring/patches/patched/crayons.patch b/tasks/vendoring/patches/patched/crayons.patch index 98dea222..b9e3b1d0 100644 --- a/tasks/vendoring/patches/patched/crayons.patch +++ b/tasks/vendoring/patches/patched/crayons.patch @@ -1,36 +1,104 @@ diff --git a/pipenv/patched/crayons.py b/pipenv/patched/crayons.py -index 455d3e9..7c9ff0d 100644 +index 455d3e90..bb4b3d97 100644 --- a/pipenv/patched/crayons.py +++ b/pipenv/patched/crayons.py -@@ -12,14 +12,14 @@ import os +@@ -12,21 +12,45 @@ import os import re import sys -PY3 = sys.version_info[0] >= 3 - ++import shellingham import colorama +PY3 = sys.version_info[0] >= 3 + __all__ = ( - 'red', 'green', 'yellow', 'blue', +- 'red', 'green', 'yellow', 'blue', - 'black', 'magenta', 'cyan', 'white', - 'clean', 'disable' -+ 'black', 'magenta', 'cyan', 'white', 'normal', -+ 'clean', 'disable', ++ "red", ++ "green", ++ "yellow", ++ "blue", ++ "black", ++ "magenta", ++ "cyan", ++ "white", ++ "normal", ++ "clean", ++ "disable", ) COLORS = __all__[:-2] -@@ -46,7 +46,7 @@ class ColoredString(object): + +-if 'get_ipython' in dir(): +- """ +- when ipython is fired lot of variables like _oh, etc are used. ++is_ipython = "get_ipython" in dir() ++ ++if ( ++ os.environ.get("CMDER_ROOT") ++ or os.environ.get("VSCODE_PID") ++ or os.environ.get("TERM_PROGRAM") == "Hyper" ++): ++ is_native_powershell = False ++else: ++ is_native_powershell = True ++ ++try: ++ is_powershell = "powershell" in shellingham.detect_shell()[0] ++except shellingham.ShellDetectionFailure: ++ is_powershell = False ++ ++if is_ipython or (is_powershell and is_native_powershell): ++ """when ipython is fired lot of variables like _oh, etc are used. + There are so many ways to find current python interpreter is ipython. + get_ipython is easiest is most appealing for readers to understand. + """ +@@ -37,16 +61,17 @@ else: + + class ColoredString(object): + """Enhanced string for __len__ operations on Colored output.""" ++ + def __init__(self, color, s, always_color=False, bold=False): + super(ColoredString, self).__init__() + if not PY3 and isinstance(s, unicode): +- self.s = s.encode('utf-8') ++ self.s = s.encode("utf-8") + else: + self.s = s self.color = color self.always_color = always_color self.bold = bold - if os.environ.get('CLINT_FORCE_COLOR'): -+ if os.environ.get('PIPENV_FORCE_COLOR'): ++ if os.environ.get("PIPENV_FORCE_COLOR"): self.always_color = True def __getattr__(self, att): -@@ -76,7 +76,6 @@ class ColoredString(object): +@@ -62,12 +87,19 @@ class ColoredString(object): + return [self._new(x) for x in result] + else: + return result ++ + return func_help + + @property + def color_str(self): +- style = 'BRIGHT' if self.bold else 'NORMAL' +- c = '%s%s%s%s%s' % (getattr(colorama.Fore, self.color), getattr(colorama.Style, style), self.s, colorama.Fore.RESET, getattr(colorama.Style, 'NORMAL')) ++ style = "BRIGHT" if self.bold else "NORMAL" ++ c = "%s%s%s%s%s" % ( ++ getattr(colorama.Fore, self.color), ++ getattr(colorama.Style, style), ++ self.s, ++ colorama.Fore.RESET, ++ getattr(colorama.Style, "NORMAL"), ++ ) + + if self.always_color: + return c +@@ -76,7 +108,6 @@ class ColoredString(object): else: return self.s @@ -38,47 +106,92 @@ index 455d3e9..7c9ff0d 100644 def __len__(self): return len(self.s) -@@ -121,30 +120,43 @@ def clean(s): +@@ -86,12 +117,13 @@ class ColoredString(object): + def __unicode__(self): + value = self.color_str + if isinstance(value, bytes): +- return value.decode('utf8') ++ return value.decode("utf8") + return value + + if PY3: + __str__ = __unicode__ + else: ++ + def __str__(self): + return self.color_str + +@@ -105,45 +137,60 @@ class ColoredString(object): + return str(other) + str(self.color_str) + + def __mul__(self, other): +- return (self.color_str * other) ++ return self.color_str * other + + def _new(self, s): + return ColoredString(self.color, s) + + + def clean(s): +- strip = re.compile("([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)") +- txt = strip.sub('', str(s)) ++ strip = re.compile( ++ "([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)" ++ ) ++ txt = strip.sub("", str(s)) + +- strip = re.compile(r'\[\d+m') +- txt = strip.sub('', txt) ++ strip = re.compile(r"\[\d+m") ++ txt = strip.sub("", txt) + return txt +def normal(string, always=False, bold=False): -+ return ColoredString('RESET', string, always_color=always, bold=bold) ++ return ColoredString("RESET", string, always_color=always, bold=bold) + + def black(string, always=False, bold=False): - return ColoredString('BLACK', string, always_color=always, bold=bold) - +- return ColoredString('BLACK', string, always_color=always, bold=bold) ++ return ColoredString("BLACK", string, always_color=always, bold=bold) + + def red(string, always=False, bold=False): - return ColoredString('RED', string, always_color=always, bold=bold) - +- return ColoredString('RED', string, always_color=always, bold=bold) ++ return ColoredString("RED", string, always_color=always, bold=bold) + + def green(string, always=False, bold=False): - return ColoredString('GREEN', string, always_color=always, bold=bold) - +- return ColoredString('GREEN', string, always_color=always, bold=bold) ++ return ColoredString("GREEN", string, always_color=always, bold=bold) + + def yellow(string, always=False, bold=False): - return ColoredString('YELLOW', string, always_color=always, bold=bold) - +- return ColoredString('YELLOW', string, always_color=always, bold=bold) ++ return ColoredString("YELLOW", string, always_color=always, bold=bold) + + def blue(string, always=False, bold=False): - return ColoredString('BLUE', string, always_color=always, bold=bold) - +- return ColoredString('BLUE', string, always_color=always, bold=bold) ++ return ColoredString("BLUE", string, always_color=always, bold=bold) + + def magenta(string, always=False, bold=False): - return ColoredString('MAGENTA', string, always_color=always, bold=bold) - +- return ColoredString('MAGENTA', string, always_color=always, bold=bold) ++ return ColoredString("MAGENTA", string, always_color=always, bold=bold) + + def cyan(string, always=False, bold=False): - return ColoredString('CYAN', string, always_color=always, bold=bold) - +- return ColoredString('CYAN', string, always_color=always, bold=bold) ++ return ColoredString("CYAN", string, always_color=always, bold=bold) + + def white(string, always=False, bold=False): +- return ColoredString('WHITE', string, always_color=always, bold=bold) + # This upsets people... - return ColoredString('WHITE', string, always_color=always, bold=bold) - ++ return ColoredString("WHITE", string, always_color=always, bold=bold) + + def disable(): """Disables colors.""" - global DISABLE_COLOR