diff options
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama')
6 files changed, 0 insertions, 745 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/__init__.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/__init__.py deleted file mode 100644 index 10c372d..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/__init__.py +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
2 | from .initialise import init, deinit, reinit, colorama_text | ||
3 | from .ansi import Fore, Back, Style, Cursor | ||
4 | from .ansitowin32 import AnsiToWin32 | ||
5 | |||
6 | __version__ = '0.3.9' | ||
7 | |||
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/ansi.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/ansi.py deleted file mode 100644 index 8530fd0..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/ansi.py +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
2 | ''' | ||
3 | This module generates ANSI character codes to printing colors to terminals. | ||
4 | See: http://en.wikipedia.org/wiki/ANSI_escape_code | ||
5 | ''' | ||
6 | |||
7 | CSI = '\033[' | ||
8 | OSC = '\033]' | ||
9 | BEL = '\007' | ||
10 | |||
11 | |||
12 | def code_to_chars(code): | ||
13 | return CSI + str(code) + 'm' | ||
14 | |||
15 | def set_title(title): | ||
16 | return OSC + '2;' + title + BEL | ||
17 | |||
18 | def clear_screen(mode=2): | ||
19 | return CSI + str(mode) + 'J' | ||
20 | |||
21 | def clear_line(mode=2): | ||
22 | return CSI + str(mode) + 'K' | ||
23 | |||
24 | |||
25 | class AnsiCodes(object): | ||
26 | def __init__(self): | ||
27 | # the subclasses declare class attributes which are numbers. | ||
28 | # Upon instantiation we define instance attributes, which are the same | ||
29 | # as the class attributes but wrapped with the ANSI escape sequence | ||
30 | for name in dir(self): | ||
31 | if not name.startswith('_'): | ||
32 | value = getattr(self, name) | ||
33 | setattr(self, name, code_to_chars(value)) | ||
34 | |||
35 | |||
36 | class AnsiCursor(object): | ||
37 | def UP(self, n=1): | ||
38 | return CSI + str(n) + 'A' | ||
39 | def DOWN(self, n=1): | ||
40 | return CSI + str(n) + 'B' | ||
41 | def FORWARD(self, n=1): | ||
42 | return CSI + str(n) + 'C' | ||
43 | def BACK(self, n=1): | ||
44 | return CSI + str(n) + 'D' | ||
45 | def POS(self, x=1, y=1): | ||
46 | return CSI + str(y) + ';' + str(x) + 'H' | ||
47 | |||
48 | |||
49 | class AnsiFore(AnsiCodes): | ||
50 | BLACK = 30 | ||
51 | RED = 31 | ||
52 | GREEN = 32 | ||
53 | YELLOW = 33 | ||
54 | BLUE = 34 | ||
55 | MAGENTA = 35 | ||
56 | CYAN = 36 | ||
57 | WHITE = 37 | ||
58 | RESET = 39 | ||
59 | |||
60 | # These are fairly well supported, but not part of the standard. | ||
61 | LIGHTBLACK_EX = 90 | ||
62 | LIGHTRED_EX = 91 | ||
63 | LIGHTGREEN_EX = 92 | ||
64 | LIGHTYELLOW_EX = 93 | ||
65 | LIGHTBLUE_EX = 94 | ||
66 | LIGHTMAGENTA_EX = 95 | ||
67 | LIGHTCYAN_EX = 96 | ||
68 | LIGHTWHITE_EX = 97 | ||
69 | |||
70 | |||
71 | class AnsiBack(AnsiCodes): | ||
72 | BLACK = 40 | ||
73 | RED = 41 | ||
74 | GREEN = 42 | ||
75 | YELLOW = 43 | ||
76 | BLUE = 44 | ||
77 | MAGENTA = 45 | ||
78 | CYAN = 46 | ||
79 | WHITE = 47 | ||
80 | RESET = 49 | ||
81 | |||
82 | # These are fairly well supported, but not part of the standard. | ||
83 | LIGHTBLACK_EX = 100 | ||
84 | LIGHTRED_EX = 101 | ||
85 | LIGHTGREEN_EX = 102 | ||
86 | LIGHTYELLOW_EX = 103 | ||
87 | LIGHTBLUE_EX = 104 | ||
88 | LIGHTMAGENTA_EX = 105 | ||
89 | LIGHTCYAN_EX = 106 | ||
90 | LIGHTWHITE_EX = 107 | ||
91 | |||
92 | |||
93 | class AnsiStyle(AnsiCodes): | ||
94 | BRIGHT = 1 | ||
95 | DIM = 2 | ||
96 | NORMAL = 22 | ||
97 | RESET_ALL = 0 | ||
98 | |||
99 | Fore = AnsiFore() | ||
100 | Back = AnsiBack() | ||
101 | Style = AnsiStyle() | ||
102 | Cursor = AnsiCursor() | ||
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/ansitowin32.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/ansitowin32.py deleted file mode 100644 index 0cb9efc..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/ansitowin32.py +++ /dev/null | |||
@@ -1,236 +0,0 @@ | |||
1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
2 | import re | ||
3 | import sys | ||
4 | import os | ||
5 | |||
6 | from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style | ||
7 | from .winterm import WinTerm, WinColor, WinStyle | ||
8 | from .win32 import windll, winapi_test | ||
9 | |||
10 | |||
11 | winterm = None | ||
12 | if windll is not None: | ||
13 | winterm = WinTerm() | ||
14 | |||
15 | |||
16 | def is_stream_closed(stream): | ||
17 | return not hasattr(stream, 'closed') or stream.closed | ||
18 | |||
19 | |||
20 | def is_a_tty(stream): | ||
21 | return hasattr(stream, 'isatty') and stream.isatty() | ||
22 | |||
23 | |||
24 | class StreamWrapper(object): | ||
25 | ''' | ||
26 | Wraps a stream (such as stdout), acting as a transparent proxy for all | ||
27 | attribute access apart from method 'write()', which is delegated to our | ||
28 | Converter instance. | ||
29 | ''' | ||
30 | def __init__(self, wrapped, converter): | ||
31 | # double-underscore everything to prevent clashes with names of | ||
32 | # attributes on the wrapped stream object. | ||
33 | self.__wrapped = wrapped | ||
34 | self.__convertor = converter | ||
35 | |||
36 | def __getattr__(self, name): | ||
37 | return getattr(self.__wrapped, name) | ||
38 | |||
39 | def write(self, text): | ||
40 | self.__convertor.write(text) | ||
41 | |||
42 | |||
43 | class AnsiToWin32(object): | ||
44 | ''' | ||
45 | Implements a 'write()' method which, on Windows, will strip ANSI character | ||
46 | sequences from the text, and if outputting to a tty, will convert them into | ||
47 | win32 function calls. | ||
48 | ''' | ||
49 | ANSI_CSI_RE = re.compile('\001?\033\\[((?:\\d|;)*)([a-zA-Z])\002?') # Control Sequence Introducer | ||
50 | ANSI_OSC_RE = re.compile('\001?\033\\]((?:.|;)*?)(\x07)\002?') # Operating System Command | ||
51 | |||
52 | def __init__(self, wrapped, convert=None, strip=None, autoreset=False): | ||
53 | # The wrapped stream (normally sys.stdout or sys.stderr) | ||
54 | self.wrapped = wrapped | ||
55 | |||
56 | # should we reset colors to defaults after every .write() | ||
57 | self.autoreset = autoreset | ||
58 | |||
59 | # create the proxy wrapping our output stream | ||
60 | self.stream = StreamWrapper(wrapped, self) | ||
61 | |||
62 | on_windows = os.name == 'nt' | ||
63 | # We test if the WinAPI works, because even if we are on Windows | ||
64 | # we may be using a terminal that doesn't support the WinAPI | ||
65 | # (e.g. Cygwin Terminal). In this case it's up to the terminal | ||
66 | # to support the ANSI codes. | ||
67 | conversion_supported = on_windows and winapi_test() | ||
68 | |||
69 | # should we strip ANSI sequences from our output? | ||
70 | if strip is None: | ||
71 | strip = conversion_supported or (not is_stream_closed(wrapped) and not is_a_tty(wrapped)) | ||
72 | self.strip = strip | ||
73 | |||
74 | # should we should convert ANSI sequences into win32 calls? | ||
75 | if convert is None: | ||
76 | convert = conversion_supported and not is_stream_closed(wrapped) and is_a_tty(wrapped) | ||
77 | self.convert = convert | ||
78 | |||
79 | # dict of ansi codes to win32 functions and parameters | ||
80 | self.win32_calls = self.get_win32_calls() | ||
81 | |||
82 | # are we wrapping stderr? | ||
83 | self.on_stderr = self.wrapped is sys.stderr | ||
84 | |||
85 | def should_wrap(self): | ||
86 | ''' | ||
87 | True if this class is actually needed. If false, then the output | ||
88 | stream will not be affected, nor will win32 calls be issued, so | ||
89 | wrapping stdout is not actually required. This will generally be | ||
90 | False on non-Windows platforms, unless optional functionality like | ||
91 | autoreset has been requested using kwargs to init() | ||
92 | ''' | ||
93 | return self.convert or self.strip or self.autoreset | ||
94 | |||
95 | def get_win32_calls(self): | ||
96 | if self.convert and winterm: | ||
97 | return { | ||
98 | AnsiStyle.RESET_ALL: (winterm.reset_all, ), | ||
99 | AnsiStyle.BRIGHT: (winterm.style, WinStyle.BRIGHT), | ||
100 | AnsiStyle.DIM: (winterm.style, WinStyle.NORMAL), | ||
101 | AnsiStyle.NORMAL: (winterm.style, WinStyle.NORMAL), | ||
102 | AnsiFore.BLACK: (winterm.fore, WinColor.BLACK), | ||
103 | AnsiFore.RED: (winterm.fore, WinColor.RED), | ||
104 | AnsiFore.GREEN: (winterm.fore, WinColor.GREEN), | ||
105 | AnsiFore.YELLOW: (winterm.fore, WinColor.YELLOW), | ||
106 | AnsiFore.BLUE: (winterm.fore, WinColor.BLUE), | ||
107 | AnsiFore.MAGENTA: (winterm.fore, WinColor.MAGENTA), | ||
108 | AnsiFore.CYAN: (winterm.fore, WinColor.CYAN), | ||
109 | AnsiFore.WHITE: (winterm.fore, WinColor.GREY), | ||
110 | AnsiFore.RESET: (winterm.fore, ), | ||
111 | AnsiFore.LIGHTBLACK_EX: (winterm.fore, WinColor.BLACK, True), | ||
112 | AnsiFore.LIGHTRED_EX: (winterm.fore, WinColor.RED, True), | ||
113 | AnsiFore.LIGHTGREEN_EX: (winterm.fore, WinColor.GREEN, True), | ||
114 | AnsiFore.LIGHTYELLOW_EX: (winterm.fore, WinColor.YELLOW, True), | ||
115 | AnsiFore.LIGHTBLUE_EX: (winterm.fore, WinColor.BLUE, True), | ||
116 | AnsiFore.LIGHTMAGENTA_EX: (winterm.fore, WinColor.MAGENTA, True), | ||
117 | AnsiFore.LIGHTCYAN_EX: (winterm.fore, WinColor.CYAN, True), | ||
118 | AnsiFore.LIGHTWHITE_EX: (winterm.fore, WinColor.GREY, True), | ||
119 | AnsiBack.BLACK: (winterm.back, WinColor.BLACK), | ||
120 | AnsiBack.RED: (winterm.back, WinColor.RED), | ||
121 | AnsiBack.GREEN: (winterm.back, WinColor.GREEN), | ||
122 | AnsiBack.YELLOW: (winterm.back, WinColor.YELLOW), | ||
123 | AnsiBack.BLUE: (winterm.back, WinColor.BLUE), | ||
124 | AnsiBack.MAGENTA: (winterm.back, WinColor.MAGENTA), | ||
125 | AnsiBack.CYAN: (winterm.back, WinColor.CYAN), | ||
126 | AnsiBack.WHITE: (winterm.back, WinColor.GREY), | ||
127 | AnsiBack.RESET: (winterm.back, ), | ||
128 | AnsiBack.LIGHTBLACK_EX: (winterm.back, WinColor.BLACK, True), | ||
129 | AnsiBack.LIGHTRED_EX: (winterm.back, WinColor.RED, True), | ||
130 | AnsiBack.LIGHTGREEN_EX: (winterm.back, WinColor.GREEN, True), | ||
131 | AnsiBack.LIGHTYELLOW_EX: (winterm.back, WinColor.YELLOW, True), | ||
132 | AnsiBack.LIGHTBLUE_EX: (winterm.back, WinColor.BLUE, True), | ||
133 | AnsiBack.LIGHTMAGENTA_EX: (winterm.back, WinColor.MAGENTA, True), | ||
134 | AnsiBack.LIGHTCYAN_EX: (winterm.back, WinColor.CYAN, True), | ||
135 | AnsiBack.LIGHTWHITE_EX: (winterm.back, WinColor.GREY, True), | ||
136 | } | ||
137 | return dict() | ||
138 | |||
139 | def write(self, text): | ||
140 | if self.strip or self.convert: | ||
141 | self.write_and_convert(text) | ||
142 | else: | ||
143 | self.wrapped.write(text) | ||
144 | self.wrapped.flush() | ||
145 | if self.autoreset: | ||
146 | self.reset_all() | ||
147 | |||
148 | |||
149 | def reset_all(self): | ||
150 | if self.convert: | ||
151 | self.call_win32('m', (0,)) | ||
152 | elif not self.strip and not is_stream_closed(self.wrapped): | ||
153 | self.wrapped.write(Style.RESET_ALL) | ||
154 | |||
155 | |||
156 | def write_and_convert(self, text): | ||
157 | ''' | ||
158 | Write the given text to our wrapped stream, stripping any ANSI | ||
159 | sequences from the text, and optionally converting them into win32 | ||
160 | calls. | ||
161 | ''' | ||
162 | cursor = 0 | ||
163 | text = self.convert_osc(text) | ||
164 | for match in self.ANSI_CSI_RE.finditer(text): | ||
165 | start, end = match.span() | ||
166 | self.write_plain_text(text, cursor, start) | ||
167 | self.convert_ansi(*match.groups()) | ||
168 | cursor = end | ||
169 | self.write_plain_text(text, cursor, len(text)) | ||
170 | |||
171 | |||
172 | def write_plain_text(self, text, start, end): | ||
173 | if start < end: | ||
174 | self.wrapped.write(text[start:end]) | ||
175 | self.wrapped.flush() | ||
176 | |||
177 | |||
178 | def convert_ansi(self, paramstring, command): | ||
179 | if self.convert: | ||
180 | params = self.extract_params(command, paramstring) | ||
181 | self.call_win32(command, params) | ||
182 | |||
183 | |||
184 | def extract_params(self, command, paramstring): | ||
185 | if command in 'Hf': | ||
186 | params = tuple(int(p) if len(p) != 0 else 1 for p in paramstring.split(';')) | ||
187 | while len(params) < 2: | ||
188 | # defaults: | ||
189 | params = params + (1,) | ||
190 | else: | ||
191 | params = tuple(int(p) for p in paramstring.split(';') if len(p) != 0) | ||
192 | if len(params) == 0: | ||
193 | # defaults: | ||
194 | if command in 'JKm': | ||
195 | params = (0,) | ||
196 | elif command in 'ABCD': | ||
197 | params = (1,) | ||
198 | |||
199 | return params | ||
200 | |||
201 | |||
202 | def call_win32(self, command, params): | ||
203 | if command == 'm': | ||
204 | for param in params: | ||
205 | if param in self.win32_calls: | ||
206 | func_args = self.win32_calls[param] | ||
207 | func = func_args[0] | ||
208 | args = func_args[1:] | ||
209 | kwargs = dict(on_stderr=self.on_stderr) | ||
210 | func(*args, **kwargs) | ||
211 | elif command in 'J': | ||
212 | winterm.erase_screen(params[0], on_stderr=self.on_stderr) | ||
213 | elif command in 'K': | ||
214 | winterm.erase_line(params[0], on_stderr=self.on_stderr) | ||
215 | elif command in 'Hf': # cursor position - absolute | ||
216 | winterm.set_cursor_position(params, on_stderr=self.on_stderr) | ||
217 | elif command in 'ABCD': # cursor position - relative | ||
218 | n = params[0] | ||
219 | # A - up, B - down, C - forward, D - back | ||
220 | x, y = {'A': (0, -n), 'B': (0, n), 'C': (n, 0), 'D': (-n, 0)}[command] | ||
221 | winterm.cursor_adjust(x, y, on_stderr=self.on_stderr) | ||
222 | |||
223 | |||
224 | def convert_osc(self, text): | ||
225 | for match in self.ANSI_OSC_RE.finditer(text): | ||
226 | start, end = match.span() | ||
227 | text = text[:start] + text[end:] | ||
228 | paramstring, command = match.groups() | ||
229 | if command in '\x07': # \x07 = BEL | ||
230 | params = paramstring.split(";") | ||
231 | # 0 - change title and icon (we will only change title) | ||
232 | # 1 - change icon (we don't support this) | ||
233 | # 2 - change title | ||
234 | if params[0] in '02': | ||
235 | winterm.set_title(params[1]) | ||
236 | return text | ||
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/initialise.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/initialise.py deleted file mode 100644 index 7f03156..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/initialise.py +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
2 | import atexit | ||
3 | import contextlib | ||
4 | import sys | ||
5 | |||
6 | from .ansitowin32 import AnsiToWin32 | ||
7 | |||
8 | |||
9 | orig_stdout = None | ||
10 | orig_stderr = None | ||
11 | |||
12 | wrapped_stdout = None | ||
13 | wrapped_stderr = None | ||
14 | |||
15 | atexit_done = False | ||
16 | |||
17 | |||
18 | def reset_all(): | ||
19 | if AnsiToWin32 is not None: # Issue #74: objects might become None at exit | ||
20 | AnsiToWin32(orig_stdout).reset_all() | ||
21 | |||
22 | |||
23 | def init(autoreset=False, convert=None, strip=None, wrap=True): | ||
24 | |||
25 | if not wrap and any([autoreset, convert, strip]): | ||
26 | raise ValueError('wrap=False conflicts with any other arg=True') | ||
27 | |||
28 | global wrapped_stdout, wrapped_stderr | ||
29 | global orig_stdout, orig_stderr | ||
30 | |||
31 | orig_stdout = sys.stdout | ||
32 | orig_stderr = sys.stderr | ||
33 | |||
34 | if sys.stdout is None: | ||
35 | wrapped_stdout = None | ||
36 | else: | ||
37 | sys.stdout = wrapped_stdout = \ | ||
38 | wrap_stream(orig_stdout, convert, strip, autoreset, wrap) | ||
39 | if sys.stderr is None: | ||
40 | wrapped_stderr = None | ||
41 | else: | ||
42 | sys.stderr = wrapped_stderr = \ | ||
43 | wrap_stream(orig_stderr, convert, strip, autoreset, wrap) | ||
44 | |||
45 | global atexit_done | ||
46 | if not atexit_done: | ||
47 | atexit.register(reset_all) | ||
48 | atexit_done = True | ||
49 | |||
50 | |||
51 | def deinit(): | ||
52 | if orig_stdout is not None: | ||
53 | sys.stdout = orig_stdout | ||
54 | if orig_stderr is not None: | ||
55 | sys.stderr = orig_stderr | ||
56 | |||
57 | |||
58 | @contextlib.contextmanager | ||
59 | def colorama_text(*args, **kwargs): | ||
60 | init(*args, **kwargs) | ||
61 | try: | ||
62 | yield | ||
63 | finally: | ||
64 | deinit() | ||
65 | |||
66 | |||
67 | def reinit(): | ||
68 | if wrapped_stdout is not None: | ||
69 | sys.stdout = wrapped_stdout | ||
70 | if wrapped_stderr is not None: | ||
71 | sys.stderr = wrapped_stderr | ||
72 | |||
73 | |||
74 | def wrap_stream(stream, convert, strip, autoreset, wrap): | ||
75 | if wrap: | ||
76 | wrapper = AnsiToWin32(stream, | ||
77 | convert=convert, strip=strip, autoreset=autoreset) | ||
78 | if wrapper.should_wrap(): | ||
79 | stream = wrapper.stream | ||
80 | return stream | ||
81 | |||
82 | |||
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/win32.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/win32.py deleted file mode 100644 index 1485e69..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/win32.py +++ /dev/null | |||
@@ -1,156 +0,0 @@ | |||
1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
2 | |||
3 | # from winbase.h | ||
4 | STDOUT = -11 | ||
5 | STDERR = -12 | ||
6 | |||
7 | try: | ||
8 | import ctypes | ||
9 | from ctypes import LibraryLoader | ||
10 | windll = LibraryLoader(ctypes.WinDLL) | ||
11 | from ctypes import wintypes | ||
12 | except (AttributeError, ImportError): | ||
13 | windll = None | ||
14 | SetConsoleTextAttribute = lambda *_: None | ||
15 | winapi_test = lambda *_: None | ||
16 | else: | ||
17 | from ctypes import byref, Structure, c_char, POINTER | ||
18 | |||
19 | COORD = wintypes._COORD | ||
20 | |||
21 | class CONSOLE_SCREEN_BUFFER_INFO(Structure): | ||
22 | """struct in wincon.h.""" | ||
23 | _fields_ = [ | ||
24 | ("dwSize", COORD), | ||
25 | ("dwCursorPosition", COORD), | ||
26 | ("wAttributes", wintypes.WORD), | ||
27 | ("srWindow", wintypes.SMALL_RECT), | ||
28 | ("dwMaximumWindowSize", COORD), | ||
29 | ] | ||
30 | def __str__(self): | ||
31 | return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % ( | ||
32 | self.dwSize.Y, self.dwSize.X | ||
33 | , self.dwCursorPosition.Y, self.dwCursorPosition.X | ||
34 | , self.wAttributes | ||
35 | , self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right | ||
36 | , self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X | ||
37 | ) | ||
38 | |||
39 | _GetStdHandle = windll.kernel32.GetStdHandle | ||
40 | _GetStdHandle.argtypes = [ | ||
41 | wintypes.DWORD, | ||
42 | ] | ||
43 | _GetStdHandle.restype = wintypes.HANDLE | ||
44 | |||
45 | _GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo | ||
46 | _GetConsoleScreenBufferInfo.argtypes = [ | ||
47 | wintypes.HANDLE, | ||
48 | POINTER(CONSOLE_SCREEN_BUFFER_INFO), | ||
49 | ] | ||
50 | _GetConsoleScreenBufferInfo.restype = wintypes.BOOL | ||
51 | |||
52 | _SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute | ||
53 | _SetConsoleTextAttribute.argtypes = [ | ||
54 | wintypes.HANDLE, | ||
55 | wintypes.WORD, | ||
56 | ] | ||
57 | _SetConsoleTextAttribute.restype = wintypes.BOOL | ||
58 | |||
59 | _SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition | ||
60 | _SetConsoleCursorPosition.argtypes = [ | ||
61 | wintypes.HANDLE, | ||
62 | COORD, | ||
63 | ] | ||
64 | _SetConsoleCursorPosition.restype = wintypes.BOOL | ||
65 | |||
66 | _FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA | ||
67 | _FillConsoleOutputCharacterA.argtypes = [ | ||
68 | wintypes.HANDLE, | ||
69 | c_char, | ||
70 | wintypes.DWORD, | ||
71 | COORD, | ||
72 | POINTER(wintypes.DWORD), | ||
73 | ] | ||
74 | _FillConsoleOutputCharacterA.restype = wintypes.BOOL | ||
75 | |||
76 | _FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute | ||
77 | _FillConsoleOutputAttribute.argtypes = [ | ||
78 | wintypes.HANDLE, | ||
79 | wintypes.WORD, | ||
80 | wintypes.DWORD, | ||
81 | COORD, | ||
82 | POINTER(wintypes.DWORD), | ||
83 | ] | ||
84 | _FillConsoleOutputAttribute.restype = wintypes.BOOL | ||
85 | |||
86 | _SetConsoleTitleW = windll.kernel32.SetConsoleTitleW | ||
87 | _SetConsoleTitleW.argtypes = [ | ||
88 | wintypes.LPCWSTR | ||
89 | ] | ||
90 | _SetConsoleTitleW.restype = wintypes.BOOL | ||
91 | |||
92 | handles = { | ||
93 | STDOUT: _GetStdHandle(STDOUT), | ||
94 | STDERR: _GetStdHandle(STDERR), | ||
95 | } | ||
96 | |||
97 | def _winapi_test(handle): | ||
98 | csbi = CONSOLE_SCREEN_BUFFER_INFO() | ||
99 | success = _GetConsoleScreenBufferInfo( | ||
100 | handle, byref(csbi)) | ||
101 | return bool(success) | ||
102 | |||
103 | def winapi_test(): | ||
104 | return any(_winapi_test(h) for h in handles.values()) | ||
105 | |||
106 | def GetConsoleScreenBufferInfo(stream_id=STDOUT): | ||
107 | handle = handles[stream_id] | ||
108 | csbi = CONSOLE_SCREEN_BUFFER_INFO() | ||
109 | success = _GetConsoleScreenBufferInfo( | ||
110 | handle, byref(csbi)) | ||
111 | return csbi | ||
112 | |||
113 | def SetConsoleTextAttribute(stream_id, attrs): | ||
114 | handle = handles[stream_id] | ||
115 | return _SetConsoleTextAttribute(handle, attrs) | ||
116 | |||
117 | def SetConsoleCursorPosition(stream_id, position, adjust=True): | ||
118 | position = COORD(*position) | ||
119 | # If the position is out of range, do nothing. | ||
120 | if position.Y <= 0 or position.X <= 0: | ||
121 | return | ||
122 | # Adjust for Windows' SetConsoleCursorPosition: | ||
123 | # 1. being 0-based, while ANSI is 1-based. | ||
124 | # 2. expecting (x,y), while ANSI uses (y,x). | ||
125 | adjusted_position = COORD(position.Y - 1, position.X - 1) | ||
126 | if adjust: | ||
127 | # Adjust for viewport's scroll position | ||
128 | sr = GetConsoleScreenBufferInfo(STDOUT).srWindow | ||
129 | adjusted_position.Y += sr.Top | ||
130 | adjusted_position.X += sr.Left | ||
131 | # Resume normal processing | ||
132 | handle = handles[stream_id] | ||
133 | return _SetConsoleCursorPosition(handle, adjusted_position) | ||
134 | |||
135 | def FillConsoleOutputCharacter(stream_id, char, length, start): | ||
136 | handle = handles[stream_id] | ||
137 | char = c_char(char.encode()) | ||
138 | length = wintypes.DWORD(length) | ||
139 | num_written = wintypes.DWORD(0) | ||
140 | # Note that this is hard-coded for ANSI (vs wide) bytes. | ||
141 | success = _FillConsoleOutputCharacterA( | ||
142 | handle, char, length, start, byref(num_written)) | ||
143 | return num_written.value | ||
144 | |||
145 | def FillConsoleOutputAttribute(stream_id, attr, length, start): | ||
146 | ''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )''' | ||
147 | handle = handles[stream_id] | ||
148 | attribute = wintypes.WORD(attr) | ||
149 | length = wintypes.DWORD(length) | ||
150 | num_written = wintypes.DWORD(0) | ||
151 | # Note that this is hard-coded for ANSI (vs wide) bytes. | ||
152 | return _FillConsoleOutputAttribute( | ||
153 | handle, attribute, length, start, byref(num_written)) | ||
154 | |||
155 | def SetConsoleTitle(title): | ||
156 | return _SetConsoleTitleW(title) | ||
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/winterm.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/winterm.py deleted file mode 100644 index 385862e..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/colorama/winterm.py +++ /dev/null | |||
@@ -1,162 +0,0 @@ | |||
1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
2 | from . import win32 | ||
3 | |||
4 | |||
5 | # from wincon.h | ||
6 | class WinColor(object): | ||
7 | BLACK = 0 | ||
8 | BLUE = 1 | ||
9 | GREEN = 2 | ||
10 | CYAN = 3 | ||
11 | RED = 4 | ||
12 | MAGENTA = 5 | ||
13 | YELLOW = 6 | ||
14 | GREY = 7 | ||
15 | |||
16 | # from wincon.h | ||
17 | class WinStyle(object): | ||
18 | NORMAL = 0x00 # dim text, dim background | ||
19 | BRIGHT = 0x08 # bright text, dim background | ||
20 | BRIGHT_BACKGROUND = 0x80 # dim text, bright background | ||
21 | |||
22 | class WinTerm(object): | ||
23 | |||
24 | def __init__(self): | ||
25 | self._default = win32.GetConsoleScreenBufferInfo(win32.STDOUT).wAttributes | ||
26 | self.set_attrs(self._default) | ||
27 | self._default_fore = self._fore | ||
28 | self._default_back = self._back | ||
29 | self._default_style = self._style | ||
30 | # In order to emulate LIGHT_EX in windows, we borrow the BRIGHT style. | ||
31 | # So that LIGHT_EX colors and BRIGHT style do not clobber each other, | ||
32 | # we track them separately, since LIGHT_EX is overwritten by Fore/Back | ||
33 | # and BRIGHT is overwritten by Style codes. | ||
34 | self._light = 0 | ||
35 | |||
36 | def get_attrs(self): | ||
37 | return self._fore + self._back * 16 + (self._style | self._light) | ||
38 | |||
39 | def set_attrs(self, value): | ||
40 | self._fore = value & 7 | ||
41 | self._back = (value >> 4) & 7 | ||
42 | self._style = value & (WinStyle.BRIGHT | WinStyle.BRIGHT_BACKGROUND) | ||
43 | |||
44 | def reset_all(self, on_stderr=None): | ||
45 | self.set_attrs(self._default) | ||
46 | self.set_console(attrs=self._default) | ||
47 | |||
48 | def fore(self, fore=None, light=False, on_stderr=False): | ||
49 | if fore is None: | ||
50 | fore = self._default_fore | ||
51 | self._fore = fore | ||
52 | # Emulate LIGHT_EX with BRIGHT Style | ||
53 | if light: | ||
54 | self._light |= WinStyle.BRIGHT | ||
55 | else: | ||
56 | self._light &= ~WinStyle.BRIGHT | ||
57 | self.set_console(on_stderr=on_stderr) | ||
58 | |||
59 | def back(self, back=None, light=False, on_stderr=False): | ||
60 | if back is None: | ||
61 | back = self._default_back | ||
62 | self._back = back | ||
63 | # Emulate LIGHT_EX with BRIGHT_BACKGROUND Style | ||
64 | if light: | ||
65 | self._light |= WinStyle.BRIGHT_BACKGROUND | ||
66 | else: | ||
67 | self._light &= ~WinStyle.BRIGHT_BACKGROUND | ||
68 | self.set_console(on_stderr=on_stderr) | ||
69 | |||
70 | def style(self, style=None, on_stderr=False): | ||
71 | if style is None: | ||
72 | style = self._default_style | ||
73 | self._style = style | ||
74 | self.set_console(on_stderr=on_stderr) | ||
75 | |||
76 | def set_console(self, attrs=None, on_stderr=False): | ||
77 | if attrs is None: | ||
78 | attrs = self.get_attrs() | ||
79 | handle = win32.STDOUT | ||
80 | if on_stderr: | ||
81 | handle = win32.STDERR | ||
82 | win32.SetConsoleTextAttribute(handle, attrs) | ||
83 | |||
84 | def get_position(self, handle): | ||
85 | position = win32.GetConsoleScreenBufferInfo(handle).dwCursorPosition | ||
86 | # Because Windows coordinates are 0-based, | ||
87 | # and win32.SetConsoleCursorPosition expects 1-based. | ||
88 | position.X += 1 | ||
89 | position.Y += 1 | ||
90 | return position | ||
91 | |||
92 | def set_cursor_position(self, position=None, on_stderr=False): | ||
93 | if position is None: | ||
94 | # I'm not currently tracking the position, so there is no default. | ||
95 | # position = self.get_position() | ||
96 | return | ||
97 | handle = win32.STDOUT | ||
98 | if on_stderr: | ||
99 | handle = win32.STDERR | ||
100 | win32.SetConsoleCursorPosition(handle, position) | ||
101 | |||
102 | def cursor_adjust(self, x, y, on_stderr=False): | ||
103 | handle = win32.STDOUT | ||
104 | if on_stderr: | ||
105 | handle = win32.STDERR | ||
106 | position = self.get_position(handle) | ||
107 | adjusted_position = (position.Y + y, position.X + x) | ||
108 | win32.SetConsoleCursorPosition(handle, adjusted_position, adjust=False) | ||
109 | |||
110 | def erase_screen(self, mode=0, on_stderr=False): | ||
111 | # 0 should clear from the cursor to the end of the screen. | ||
112 | # 1 should clear from the cursor to the beginning of the screen. | ||
113 | # 2 should clear the entire screen, and move cursor to (1,1) | ||
114 | handle = win32.STDOUT | ||
115 | if on_stderr: | ||
116 | handle = win32.STDERR | ||
117 | csbi = win32.GetConsoleScreenBufferInfo(handle) | ||
118 | # get the number of character cells in the current buffer | ||
119 | cells_in_screen = csbi.dwSize.X * csbi.dwSize.Y | ||
120 | # get number of character cells before current cursor position | ||
121 | cells_before_cursor = csbi.dwSize.X * csbi.dwCursorPosition.Y + csbi.dwCursorPosition.X | ||
122 | if mode == 0: | ||
123 | from_coord = csbi.dwCursorPosition | ||
124 | cells_to_erase = cells_in_screen - cells_before_cursor | ||
125 | if mode == 1: | ||
126 | from_coord = win32.COORD(0, 0) | ||
127 | cells_to_erase = cells_before_cursor | ||
128 | elif mode == 2: | ||
129 | from_coord = win32.COORD(0, 0) | ||
130 | cells_to_erase = cells_in_screen | ||
131 | # fill the entire screen with blanks | ||
132 | win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord) | ||
133 | # now set the buffer's attributes accordingly | ||
134 | win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord) | ||
135 | if mode == 2: | ||
136 | # put the cursor where needed | ||
137 | win32.SetConsoleCursorPosition(handle, (1, 1)) | ||
138 | |||
139 | def erase_line(self, mode=0, on_stderr=False): | ||
140 | # 0 should clear from the cursor to the end of the line. | ||
141 | # 1 should clear from the cursor to the beginning of the line. | ||
142 | # 2 should clear the entire line. | ||
143 | handle = win32.STDOUT | ||
144 | if on_stderr: | ||
145 | handle = win32.STDERR | ||
146 | csbi = win32.GetConsoleScreenBufferInfo(handle) | ||
147 | if mode == 0: | ||
148 | from_coord = csbi.dwCursorPosition | ||
149 | cells_to_erase = csbi.dwSize.X - csbi.dwCursorPosition.X | ||
150 | if mode == 1: | ||
151 | from_coord = win32.COORD(0, csbi.dwCursorPosition.Y) | ||
152 | cells_to_erase = csbi.dwCursorPosition.X | ||
153 | elif mode == 2: | ||
154 | from_coord = win32.COORD(0, csbi.dwCursorPosition.Y) | ||
155 | cells_to_erase = csbi.dwSize.X | ||
156 | # fill the entire screen with blanks | ||
157 | win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord) | ||
158 | # now set the buffer's attributes accordingly | ||
159 | win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord) | ||
160 | |||
161 | def set_title(self, title): | ||
162 | win32.SetConsoleTitle(title) | ||