Datasets:
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .venv/Lib/site-packages/pip-23.2.1.dist-info/AUTHORS.txt +738 -0
- .venv/Lib/site-packages/pip-23.2.1.dist-info/INSTALLER +1 -0
- .venv/Lib/site-packages/pip-23.2.1.dist-info/LICENSE.txt +20 -0
- .venv/Lib/site-packages/pip-23.2.1.dist-info/METADATA +90 -0
- .venv/Lib/site-packages/pip-23.2.1.dist-info/RECORD +1063 -0
- .venv/Lib/site-packages/pip-23.2.1.dist-info/WHEEL +5 -0
- .venv/Lib/site-packages/pip-23.2.1.dist-info/entry_points.txt +4 -0
- .venv/Lib/site-packages/pip-23.2.1.dist-info/top_level.txt +1 -0
- .venv/Lib/site-packages/pip/_vendor/rich/__init__.py +177 -0
- .venv/Lib/site-packages/pip/_vendor/rich/__main__.py +274 -0
- .venv/Lib/site-packages/pip/_vendor/rich/_timer.py +19 -0
- .venv/Lib/site-packages/pip/_vendor/rich/_win32_console.py +662 -0
- .venv/Lib/site-packages/pip/_vendor/rich/_windows.py +72 -0
- .venv/Lib/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
- .venv/Lib/site-packages/pip/_vendor/rich/_wrap.py +56 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/__init__.py +608 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/_asyncio.py +94 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/_utils.py +76 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/after.py +51 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/before.py +46 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/before_sleep.py +71 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/nap.py +43 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/retry.py +272 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/stop.py +103 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/tornadoweb.py +59 -0
- .venv/Lib/site-packages/pip/_vendor/tenacity/wait.py +228 -0
- .venv/Lib/site-packages/pip/_vendor/tomli/__init__.py +11 -0
- .venv/Lib/site-packages/pip/_vendor/tomli/_parser.py +691 -0
- .venv/Lib/site-packages/pip/_vendor/tomli/_re.py +107 -0
- .venv/Lib/site-packages/pip/_vendor/tomli/_types.py +10 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/__init__.py +102 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/_collections.py +337 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/_version.py +2 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/connection.py +572 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py +1132 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +519 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py +130 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +518 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +921 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py +216 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/fields.py +274 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/filepost.py +98 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/packages/__init__.py +0 -0
- .venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
.venv/Lib/site-packages/p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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@Switch01
|
| 2 |
+
A_Rog
|
| 3 |
+
Aakanksha Agrawal
|
| 4 |
+
Abhinav Sagar
|
| 5 |
+
ABHYUDAY PRATAP SINGH
|
| 6 |
+
abs51295
|
| 7 |
+
AceGentile
|
| 8 |
+
Adam Chainz
|
| 9 |
+
Adam Tse
|
| 10 |
+
Adam Wentz
|
| 11 |
+
admin
|
| 12 |
+
Adrien Morison
|
| 13 |
+
ahayrapetyan
|
| 14 |
+
Ahilya
|
| 15 |
+
AinsworthK
|
| 16 |
+
Akash Srivastava
|
| 17 |
+
Alan Yee
|
| 18 |
+
Albert Tugushev
|
| 19 |
+
Albert-Guan
|
| 20 |
+
albertg
|
| 21 |
+
Alberto Sottile
|
| 22 |
+
Aleks Bunin
|
| 23 |
+
Alethea Flowers
|
| 24 |
+
Alex Gaynor
|
| 25 |
+
Alex Grönholm
|
| 26 |
+
Alex Hedges
|
| 27 |
+
Alex Loosley
|
| 28 |
+
Alex Morega
|
| 29 |
+
Alex Stachowiak
|
| 30 |
+
Alexander Shtyrov
|
| 31 |
+
Alexandre Conrad
|
| 32 |
+
Alexey Popravka
|
| 33 |
+
Alli
|
| 34 |
+
Ami Fischman
|
| 35 |
+
Ananya Maiti
|
| 36 |
+
Anatoly Techtonik
|
| 37 |
+
Anders Kaseorg
|
| 38 |
+
Andre Aguiar
|
| 39 |
+
Andreas Lutro
|
| 40 |
+
Andrei Geacar
|
| 41 |
+
Andrew Gaul
|
| 42 |
+
Andrew Shymanel
|
| 43 |
+
Andrey Bienkowski
|
| 44 |
+
Andrey Bulgakov
|
| 45 |
+
Andrés Delfino
|
| 46 |
+
Andy Freeland
|
| 47 |
+
Andy Kluger
|
| 48 |
+
Ani Hayrapetyan
|
| 49 |
+
Aniruddha Basak
|
| 50 |
+
Anish Tambe
|
| 51 |
+
Anrs Hu
|
| 52 |
+
Anthony Sottile
|
| 53 |
+
Antoine Musso
|
| 54 |
+
Anton Ovchinnikov
|
| 55 |
+
Anton Patrushev
|
| 56 |
+
Antonio Alvarado Hernandez
|
| 57 |
+
Antony Lee
|
| 58 |
+
Antti Kaihola
|
| 59 |
+
Anubhav Patel
|
| 60 |
+
Anudit Nagar
|
| 61 |
+
Anuj Godase
|
| 62 |
+
AQNOUCH Mohammed
|
| 63 |
+
AraHaan
|
| 64 |
+
Arindam Choudhury
|
| 65 |
+
Armin Ronacher
|
| 66 |
+
Artem
|
| 67 |
+
Arun Babu Neelicattu
|
| 68 |
+
Ashley Manton
|
| 69 |
+
Ashwin Ramaswami
|
| 70 |
+
atse
|
| 71 |
+
Atsushi Odagiri
|
| 72 |
+
Avinash Karhana
|
| 73 |
+
Avner Cohen
|
| 74 |
+
Awit (Ah-Wit) Ghirmai
|
| 75 |
+
Baptiste Mispelon
|
| 76 |
+
Barney Gale
|
| 77 |
+
barneygale
|
| 78 |
+
Bartek Ogryczak
|
| 79 |
+
Bastian Venthur
|
| 80 |
+
Ben Bodenmiller
|
| 81 |
+
Ben Darnell
|
| 82 |
+
Ben Hoyt
|
| 83 |
+
Ben Mares
|
| 84 |
+
Ben Rosser
|
| 85 |
+
Bence Nagy
|
| 86 |
+
Benjamin Peterson
|
| 87 |
+
Benjamin VanEvery
|
| 88 |
+
Benoit Pierre
|
| 89 |
+
Berker Peksag
|
| 90 |
+
Bernard
|
| 91 |
+
Bernard Tyers
|
| 92 |
+
Bernardo B. Marques
|
| 93 |
+
Bernhard M. Wiedemann
|
| 94 |
+
Bertil Hatt
|
| 95 |
+
Bhavam Vidyarthi
|
| 96 |
+
Blazej Michalik
|
| 97 |
+
Bogdan Opanchuk
|
| 98 |
+
BorisZZZ
|
| 99 |
+
Brad Erickson
|
| 100 |
+
Bradley Ayers
|
| 101 |
+
Brandon L. Reiss
|
| 102 |
+
Brandt Bucher
|
| 103 |
+
Brett Randall
|
| 104 |
+
Brett Rosen
|
| 105 |
+
Brian Cristante
|
| 106 |
+
Brian Rosner
|
| 107 |
+
briantracy
|
| 108 |
+
BrownTruck
|
| 109 |
+
Bruno Oliveira
|
| 110 |
+
Bruno Renié
|
| 111 |
+
Bruno S
|
| 112 |
+
Bstrdsmkr
|
| 113 |
+
Buck Golemon
|
| 114 |
+
burrows
|
| 115 |
+
Bussonnier Matthias
|
| 116 |
+
bwoodsend
|
| 117 |
+
c22
|
| 118 |
+
Caleb Martinez
|
| 119 |
+
Calvin Smith
|
| 120 |
+
Carl Meyer
|
| 121 |
+
Carlos Liam
|
| 122 |
+
Carol Willing
|
| 123 |
+
Carter Thayer
|
| 124 |
+
Cass
|
| 125 |
+
Chandrasekhar Atina
|
| 126 |
+
Chih-Hsuan Yen
|
| 127 |
+
Chris Brinker
|
| 128 |
+
Chris Hunt
|
| 129 |
+
Chris Jerdonek
|
| 130 |
+
Chris Kuehl
|
| 131 |
+
Chris McDonough
|
| 132 |
+
Chris Pawley
|
| 133 |
+
Chris Pryer
|
| 134 |
+
Chris Wolfe
|
| 135 |
+
Christian Clauss
|
| 136 |
+
Christian Heimes
|
| 137 |
+
Christian Oudard
|
| 138 |
+
Christoph Reiter
|
| 139 |
+
Christopher Hunt
|
| 140 |
+
Christopher Snyder
|
| 141 |
+
cjc7373
|
| 142 |
+
Clark Boylan
|
| 143 |
+
Claudio Jolowicz
|
| 144 |
+
Clay McClure
|
| 145 |
+
Cody
|
| 146 |
+
Cody Soyland
|
| 147 |
+
Colin Watson
|
| 148 |
+
Collin Anderson
|
| 149 |
+
Connor Osborn
|
| 150 |
+
Cooper Lees
|
| 151 |
+
Cooper Ry Lees
|
| 152 |
+
Cory Benfield
|
| 153 |
+
Cory Wright
|
| 154 |
+
Craig Kerstiens
|
| 155 |
+
Cristian Sorinel
|
| 156 |
+
Cristina
|
| 157 |
+
Cristina Muñoz
|
| 158 |
+
Curtis Doty
|
| 159 |
+
cytolentino
|
| 160 |
+
Daan De Meyer
|
| 161 |
+
Damian
|
| 162 |
+
Damian Quiroga
|
| 163 |
+
Damian Shaw
|
| 164 |
+
Dan Black
|
| 165 |
+
Dan Savilonis
|
| 166 |
+
Dan Sully
|
| 167 |
+
Dane Hillard
|
| 168 |
+
daniel
|
| 169 |
+
Daniel Collins
|
| 170 |
+
Daniel Hahler
|
| 171 |
+
Daniel Holth
|
| 172 |
+
Daniel Jost
|
| 173 |
+
Daniel Katz
|
| 174 |
+
Daniel Shaulov
|
| 175 |
+
Daniele Esposti
|
| 176 |
+
Daniele Nicolodi
|
| 177 |
+
Daniele Procida
|
| 178 |
+
Daniil Konovalenko
|
| 179 |
+
Danny Hermes
|
| 180 |
+
Danny McClanahan
|
| 181 |
+
Darren Kavanagh
|
| 182 |
+
Dav Clark
|
| 183 |
+
Dave Abrahams
|
| 184 |
+
Dave Jones
|
| 185 |
+
David Aguilar
|
| 186 |
+
David Black
|
| 187 |
+
David Bordeynik
|
| 188 |
+
David Caro
|
| 189 |
+
David D Lowe
|
| 190 |
+
David Evans
|
| 191 |
+
David Hewitt
|
| 192 |
+
David Linke
|
| 193 |
+
David Poggi
|
| 194 |
+
David Pursehouse
|
| 195 |
+
David Runge
|
| 196 |
+
David Tucker
|
| 197 |
+
David Wales
|
| 198 |
+
Davidovich
|
| 199 |
+
Deepak Sharma
|
| 200 |
+
Deepyaman Datta
|
| 201 |
+
Denise Yu
|
| 202 |
+
derwolfe
|
| 203 |
+
Desetude
|
| 204 |
+
Devesh Kumar Singh
|
| 205 |
+
Diego Caraballo
|
| 206 |
+
Diego Ramirez
|
| 207 |
+
DiegoCaraballo
|
| 208 |
+
Dimitri Merejkowsky
|
| 209 |
+
Dimitri Papadopoulos
|
| 210 |
+
Dirk Stolle
|
| 211 |
+
Dmitry Gladkov
|
| 212 |
+
Dmitry Volodin
|
| 213 |
+
Domen Kožar
|
| 214 |
+
Dominic Davis-Foster
|
| 215 |
+
Donald Stufft
|
| 216 |
+
Dongweiming
|
| 217 |
+
doron zarhi
|
| 218 |
+
Dos Moonen
|
| 219 |
+
Douglas Thor
|
| 220 |
+
DrFeathers
|
| 221 |
+
Dustin Ingram
|
| 222 |
+
Dwayne Bailey
|
| 223 |
+
Ed Morley
|
| 224 |
+
Edgar Ramírez
|
| 225 |
+
Ee Durbin
|
| 226 |
+
Eitan Adler
|
| 227 |
+
ekristina
|
| 228 |
+
elainechan
|
| 229 |
+
Eli Schwartz
|
| 230 |
+
Elisha Hollander
|
| 231 |
+
Ellen Marie Dash
|
| 232 |
+
Emil Burzo
|
| 233 |
+
Emil Styrke
|
| 234 |
+
Emmanuel Arias
|
| 235 |
+
Endoh Takanao
|
| 236 |
+
enoch
|
| 237 |
+
Erdinc Mutlu
|
| 238 |
+
Eric Cousineau
|
| 239 |
+
Eric Gillingham
|
| 240 |
+
Eric Hanchrow
|
| 241 |
+
Eric Hopper
|
| 242 |
+
Erik M. Bray
|
| 243 |
+
Erik Rose
|
| 244 |
+
Erwin Janssen
|
| 245 |
+
Eugene Vereshchagin
|
| 246 |
+
everdimension
|
| 247 |
+
Federico
|
| 248 |
+
Felipe Peter
|
| 249 |
+
Felix Yan
|
| 250 |
+
fiber-space
|
| 251 |
+
Filip Kokosiński
|
| 252 |
+
Filipe Laíns
|
| 253 |
+
Finn Womack
|
| 254 |
+
finnagin
|
| 255 |
+
Florian Briand
|
| 256 |
+
Florian Rathgeber
|
| 257 |
+
Francesco
|
| 258 |
+
Francesco Montesano
|
| 259 |
+
Frost Ming
|
| 260 |
+
Gabriel Curio
|
| 261 |
+
Gabriel de Perthuis
|
| 262 |
+
Garry Polley
|
| 263 |
+
gavin
|
| 264 |
+
gdanielson
|
| 265 |
+
Geoffrey Sneddon
|
| 266 |
+
George Song
|
| 267 |
+
Georgi Valkov
|
| 268 |
+
Georgy Pchelkin
|
| 269 |
+
ghost
|
| 270 |
+
Giftlin Rajaiah
|
| 271 |
+
gizmoguy1
|
| 272 |
+
gkdoc
|
| 273 |
+
Godefroid Chapelle
|
| 274 |
+
Gopinath M
|
| 275 |
+
GOTO Hayato
|
| 276 |
+
gousaiyang
|
| 277 |
+
gpiks
|
| 278 |
+
Greg Roodt
|
| 279 |
+
Greg Ward
|
| 280 |
+
Guilherme Espada
|
| 281 |
+
Guillaume Seguin
|
| 282 |
+
gutsytechster
|
| 283 |
+
Guy Rozendorn
|
| 284 |
+
Guy Tuval
|
| 285 |
+
gzpan123
|
| 286 |
+
Hanjun Kim
|
| 287 |
+
Hari Charan
|
| 288 |
+
Harsh Vardhan
|
| 289 |
+
harupy
|
| 290 |
+
Harutaka Kawamura
|
| 291 |
+
hauntsaninja
|
| 292 |
+
Henrich Hartzer
|
| 293 |
+
Henry Schreiner
|
| 294 |
+
Herbert Pfennig
|
| 295 |
+
Holly Stotelmyer
|
| 296 |
+
Honnix
|
| 297 |
+
Hsiaoming Yang
|
| 298 |
+
Hugo Lopes Tavares
|
| 299 |
+
Hugo van Kemenade
|
| 300 |
+
Hugues Bruant
|
| 301 |
+
Hynek Schlawack
|
| 302 |
+
Ian Bicking
|
| 303 |
+
Ian Cordasco
|
| 304 |
+
Ian Lee
|
| 305 |
+
Ian Stapleton Cordasco
|
| 306 |
+
Ian Wienand
|
| 307 |
+
Igor Kuzmitshov
|
| 308 |
+
Igor Sobreira
|
| 309 |
+
Ilan Schnell
|
| 310 |
+
Illia Volochii
|
| 311 |
+
Ilya Baryshev
|
| 312 |
+
Inada Naoki
|
| 313 |
+
Ionel Cristian Mărieș
|
| 314 |
+
Ionel Maries Cristian
|
| 315 |
+
Ivan Pozdeev
|
| 316 |
+
Jacob Kim
|
| 317 |
+
Jacob Walls
|
| 318 |
+
Jaime Sanz
|
| 319 |
+
jakirkham
|
| 320 |
+
Jakub Kuczys
|
| 321 |
+
Jakub Stasiak
|
| 322 |
+
Jakub Vysoky
|
| 323 |
+
Jakub Wilk
|
| 324 |
+
James Cleveland
|
| 325 |
+
James Curtin
|
| 326 |
+
James Firth
|
| 327 |
+
James Gerity
|
| 328 |
+
James Polley
|
| 329 |
+
Jan Pokorný
|
| 330 |
+
Jannis Leidel
|
| 331 |
+
Jarek Potiuk
|
| 332 |
+
jarondl
|
| 333 |
+
Jason Curtis
|
| 334 |
+
Jason R. Coombs
|
| 335 |
+
JasonMo
|
| 336 |
+
JasonMo1
|
| 337 |
+
Jay Graves
|
| 338 |
+
Jean-Christophe Fillion-Robin
|
| 339 |
+
Jeff Barber
|
| 340 |
+
Jeff Dairiki
|
| 341 |
+
Jelmer Vernooij
|
| 342 |
+
jenix21
|
| 343 |
+
Jeremy Stanley
|
| 344 |
+
Jeremy Zafran
|
| 345 |
+
Jesse Rittner
|
| 346 |
+
Jiashuo Li
|
| 347 |
+
Jim Fisher
|
| 348 |
+
Jim Garrison
|
| 349 |
+
Jiun Bae
|
| 350 |
+
Jivan Amara
|
| 351 |
+
Joe Bylund
|
| 352 |
+
Joe Michelini
|
| 353 |
+
John Paton
|
| 354 |
+
John T. Wodder II
|
| 355 |
+
John-Scott Atlakson
|
| 356 |
+
johnthagen
|
| 357 |
+
Jon Banafato
|
| 358 |
+
Jon Dufresne
|
| 359 |
+
Jon Parise
|
| 360 |
+
Jonas Nockert
|
| 361 |
+
Jonathan Herbert
|
| 362 |
+
Joonatan Partanen
|
| 363 |
+
Joost Molenaar
|
| 364 |
+
Jorge Niedbalski
|
| 365 |
+
Joseph Bylund
|
| 366 |
+
Joseph Long
|
| 367 |
+
Josh Bronson
|
| 368 |
+
Josh Hansen
|
| 369 |
+
Josh Schneier
|
| 370 |
+
Juan Luis Cano Rodríguez
|
| 371 |
+
Juanjo Bazán
|
| 372 |
+
Judah Rand
|
| 373 |
+
Julian Berman
|
| 374 |
+
Julian Gethmann
|
| 375 |
+
Julien Demoor
|
| 376 |
+
Jussi Kukkonen
|
| 377 |
+
jwg4
|
| 378 |
+
Jyrki Pulliainen
|
| 379 |
+
Kai Chen
|
| 380 |
+
Kai Mueller
|
| 381 |
+
Kamal Bin Mustafa
|
| 382 |
+
kasium
|
| 383 |
+
kaustav haldar
|
| 384 |
+
keanemind
|
| 385 |
+
Keith Maxwell
|
| 386 |
+
Kelsey Hightower
|
| 387 |
+
Kenneth Belitzky
|
| 388 |
+
Kenneth Reitz
|
| 389 |
+
Kevin Burke
|
| 390 |
+
Kevin Carter
|
| 391 |
+
Kevin Frommelt
|
| 392 |
+
Kevin R Patterson
|
| 393 |
+
Kexuan Sun
|
| 394 |
+
Kit Randel
|
| 395 |
+
Klaas van Schelven
|
| 396 |
+
KOLANICH
|
| 397 |
+
kpinc
|
| 398 |
+
Krishna Oza
|
| 399 |
+
Kumar McMillan
|
| 400 |
+
Kyle Persohn
|
| 401 |
+
lakshmanaram
|
| 402 |
+
Laszlo Kiss-Kollar
|
| 403 |
+
Laurent Bristiel
|
| 404 |
+
Laurent LAPORTE
|
| 405 |
+
Laurie O
|
| 406 |
+
Laurie Opperman
|
| 407 |
+
layday
|
| 408 |
+
Leon Sasson
|
| 409 |
+
Lev Givon
|
| 410 |
+
Lincoln de Sousa
|
| 411 |
+
Lipis
|
| 412 |
+
lorddavidiii
|
| 413 |
+
Loren Carvalho
|
| 414 |
+
Lucas Cimon
|
| 415 |
+
Ludovic Gasc
|
| 416 |
+
Lukas Juhrich
|
| 417 |
+
Luke Macken
|
| 418 |
+
Luo Jiebin
|
| 419 |
+
luojiebin
|
| 420 |
+
luz.paz
|
| 421 |
+
László Kiss Kollár
|
| 422 |
+
M00nL1ght
|
| 423 |
+
Marc Abramowitz
|
| 424 |
+
Marc Tamlyn
|
| 425 |
+
Marcus Smith
|
| 426 |
+
Mariatta
|
| 427 |
+
Mark Kohler
|
| 428 |
+
Mark Williams
|
| 429 |
+
Markus Hametner
|
| 430 |
+
Martey Dodoo
|
| 431 |
+
Martin Fischer
|
| 432 |
+
Martin Häcker
|
| 433 |
+
Martin Pavlasek
|
| 434 |
+
Masaki
|
| 435 |
+
Masklinn
|
| 436 |
+
Matej Stuchlik
|
| 437 |
+
Mathew Jennings
|
| 438 |
+
Mathieu Bridon
|
| 439 |
+
Mathieu Kniewallner
|
| 440 |
+
Matt Bacchi
|
| 441 |
+
Matt Good
|
| 442 |
+
Matt Maker
|
| 443 |
+
Matt Robenolt
|
| 444 |
+
matthew
|
| 445 |
+
Matthew Einhorn
|
| 446 |
+
Matthew Feickert
|
| 447 |
+
Matthew Gilliard
|
| 448 |
+
Matthew Iversen
|
| 449 |
+
Matthew Treinish
|
| 450 |
+
Matthew Trumbell
|
| 451 |
+
Matthew Willson
|
| 452 |
+
Matthias Bussonnier
|
| 453 |
+
mattip
|
| 454 |
+
Maurits van Rees
|
| 455 |
+
Max W Chase
|
| 456 |
+
Maxim Kurnikov
|
| 457 |
+
Maxime Rouyrre
|
| 458 |
+
mayeut
|
| 459 |
+
mbaluna
|
| 460 |
+
mdebi
|
| 461 |
+
memoselyk
|
| 462 |
+
meowmeowcat
|
| 463 |
+
Michael
|
| 464 |
+
Michael Aquilina
|
| 465 |
+
Michael E. Karpeles
|
| 466 |
+
Michael Klich
|
| 467 |
+
Michael Mintz
|
| 468 |
+
Michael Williamson
|
| 469 |
+
michaelpacer
|
| 470 |
+
Michał Górny
|
| 471 |
+
Mickaël Schoentgen
|
| 472 |
+
Miguel Araujo Perez
|
| 473 |
+
Mihir Singh
|
| 474 |
+
Mike
|
| 475 |
+
Mike Hendricks
|
| 476 |
+
Min RK
|
| 477 |
+
MinRK
|
| 478 |
+
Miro Hrončok
|
| 479 |
+
Monica Baluna
|
| 480 |
+
montefra
|
| 481 |
+
Monty Taylor
|
| 482 |
+
Muha Ajjan
|
| 483 |
+
Nadav Wexler
|
| 484 |
+
Nahuel Ambrosini
|
| 485 |
+
Nate Coraor
|
| 486 |
+
Nate Prewitt
|
| 487 |
+
Nathan Houghton
|
| 488 |
+
Nathaniel J. Smith
|
| 489 |
+
Nehal J Wani
|
| 490 |
+
Neil Botelho
|
| 491 |
+
Nguyễn Gia Phong
|
| 492 |
+
Nicholas Serra
|
| 493 |
+
Nick Coghlan
|
| 494 |
+
Nick Stenning
|
| 495 |
+
Nick Timkovich
|
| 496 |
+
Nicolas Bock
|
| 497 |
+
Nicole Harris
|
| 498 |
+
Nikhil Benesch
|
| 499 |
+
Nikhil Ladha
|
| 500 |
+
Nikita Chepanov
|
| 501 |
+
Nikolay Korolev
|
| 502 |
+
Nipunn Koorapati
|
| 503 |
+
Nitesh Sharma
|
| 504 |
+
Niyas Sait
|
| 505 |
+
Noah
|
| 506 |
+
Noah Gorny
|
| 507 |
+
Nowell Strite
|
| 508 |
+
NtaleGrey
|
| 509 |
+
nvdv
|
| 510 |
+
OBITORASU
|
| 511 |
+
Ofek Lev
|
| 512 |
+
ofrinevo
|
| 513 |
+
Oliver Freund
|
| 514 |
+
Oliver Jeeves
|
| 515 |
+
Oliver Mannion
|
| 516 |
+
Oliver Tonnhofer
|
| 517 |
+
Olivier Girardot
|
| 518 |
+
Olivier Grisel
|
| 519 |
+
Ollie Rutherfurd
|
| 520 |
+
OMOTO Kenji
|
| 521 |
+
Omry Yadan
|
| 522 |
+
onlinejudge95
|
| 523 |
+
Oren Held
|
| 524 |
+
Oscar Benjamin
|
| 525 |
+
Oz N Tiram
|
| 526 |
+
Pachwenko
|
| 527 |
+
Patrick Dubroy
|
| 528 |
+
Patrick Jenkins
|
| 529 |
+
Patrick Lawson
|
| 530 |
+
patricktokeeffe
|
| 531 |
+
Patrik Kopkan
|
| 532 |
+
Paul Kehrer
|
| 533 |
+
Paul Moore
|
| 534 |
+
Paul Nasrat
|
| 535 |
+
Paul Oswald
|
| 536 |
+
Paul van der Linden
|
| 537 |
+
Paulus Schoutsen
|
| 538 |
+
Pavel Safronov
|
| 539 |
+
Pavithra Eswaramoorthy
|
| 540 |
+
Pawel Jasinski
|
| 541 |
+
Paweł Szramowski
|
| 542 |
+
Pekka Klärck
|
| 543 |
+
Peter Gessler
|
| 544 |
+
Peter Lisák
|
| 545 |
+
Peter Waller
|
| 546 |
+
petr-tik
|
| 547 |
+
Phaneendra Chiruvella
|
| 548 |
+
Phil Elson
|
| 549 |
+
Phil Freo
|
| 550 |
+
Phil Pennock
|
| 551 |
+
Phil Whelan
|
| 552 |
+
Philip Jägenstedt
|
| 553 |
+
Philip Molloy
|
| 554 |
+
Philippe Ombredanne
|
| 555 |
+
Pi Delport
|
| 556 |
+
Pierre-Yves Rofes
|
| 557 |
+
Pieter Degroote
|
| 558 |
+
pip
|
| 559 |
+
Prabakaran Kumaresshan
|
| 560 |
+
Prabhjyotsing Surjit Singh Sodhi
|
| 561 |
+
Prabhu Marappan
|
| 562 |
+
Pradyun Gedam
|
| 563 |
+
Prashant Sharma
|
| 564 |
+
Pratik Mallya
|
| 565 |
+
pre-commit-ci[bot]
|
| 566 |
+
Preet Thakkar
|
| 567 |
+
Preston Holmes
|
| 568 |
+
Przemek Wrzos
|
| 569 |
+
Pulkit Goyal
|
| 570 |
+
q0w
|
| 571 |
+
Qiangning Hong
|
| 572 |
+
Quentin Lee
|
| 573 |
+
Quentin Pradet
|
| 574 |
+
R. David Murray
|
| 575 |
+
Rafael Caricio
|
| 576 |
+
Ralf Schmitt
|
| 577 |
+
Razzi Abuissa
|
| 578 |
+
rdb
|
| 579 |
+
Reece Dunham
|
| 580 |
+
Remi Rampin
|
| 581 |
+
Rene Dudfield
|
| 582 |
+
Riccardo Magliocchetti
|
| 583 |
+
Riccardo Schirone
|
| 584 |
+
Richard Jones
|
| 585 |
+
Richard Si
|
| 586 |
+
Ricky Ng-Adam
|
| 587 |
+
Rishi
|
| 588 |
+
RobberPhex
|
| 589 |
+
Robert Collins
|
| 590 |
+
Robert McGibbon
|
| 591 |
+
Robert Pollak
|
| 592 |
+
Robert T. McGibbon
|
| 593 |
+
robin elisha robinson
|
| 594 |
+
Roey Berman
|
| 595 |
+
Rohan Jain
|
| 596 |
+
Roman Bogorodskiy
|
| 597 |
+
Roman Donchenko
|
| 598 |
+
Romuald Brunet
|
| 599 |
+
ronaudinho
|
| 600 |
+
Ronny Pfannschmidt
|
| 601 |
+
Rory McCann
|
| 602 |
+
Ross Brattain
|
| 603 |
+
Roy Wellington Ⅳ
|
| 604 |
+
Ruairidh MacLeod
|
| 605 |
+
Russell Keith-Magee
|
| 606 |
+
Ryan Shepherd
|
| 607 |
+
Ryan Wooden
|
| 608 |
+
ryneeverett
|
| 609 |
+
Sachi King
|
| 610 |
+
Salvatore Rinchiera
|
| 611 |
+
sandeepkiran-js
|
| 612 |
+
Savio Jomton
|
| 613 |
+
schlamar
|
| 614 |
+
Scott Kitterman
|
| 615 |
+
Sean
|
| 616 |
+
seanj
|
| 617 |
+
Sebastian Jordan
|
| 618 |
+
Sebastian Schaetz
|
| 619 |
+
Segev Finer
|
| 620 |
+
SeongSoo Cho
|
| 621 |
+
Sergey Vasilyev
|
| 622 |
+
Seth Michael Larson
|
| 623 |
+
Seth Woodworth
|
| 624 |
+
Shantanu
|
| 625 |
+
shireenrao
|
| 626 |
+
Shivansh-007
|
| 627 |
+
Shlomi Fish
|
| 628 |
+
Shovan Maity
|
| 629 |
+
Simeon Visser
|
| 630 |
+
Simon Cross
|
| 631 |
+
Simon Pichugin
|
| 632 |
+
sinoroc
|
| 633 |
+
sinscary
|
| 634 |
+
snook92
|
| 635 |
+
socketubs
|
| 636 |
+
Sorin Sbarnea
|
| 637 |
+
Srinivas Nyayapati
|
| 638 |
+
Stavros Korokithakis
|
| 639 |
+
Stefan Scherfke
|
| 640 |
+
Stefano Rivera
|
| 641 |
+
Stephan Erb
|
| 642 |
+
Stephen Rosen
|
| 643 |
+
stepshal
|
| 644 |
+
Steve (Gadget) Barnes
|
| 645 |
+
Steve Barnes
|
| 646 |
+
Steve Dower
|
| 647 |
+
Steve Kowalik
|
| 648 |
+
Steven Myint
|
| 649 |
+
Steven Silvester
|
| 650 |
+
stonebig
|
| 651 |
+
Stéphane Bidoul
|
| 652 |
+
Stéphane Bidoul (ACSONE)
|
| 653 |
+
Stéphane Klein
|
| 654 |
+
Sumana Harihareswara
|
| 655 |
+
Surbhi Sharma
|
| 656 |
+
Sviatoslav Sydorenko
|
| 657 |
+
Swat009
|
| 658 |
+
Sylvain
|
| 659 |
+
Takayuki SHIMIZUKAWA
|
| 660 |
+
Taneli Hukkinen
|
| 661 |
+
tbeswick
|
| 662 |
+
Thiago
|
| 663 |
+
Thijs Triemstra
|
| 664 |
+
Thomas Fenzl
|
| 665 |
+
Thomas Grainger
|
| 666 |
+
Thomas Guettler
|
| 667 |
+
Thomas Johansson
|
| 668 |
+
Thomas Kluyver
|
| 669 |
+
Thomas Smith
|
| 670 |
+
Thomas VINCENT
|
| 671 |
+
Tim D. Smith
|
| 672 |
+
Tim Gates
|
| 673 |
+
Tim Harder
|
| 674 |
+
Tim Heap
|
| 675 |
+
tim smith
|
| 676 |
+
tinruufu
|
| 677 |
+
Tobias Hermann
|
| 678 |
+
Tom Forbes
|
| 679 |
+
Tom Freudenheim
|
| 680 |
+
Tom V
|
| 681 |
+
Tomas Hrnciar
|
| 682 |
+
Tomas Orsava
|
| 683 |
+
Tomer Chachamu
|
| 684 |
+
Tommi Enenkel | AnB
|
| 685 |
+
Tomáš Hrnčiar
|
| 686 |
+
Tony Beswick
|
| 687 |
+
Tony Narlock
|
| 688 |
+
Tony Zhaocheng Tan
|
| 689 |
+
TonyBeswick
|
| 690 |
+
toonarmycaptain
|
| 691 |
+
Toshio Kuratomi
|
| 692 |
+
toxinu
|
| 693 |
+
Travis Swicegood
|
| 694 |
+
Tushar Sadhwani
|
| 695 |
+
Tzu-ping Chung
|
| 696 |
+
Valentin Haenel
|
| 697 |
+
Victor Stinner
|
| 698 |
+
victorvpaulo
|
| 699 |
+
Vikram - Google
|
| 700 |
+
Viktor Szépe
|
| 701 |
+
Ville Skyttä
|
| 702 |
+
Vinay Sajip
|
| 703 |
+
Vincent Philippon
|
| 704 |
+
Vinicyus Macedo
|
| 705 |
+
Vipul Kumar
|
| 706 |
+
Vitaly Babiy
|
| 707 |
+
Vladimir Rutsky
|
| 708 |
+
W. Trevor King
|
| 709 |
+
Wil Tan
|
| 710 |
+
Wilfred Hughes
|
| 711 |
+
William Edwards
|
| 712 |
+
William ML Leslie
|
| 713 |
+
William T Olson
|
| 714 |
+
William Woodruff
|
| 715 |
+
Wilson Mo
|
| 716 |
+
wim glenn
|
| 717 |
+
Winson Luk
|
| 718 |
+
Wolfgang Maier
|
| 719 |
+
Wu Zhenyu
|
| 720 |
+
XAMES3
|
| 721 |
+
Xavier Fernandez
|
| 722 |
+
xoviat
|
| 723 |
+
xtreak
|
| 724 |
+
YAMAMOTO Takashi
|
| 725 |
+
Yen Chi Hsuan
|
| 726 |
+
Yeray Diaz Diaz
|
| 727 |
+
Yoval P
|
| 728 |
+
Yu Jian
|
| 729 |
+
Yuan Jing Vincent Yan
|
| 730 |
+
Yusuke Hayashi
|
| 731 |
+
Zearin
|
| 732 |
+
Zhiping Deng
|
| 733 |
+
ziebam
|
| 734 |
+
Zvezdan Petkovic
|
| 735 |
+
Łukasz Langa
|
| 736 |
+
Роман Донченко
|
| 737 |
+
Семён Марьясин
|
| 738 |
+
rekcäH nitraM
|
.venv/Lib/site-packages/pip-23.2.1.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/Lib/site-packages/pip-23.2.1.dist-info/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2008-present The pip developers (see AUTHORS.txt file)
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 4 |
+
a copy of this software and associated documentation files (the
|
| 5 |
+
"Software"), to deal in the Software without restriction, including
|
| 6 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 7 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 8 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 9 |
+
the following conditions:
|
| 10 |
+
|
| 11 |
+
The above copyright notice and this permission notice shall be
|
| 12 |
+
included in all copies or substantial portions of the Software.
|
| 13 |
+
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 15 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 16 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 17 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 18 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 19 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 20 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
.venv/Lib/site-packages/pip-23.2.1.dist-info/METADATA
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: pip
|
| 3 |
+
Version: 23.2.1
|
| 4 |
+
Summary: The PyPA recommended tool for installing Python packages.
|
| 5 |
+
Home-page: https://pip.pypa.io/
|
| 6 |
+
Author: The pip developers
|
| 7 |
+
Author-email: distutils-sig@python.org
|
| 8 |
+
License: MIT
|
| 9 |
+
Project-URL: Documentation, https://pip.pypa.io
|
| 10 |
+
Project-URL: Source, https://github.com/pypa/pip
|
| 11 |
+
Project-URL: Changelog, https://pip.pypa.io/en/stable/news/
|
| 12 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 13 |
+
Classifier: Intended Audience :: Developers
|
| 14 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 15 |
+
Classifier: Topic :: Software Development :: Build Tools
|
| 16 |
+
Classifier: Programming Language :: Python
|
| 17 |
+
Classifier: Programming Language :: Python :: 3
|
| 18 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 25 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 26 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 27 |
+
Requires-Python: >=3.7
|
| 28 |
+
License-File: LICENSE.txt
|
| 29 |
+
License-File: AUTHORS.txt
|
| 30 |
+
|
| 31 |
+
pip - The Python Package Installer
|
| 32 |
+
==================================
|
| 33 |
+
|
| 34 |
+
.. image:: https://img.shields.io/pypi/v/pip.svg
|
| 35 |
+
:target: https://pypi.org/project/pip/
|
| 36 |
+
|
| 37 |
+
.. image:: https://readthedocs.org/projects/pip/badge/?version=latest
|
| 38 |
+
:target: https://pip.pypa.io/en/latest
|
| 39 |
+
|
| 40 |
+
pip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.
|
| 41 |
+
|
| 42 |
+
Please take a look at our documentation for how to install and use pip:
|
| 43 |
+
|
| 44 |
+
* `Installation`_
|
| 45 |
+
* `Usage`_
|
| 46 |
+
|
| 47 |
+
We release updates regularly, with a new version every 3 months. Find more details in our documentation:
|
| 48 |
+
|
| 49 |
+
* `Release notes`_
|
| 50 |
+
* `Release process`_
|
| 51 |
+
|
| 52 |
+
In pip 20.3, we've `made a big improvement to the heart of pip`_; `learn more`_. We want your input, so `sign up for our user experience research studies`_ to help us do it right.
|
| 53 |
+
|
| 54 |
+
**Note**: pip 21.0, in January 2021, removed Python 2 support, per pip's `Python 2 support policy`_. Please migrate to Python 3.
|
| 55 |
+
|
| 56 |
+
If you find bugs, need help, or want to talk to the developers, please use our mailing lists or chat rooms:
|
| 57 |
+
|
| 58 |
+
* `Issue tracking`_
|
| 59 |
+
* `Discourse channel`_
|
| 60 |
+
* `User IRC`_
|
| 61 |
+
|
| 62 |
+
If you want to get involved head over to GitHub to get the source code, look at our development documentation and feel free to jump on the developer mailing lists and chat rooms:
|
| 63 |
+
|
| 64 |
+
* `GitHub page`_
|
| 65 |
+
* `Development documentation`_
|
| 66 |
+
* `Development IRC`_
|
| 67 |
+
|
| 68 |
+
Code of Conduct
|
| 69 |
+
---------------
|
| 70 |
+
|
| 71 |
+
Everyone interacting in the pip project's codebases, issue trackers, chat
|
| 72 |
+
rooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.
|
| 73 |
+
|
| 74 |
+
.. _package installer: https://packaging.python.org/guides/tool-recommendations/
|
| 75 |
+
.. _Python Package Index: https://pypi.org
|
| 76 |
+
.. _Installation: https://pip.pypa.io/en/stable/installation/
|
| 77 |
+
.. _Usage: https://pip.pypa.io/en/stable/
|
| 78 |
+
.. _Release notes: https://pip.pypa.io/en/stable/news.html
|
| 79 |
+
.. _Release process: https://pip.pypa.io/en/latest/development/release-process/
|
| 80 |
+
.. _GitHub page: https://github.com/pypa/pip
|
| 81 |
+
.. _Development documentation: https://pip.pypa.io/en/latest/development
|
| 82 |
+
.. _made a big improvement to the heart of pip: https://pyfound.blogspot.com/2020/11/pip-20-3-new-resolver.html
|
| 83 |
+
.. _learn more: https://pip.pypa.io/en/latest/user_guide/#changes-to-the-pip-dependency-resolver-in-20-3-2020
|
| 84 |
+
.. _sign up for our user experience research studies: https://pyfound.blogspot.com/2020/03/new-pip-resolver-to-roll-out-this-year.html
|
| 85 |
+
.. _Python 2 support policy: https://pip.pypa.io/en/latest/development/release-process/#python-2-support
|
| 86 |
+
.. _Issue tracking: https://github.com/pypa/pip/issues
|
| 87 |
+
.. _Discourse channel: https://discuss.python.org/c/packaging
|
| 88 |
+
.. _User IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa
|
| 89 |
+
.. _Development IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa-dev
|
| 90 |
+
.. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
|
.venv/Lib/site-packages/pip-23.2.1.dist-info/RECORD
ADDED
|
@@ -0,0 +1,1063 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pip/__init__.py,sha256=hELWH3UN2ilBntczbn1BJOIzJEoiE8w9H-gsR5TeuEk,357
|
| 2 |
+
pip/__main__.py,sha256=WzbhHXTbSE6gBY19mNN9m4s5o_365LOvTYSgqgbdBhE,854
|
| 3 |
+
pip/__pip-runner__.py,sha256=EnrfKmKMzWAdqg_JicLCOP9Y95Ux7zHh4ObvqLtQcjo,1444
|
| 4 |
+
pip/py.typed,sha256=EBVvvPRTn_eIpz5e5QztSCdrMX7Qwd7VP93RSoIlZ2I,286
|
| 5 |
+
pip/_internal/__init__.py,sha256=nnFCuxrPMgALrIDxSoy-H6Zj4W4UY60D-uL1aJyq0pc,573
|
| 6 |
+
pip/_internal/build_env.py,sha256=1ESpqw0iupS_K7phZK5zshVE5Czy9BtGLFU4W6Enva8,10243
|
| 7 |
+
pip/_internal/cache.py,sha256=pMyi1n2nfdo7xzLVhmdOvIy1INt27HbqhJNj7vMcWlI,10429
|
| 8 |
+
pip/_internal/configuration.py,sha256=i_dePJKndPAy7hf48Sl6ZuPyl3tFPCE67z0SNatwuwE,13839
|
| 9 |
+
pip/_internal/exceptions.py,sha256=LyTVY2dANx-i_TEk5Yr9YcwUtiy0HOEFCAQq1F_46co,23737
|
| 10 |
+
pip/_internal/main.py,sha256=r-UnUe8HLo5XFJz8inTcOOTiu_sxNhgHb6VwlGUllOI,340
|
| 11 |
+
pip/_internal/pyproject.py,sha256=ltmrXWaMXjiJHbYyzWplTdBvPYPdKk99GjKuQVypGZU,7161
|
| 12 |
+
pip/_internal/self_outdated_check.py,sha256=pnqBuKKZQ8OxKP0MaUUiDHl3AtyoMJHHG4rMQ7YcYXY,8167
|
| 13 |
+
pip/_internal/wheel_builder.py,sha256=3UlHfxQi7_AAXI7ur8aPpPbmqHhecCsubmkHEl-00KU,11842
|
| 14 |
+
pip/_internal/cli/__init__.py,sha256=FkHBgpxxb-_gd6r1FjnNhfMOzAUYyXoXKJ6abijfcFU,132
|
| 15 |
+
pip/_internal/cli/autocompletion.py,sha256=wY2JPZY2Eji1vhR7bVo-yCBPJ9LCy6P80iOAhZD1Vi8,6676
|
| 16 |
+
pip/_internal/cli/base_command.py,sha256=ACUUqWkZMU2O1pmUSpfBV3fwb36JzzTHGrbKXyb5f74,8726
|
| 17 |
+
pip/_internal/cli/cmdoptions.py,sha256=0bXhKutppZLBgAL54iK3tTrj-JRVbUB5M_2pHv_wnKk,30030
|
| 18 |
+
pip/_internal/cli/command_context.py,sha256=RHgIPwtObh5KhMrd3YZTkl8zbVG-6Okml7YbFX4Ehg0,774
|
| 19 |
+
pip/_internal/cli/main.py,sha256=Uzxt_YD1hIvB1AW5mxt6IVcht5G712AtMqdo51UMhmQ,2816
|
| 20 |
+
pip/_internal/cli/main_parser.py,sha256=laDpsuBDl6kyfywp9eMMA9s84jfH2TJJn-vmL0GG90w,4338
|
| 21 |
+
pip/_internal/cli/parser.py,sha256=tWP-K1uSxnJyXu3WE0kkH3niAYRBeuUaxeydhzOdhL4,10817
|
| 22 |
+
pip/_internal/cli/progress_bars.py,sha256=So4mPoSjXkXiSHiTzzquH3VVyVD_njXlHJSExYPXAow,1968
|
| 23 |
+
pip/_internal/cli/req_command.py,sha256=GqS9jkeHktOy6zRzC6uhcRY7SelnAV1LZ6OfS_gNcEk,18440
|
| 24 |
+
pip/_internal/cli/spinners.py,sha256=hIJ83GerdFgFCdobIA23Jggetegl_uC4Sp586nzFbPE,5118
|
| 25 |
+
pip/_internal/cli/status_codes.py,sha256=sEFHUaUJbqv8iArL3HAtcztWZmGOFX01hTesSytDEh0,116
|
| 26 |
+
pip/_internal/commands/__init__.py,sha256=5oRO9O3dM2vGuh0bFw4HOVletryrz5HHMmmPWwJrH9U,3882
|
| 27 |
+
pip/_internal/commands/cache.py,sha256=aDR3pKRRX9dHobQ2HzKryf02jgOZnGcnfEmX_288Vcg,7581
|
| 28 |
+
pip/_internal/commands/check.py,sha256=Rb13Q28yoLh0j1gpx5SU0jlResNct21eQCRsnaO9xKA,1782
|
| 29 |
+
pip/_internal/commands/completion.py,sha256=2frgchce-GE5Gh9SjEJV-MTcpxy3G9-Es8mpe66nHts,3986
|
| 30 |
+
pip/_internal/commands/configuration.py,sha256=NB5uf8HIX8-li95YLoZO09nALIWlLCHDF5aifSKcBn8,9815
|
| 31 |
+
pip/_internal/commands/debug.py,sha256=AesEID-4gPFDWTwPiPaGZuD4twdT-imaGuMR5ZfSn8s,6591
|
| 32 |
+
pip/_internal/commands/download.py,sha256=e4hw088zGo26WmJaMIRvCniLlLmoOjqolGyfHjsCkCQ,5335
|
| 33 |
+
pip/_internal/commands/freeze.py,sha256=2qjQrH9KWi5Roav0CuR7vc7hWm4uOi_0l6tp3ESKDHM,3172
|
| 34 |
+
pip/_internal/commands/hash.py,sha256=EVVOuvGtoPEdFi8SNnmdqlCQrhCxV-kJsdwtdcCnXGQ,1703
|
| 35 |
+
pip/_internal/commands/help.py,sha256=gcc6QDkcgHMOuAn5UxaZwAStsRBrnGSn_yxjS57JIoM,1132
|
| 36 |
+
pip/_internal/commands/index.py,sha256=cGQVSA5dAs7caQ9sz4kllYvaI4ZpGiq1WhCgaImXNSA,4793
|
| 37 |
+
pip/_internal/commands/inspect.py,sha256=2wSPt9yfr3r6g-s2S5L6PvRtaHNVyb4TuodMStJ39cw,3188
|
| 38 |
+
pip/_internal/commands/install.py,sha256=sdi44xeJlENfU-ziPl1TbUC3no2-ZGDpwBigmX1JuM0,28934
|
| 39 |
+
pip/_internal/commands/list.py,sha256=LNL6016BPvFpAZVzNoo_DWDzvRFpfw__m9Rp5kw-yUM,12457
|
| 40 |
+
pip/_internal/commands/search.py,sha256=sbBZiARRc050QquOKcCvOr2K3XLsoYebLKZGRi__iUI,5697
|
| 41 |
+
pip/_internal/commands/show.py,sha256=t5jia4zcYJRJZy4U_Von7zMl03hJmmcofj6oDNTnj7Y,6419
|
| 42 |
+
pip/_internal/commands/uninstall.py,sha256=OIqO9tqadY8kM4HwhFf1Q62fUIp7v8KDrTRo8yWMz7Y,3886
|
| 43 |
+
pip/_internal/commands/wheel.py,sha256=CSnX8Pmf1oPCnd7j7bn1_f58G9KHNiAblvVJ5zykN-A,6476
|
| 44 |
+
pip/_internal/distributions/__init__.py,sha256=Hq6kt6gXBgjNit5hTTWLAzeCNOKoB-N0pGYSqehrli8,858
|
| 45 |
+
pip/_internal/distributions/base.py,sha256=jrF1Vi7eGyqFqMHrieh1PIOrGU7KeCxhYPZnbvtmvGY,1221
|
| 46 |
+
pip/_internal/distributions/installed.py,sha256=NI2OgsgH9iBq9l5vB-56vOg5YsybOy-AU4VE5CSCO2I,729
|
| 47 |
+
pip/_internal/distributions/sdist.py,sha256=SQBdkatXSigKGG_SaD0U0p1Jwdfrg26UCNcHgkXZfdA,6494
|
| 48 |
+
pip/_internal/distributions/wheel.py,sha256=m-J4XO-gvFerlYsFzzSXYDvrx8tLZlJFTCgDxctn8ig,1164
|
| 49 |
+
pip/_internal/index/__init__.py,sha256=vpt-JeTZefh8a-FC22ZeBSXFVbuBcXSGiILhQZJaNpQ,30
|
| 50 |
+
pip/_internal/index/collector.py,sha256=3OmYZ3tCoRPGOrELSgQWG-03M-bQHa2-VCA3R_nJAaU,16504
|
| 51 |
+
pip/_internal/index/package_finder.py,sha256=rrUw4vj7QE_eMt022jw--wQiKznMaUgVBkJ1UCrVUxo,37873
|
| 52 |
+
pip/_internal/index/sources.py,sha256=7jw9XSeeQA5K-H4I5a5034Ks2gkQqm4zPXjrhwnP1S4,6556
|
| 53 |
+
pip/_internal/locations/__init__.py,sha256=Dh8LJWG8LRlDK4JIj9sfRF96TREzE--N_AIlx7Tqoe4,15365
|
| 54 |
+
pip/_internal/locations/_distutils.py,sha256=cmi6h63xYNXhQe7KEWEMaANjHFy5yQOPt_1_RCWyXMY,6100
|
| 55 |
+
pip/_internal/locations/_sysconfig.py,sha256=jyNVtUfMIf0mtyY-Xp1m9yQ8iwECozSVVFmjkN9a2yw,7680
|
| 56 |
+
pip/_internal/locations/base.py,sha256=RQiPi1d4FVM2Bxk04dQhXZ2PqkeljEL2fZZ9SYqIQ78,2556
|
| 57 |
+
pip/_internal/metadata/__init__.py,sha256=84j1dPJaIoz5Q2ZTPi0uB1iaDAHiUNfKtYSGQCfFKpo,4280
|
| 58 |
+
pip/_internal/metadata/_json.py,sha256=BTkWfFDrWFwuSodImjtbAh8wCL3isecbnjTb5E6UUDI,2595
|
| 59 |
+
pip/_internal/metadata/base.py,sha256=vIwIo1BtoqegehWMAXhNrpLGYBq245rcaCNkBMPnTU8,25277
|
| 60 |
+
pip/_internal/metadata/pkg_resources.py,sha256=WjwiNdRsvxqxL4MA5Tb5a_q3Q3sUhdpbZF8wGLtPMI0,9773
|
| 61 |
+
pip/_internal/metadata/importlib/__init__.py,sha256=9ZVO8BoE7NEZPmoHp5Ap_NJo0HgNIezXXg-TFTtt3Z4,107
|
| 62 |
+
pip/_internal/metadata/importlib/_compat.py,sha256=GAe_prIfCE4iUylrnr_2dJRlkkBVRUbOidEoID7LPoE,1882
|
| 63 |
+
pip/_internal/metadata/importlib/_dists.py,sha256=BUV8y6D0PePZrEN3vfJL-m1FDqZ6YPRgAiBeBinHhNg,8181
|
| 64 |
+
pip/_internal/metadata/importlib/_envs.py,sha256=I1DHMyAgZb8jT8CYndWl2aw2dN675p-BKPCuJhvdhrY,7435
|
| 65 |
+
pip/_internal/models/__init__.py,sha256=3DHUd_qxpPozfzouoqa9g9ts1Czr5qaHfFxbnxriepM,63
|
| 66 |
+
pip/_internal/models/candidate.py,sha256=6pcABsaR7CfIHlbJbr2_kMkVJFL_yrYjTx6SVWUnCPQ,990
|
| 67 |
+
pip/_internal/models/direct_url.py,sha256=EepBxI97j7wSZ3AmRETYyVTmR9NoTas15vc8popxVTg,6931
|
| 68 |
+
pip/_internal/models/format_control.py,sha256=DJpMYjxeYKKQdwNcML2_F0vtAh-qnKTYe-CpTxQe-4g,2520
|
| 69 |
+
pip/_internal/models/index.py,sha256=tYnL8oxGi4aSNWur0mG8DAP7rC6yuha_MwJO8xw0crI,1030
|
| 70 |
+
pip/_internal/models/installation_report.py,sha256=ueXv1RiMLAucaTuEvXACXX5R64_Wcm8b1Ztqx4Rd5xI,2609
|
| 71 |
+
pip/_internal/models/link.py,sha256=6OEk3bt41WU7QZoiyuoVPGsKOU-J_BbDDhouKbIXm0Y,20819
|
| 72 |
+
pip/_internal/models/scheme.py,sha256=3EFQp_ICu_shH1-TBqhl0QAusKCPDFOlgHFeN4XowWs,738
|
| 73 |
+
pip/_internal/models/search_scope.py,sha256=ASVyyZxiJILw7bTIVVpJx8J293M3Hk5F33ilGn0e80c,4643
|
| 74 |
+
pip/_internal/models/selection_prefs.py,sha256=KZdi66gsR-_RUXUr9uejssk3rmTHrQVJWeNA2sV-VSY,1907
|
| 75 |
+
pip/_internal/models/target_python.py,sha256=qKpZox7J8NAaPmDs5C_aniwfPDxzvpkrCKqfwndG87k,3858
|
| 76 |
+
pip/_internal/models/wheel.py,sha256=YqazoIZyma_Q1ejFa1C7NHKQRRWlvWkdK96VRKmDBeI,3600
|
| 77 |
+
pip/_internal/network/__init__.py,sha256=jf6Tt5nV_7zkARBrKojIXItgejvoegVJVKUbhAa5Ioc,50
|
| 78 |
+
pip/_internal/network/auth.py,sha256=TC-OcW2KU4W6R1hU4qPgQXvVH54adACpZz6sWq-R9NA,20541
|
| 79 |
+
pip/_internal/network/cache.py,sha256=hgXftU-eau4MWxHSLquTMzepYq5BPC2zhCkhN3glBy8,2145
|
| 80 |
+
pip/_internal/network/download.py,sha256=HvDDq9bVqaN3jcS3DyVJHP7uTqFzbShdkf7NFSoHfkw,6096
|
| 81 |
+
pip/_internal/network/lazy_wheel.py,sha256=2PXVduYZPCPZkkQFe1J1GbfHJWeCU--FXonGyIfw9eU,7638
|
| 82 |
+
pip/_internal/network/session.py,sha256=uhovd4J7abd0Yr2g426yC4aC6Uw1VKrQfpzalsEBEMw,18607
|
| 83 |
+
pip/_internal/network/utils.py,sha256=6A5SrUJEEUHxbGtbscwU2NpCyz-3ztiDlGWHpRRhsJ8,4073
|
| 84 |
+
pip/_internal/network/xmlrpc.py,sha256=AzQgG4GgS152_cqmGr_Oz2MIXsCal-xfsis7fA7nmU0,1791
|
| 85 |
+
pip/_internal/operations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 86 |
+
pip/_internal/operations/check.py,sha256=LD5BisEdT9vgzS7rLYUuk01z0l4oMj2Q7SsAxVu-pEk,6806
|
| 87 |
+
pip/_internal/operations/freeze.py,sha256=uqoeTAf6HOYVMR2UgAT8N85UZoGEVEoQdan_Ao6SOfk,9816
|
| 88 |
+
pip/_internal/operations/prepare.py,sha256=nxjIiGRSiUUSRFpwN-Qro7N6BE9jqV4mudJ7CIv9qwY,28868
|
| 89 |
+
pip/_internal/operations/build/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 90 |
+
pip/_internal/operations/build/build_tracker.py,sha256=vf81EwomN3xe9G8qRJED0VGqNikmRQRQoobNsxi5Xrs,4133
|
| 91 |
+
pip/_internal/operations/build/metadata.py,sha256=9S0CUD8U3QqZeXp-Zyt8HxwU90lE4QrnYDgrqZDzBnc,1422
|
| 92 |
+
pip/_internal/operations/build/metadata_editable.py,sha256=VLL7LvntKE8qxdhUdEJhcotFzUsOSI8NNS043xULKew,1474
|
| 93 |
+
pip/_internal/operations/build/metadata_legacy.py,sha256=o-eU21As175hDC7dluM1fJJ_FqokTIShyWpjKaIpHZw,2198
|
| 94 |
+
pip/_internal/operations/build/wheel.py,sha256=sT12FBLAxDC6wyrDorh8kvcZ1jG5qInCRWzzP-UkJiQ,1075
|
| 95 |
+
pip/_internal/operations/build/wheel_editable.py,sha256=yOtoH6zpAkoKYEUtr8FhzrYnkNHQaQBjWQ2HYae1MQg,1417
|
| 96 |
+
pip/_internal/operations/build/wheel_legacy.py,sha256=C9j6rukgQI1n_JeQLoZGuDdfUwzCXShyIdPTp6edbMQ,3064
|
| 97 |
+
pip/_internal/operations/install/__init__.py,sha256=mX7hyD2GNBO2mFGokDQ30r_GXv7Y_PLdtxcUv144e-s,51
|
| 98 |
+
pip/_internal/operations/install/editable_legacy.py,sha256=YeR0KadWXw_ZheC1NtAG1qVIEkOgRGHc23x-YtGW7NU,1282
|
| 99 |
+
pip/_internal/operations/install/wheel.py,sha256=8lsVMt_FAuiGNsf_e7C7_cCSOEO7pHyjgVmRNx-WXrw,27475
|
| 100 |
+
pip/_internal/req/__init__.py,sha256=TELFgZOof3lhMmaICVWL9U7PlhXo9OufokbMAJ6J2GI,2738
|
| 101 |
+
pip/_internal/req/constructors.py,sha256=8YE-eNXMSZ1lgsJZg-HnIo8EdaGfiOM2t3EaLlLD5Og,16610
|
| 102 |
+
pip/_internal/req/req_file.py,sha256=5PCO4GnDEnUENiFj4vD_1QmAMjHNtvN6HXbETZ9UGok,17872
|
| 103 |
+
pip/_internal/req/req_install.py,sha256=hpG29Bm2PAq7G-ogTatZcNUgjwt0zpdTXtxGw4M_MtU,33084
|
| 104 |
+
pip/_internal/req/req_set.py,sha256=pSCcIKURDkGb6JAKsc-cdvnvnAJlYPk-p3vvON9M3DY,4704
|
| 105 |
+
pip/_internal/req/req_uninstall.py,sha256=sGwa_yZ6X2NcRSUJWzUlYkf8bDEjRySAE3aQ5OewIWA,24678
|
| 106 |
+
pip/_internal/resolution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 107 |
+
pip/_internal/resolution/base.py,sha256=qlmh325SBVfvG6Me9gc5Nsh5sdwHBwzHBq6aEXtKsLA,583
|
| 108 |
+
pip/_internal/resolution/legacy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 109 |
+
pip/_internal/resolution/legacy/resolver.py,sha256=th-eTPIvbecfJaUsdrbH1aHQvDV2yCE-RhrrpsJhKbE,24128
|
| 110 |
+
pip/_internal/resolution/resolvelib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 111 |
+
pip/_internal/resolution/resolvelib/base.py,sha256=u1O4fkvCO4mhmu5i32xrDv9AX5NgUci_eYVyBDQhTIM,5220
|
| 112 |
+
pip/_internal/resolution/resolvelib/candidates.py,sha256=u5mU96o2lnUy-ODRJv7Wevee0xCYI6IKIXNamSBQnso,18969
|
| 113 |
+
pip/_internal/resolution/resolvelib/factory.py,sha256=y1Q2fsV1GKDKPitoapOLLEs75WNzEpd4l_RezCt927c,27845
|
| 114 |
+
pip/_internal/resolution/resolvelib/found_candidates.py,sha256=hvL3Hoa9VaYo-qEOZkBi2Iqw251UDxPz-uMHVaWmLpE,5705
|
| 115 |
+
pip/_internal/resolution/resolvelib/provider.py,sha256=4t23ivjruqM6hKBX1KpGiTt-M4HGhRcZnGLV0c01K7U,9824
|
| 116 |
+
pip/_internal/resolution/resolvelib/reporter.py,sha256=YFm9hQvz4DFCbjZeFTQ56hTz3Ac-mDBnHkeNRVvMHLY,3100
|
| 117 |
+
pip/_internal/resolution/resolvelib/requirements.py,sha256=zHnERhfubmvKyM3kgdAOs0dYFiqUfzKR-DAt4y0NWOI,5454
|
| 118 |
+
pip/_internal/resolution/resolvelib/resolver.py,sha256=n2Vn9EC5-7JmcRY5erIPQ4hUWnEUngG0oYS3JW3xXZo,11642
|
| 119 |
+
pip/_internal/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 120 |
+
pip/_internal/utils/_jaraco_text.py,sha256=yvDGelTVugRayPaOF2k4ab0Ky4d3uOkAfuOQjASjImY,3351
|
| 121 |
+
pip/_internal/utils/_log.py,sha256=-jHLOE_THaZz5BFcCnoSL9EYAtJ0nXem49s9of4jvKw,1015
|
| 122 |
+
pip/_internal/utils/appdirs.py,sha256=swgcTKOm3daLeXTW6v5BUS2Ti2RvEnGRQYH_yDXklAo,1665
|
| 123 |
+
pip/_internal/utils/compat.py,sha256=ACyBfLgj3_XG-iA5omEDrXqDM0cQKzi8h8HRBInzG6Q,1884
|
| 124 |
+
pip/_internal/utils/compatibility_tags.py,sha256=ydin8QG8BHqYRsPY4OL6cmb44CbqXl1T0xxS97VhHkk,5377
|
| 125 |
+
pip/_internal/utils/datetime.py,sha256=m21Y3wAtQc-ji6Veb6k_M5g6A0ZyFI4egchTdnwh-pQ,242
|
| 126 |
+
pip/_internal/utils/deprecation.py,sha256=NKo8VqLioJ4nnXXGmW4KdasxF90EFHkZaHeX1fT08C8,3627
|
| 127 |
+
pip/_internal/utils/direct_url_helpers.py,sha256=6F1tc2rcKaCZmgfVwsE6ObIe_Pux23mUVYA-2D9wCFc,3206
|
| 128 |
+
pip/_internal/utils/egg_link.py,sha256=ZryCchR_yQSCsdsMkCpxQjjLbQxObA5GDtLG0RR5mGc,2118
|
| 129 |
+
pip/_internal/utils/encoding.py,sha256=qqsXDtiwMIjXMEiIVSaOjwH5YmirCaK-dIzb6-XJsL0,1169
|
| 130 |
+
pip/_internal/utils/entrypoints.py,sha256=YlhLTRl2oHBAuqhc-zmL7USS67TPWVHImjeAQHreZTQ,3064
|
| 131 |
+
pip/_internal/utils/filesystem.py,sha256=RhMIXUaNVMGjc3rhsDahWQ4MavvEQDdqXqgq-F6fpw8,5122
|
| 132 |
+
pip/_internal/utils/filetypes.py,sha256=i8XAQ0eFCog26Fw9yV0Yb1ygAqKYB1w9Cz9n0fj8gZU,716
|
| 133 |
+
pip/_internal/utils/glibc.py,sha256=Mesxxgg3BLxheLZx-dSf30b6gKpOgdVXw6W--uHSszQ,3113
|
| 134 |
+
pip/_internal/utils/hashes.py,sha256=MjOigC75z6qoRMkgHiHqot7eqxfwDZSrEflJMPm-bHE,5118
|
| 135 |
+
pip/_internal/utils/inject_securetransport.py,sha256=o-QRVMGiENrTJxw3fAhA7uxpdEdw6M41TjHYtSVRrcg,795
|
| 136 |
+
pip/_internal/utils/logging.py,sha256=U2q0i1n8hPS2gQh8qcocAg5dovGAa_bR24akmXMzrk4,11632
|
| 137 |
+
pip/_internal/utils/misc.py,sha256=Ds3rSQU7HbdAywwmEBcPnVoLB1Tp_2gL6IbaWcpe8i0,22343
|
| 138 |
+
pip/_internal/utils/models.py,sha256=5GoYU586SrxURMvDn_jBMJInitviJg4O5-iOU-6I0WY,1193
|
| 139 |
+
pip/_internal/utils/packaging.py,sha256=5Wm6_x7lKrlqVjPI5MBN_RurcRHwVYoQ7Ksrs84de7s,2108
|
| 140 |
+
pip/_internal/utils/setuptools_build.py,sha256=ouXpud-jeS8xPyTPsXJ-m34NPvK5os45otAzdSV_IJE,4435
|
| 141 |
+
pip/_internal/utils/subprocess.py,sha256=0EMhgfPGFk8FZn6Qq7Hp9PN6YHuQNWiVby4DXcTCON4,9200
|
| 142 |
+
pip/_internal/utils/temp_dir.py,sha256=aCX489gRa4Nu0dMKRFyGhV6maJr60uEynu5uCbKR4Qg,7702
|
| 143 |
+
pip/_internal/utils/unpacking.py,sha256=SBb2iV1crb89MDRTEKY86R4A_UOWApTQn9VQVcMDOlE,8821
|
| 144 |
+
pip/_internal/utils/urls.py,sha256=AhaesUGl-9it6uvG6fsFPOr9ynFpGaTMk4t5XTX7Z_Q,1759
|
| 145 |
+
pip/_internal/utils/virtualenv.py,sha256=S6f7csYorRpiD6cvn3jISZYc3I8PJC43H5iMFpRAEDU,3456
|
| 146 |
+
pip/_internal/utils/wheel.py,sha256=lXOgZyTlOm5HmK8tw5iw0A3_5A6wRzsXHOaQkIvvloU,4549
|
| 147 |
+
pip/_internal/vcs/__init__.py,sha256=UAqvzpbi0VbZo3Ub6skEeZAw-ooIZR-zX_WpCbxyCoU,596
|
| 148 |
+
pip/_internal/vcs/bazaar.py,sha256=j0oin0fpGRHcCFCxEcpPCQoFEvA-DMLULKdGP8Nv76o,3519
|
| 149 |
+
pip/_internal/vcs/git.py,sha256=mjhwudCx9WlLNkxZ6_kOKmueF0rLoU2i1xeASKF6yiQ,18116
|
| 150 |
+
pip/_internal/vcs/mercurial.py,sha256=1FG5Zh2ltJZKryO40d2l2Q91FYNazuS16kkpoAVOh0Y,5244
|
| 151 |
+
pip/_internal/vcs/subversion.py,sha256=vhZs8L-TNggXqM1bbhl-FpbxE3TrIB6Tgnx8fh3S2HE,11729
|
| 152 |
+
pip/_internal/vcs/versioncontrol.py,sha256=KUOc-hN51em9jrqxKwUR3JnkgSE-xSOqMiiJcSaL6B8,22811
|
| 153 |
+
pip/_vendor/__init__.py,sha256=fNxOSVD0auElsD8fN9tuq5psfgMQ-RFBtD4X5gjlRkg,4966
|
| 154 |
+
pip/_vendor/six.py,sha256=TOOfQi7nFGfMrIvtdr6wX4wyHH8M7aknmuLfo2cBBrM,34549
|
| 155 |
+
pip/_vendor/typing_extensions.py,sha256=EWpcpyQnVmc48E9fSyPGs-vXgHcAk9tQABQIxmMsCGk,111130
|
| 156 |
+
pip/_vendor/vendor.txt,sha256=EyWEHCgXKFKiE8Mku6LONUDLF6UwDwjX1NP2ccKLrLo,475
|
| 157 |
+
pip/_vendor/cachecontrol/__init__.py,sha256=hrxlv3q7upsfyMw8k3gQ9vagBax1pYHSGGqYlZ0Zk0M,465
|
| 158 |
+
pip/_vendor/cachecontrol/_cmd.py,sha256=lxUXqfNTVx84zf6tcWbkLZHA6WVBRtJRpfeA9ZqhaAY,1379
|
| 159 |
+
pip/_vendor/cachecontrol/adapter.py,sha256=ew9OYEQHEOjvGl06ZsuX8W3DAvHWsQKHwWAxISyGug8,5033
|
| 160 |
+
pip/_vendor/cachecontrol/cache.py,sha256=Tty45fOjH40fColTGkqKQvQQmbYsMpk-nCyfLcv2vG4,1535
|
| 161 |
+
pip/_vendor/cachecontrol/compat.py,sha256=LNx7vqBndYdHU8YuJt53ab_8rzMGTXVrvMb7CZJkxG0,778
|
| 162 |
+
pip/_vendor/cachecontrol/controller.py,sha256=bAYrt7x_VH4toNpI066LQxbHpYGpY1MxxmZAhspplvw,16416
|
| 163 |
+
pip/_vendor/cachecontrol/filewrapper.py,sha256=X4BAQOO26GNOR7nH_fhTzAfeuct2rBQcx_15MyFBpcs,3946
|
| 164 |
+
pip/_vendor/cachecontrol/heuristics.py,sha256=8kAyuZLSCyEIgQr6vbUwfhpqg9ows4mM0IV6DWazevI,4154
|
| 165 |
+
pip/_vendor/cachecontrol/serialize.py,sha256=_U1NU_C-SDgFzkbAxAsPDgMTHeTWZZaHCQnZN_jh0U8,7105
|
| 166 |
+
pip/_vendor/cachecontrol/wrapper.py,sha256=X3-KMZ20Ho3VtqyVaXclpeQpFzokR5NE8tZSfvKVaB8,774
|
| 167 |
+
pip/_vendor/cachecontrol/caches/__init__.py,sha256=h-1cUmOz6mhLsjTjOrJ8iPejpGdLCyG4lzTftfGZvLg,242
|
| 168 |
+
pip/_vendor/cachecontrol/caches/file_cache.py,sha256=GpexcE29LoY4MaZwPUTcUBZaDdcsjqyLxZFznk8Hbr4,5271
|
| 169 |
+
pip/_vendor/cachecontrol/caches/redis_cache.py,sha256=mp-QWonP40I3xJGK3XVO-Gs9a3UjzlqqEmp9iLJH9F4,1033
|
| 170 |
+
pip/_vendor/certifi/__init__.py,sha256=q5ePznlfOw-XYIOV6RTnh45yS9haN-Nb1d__4QXc3g0,94
|
| 171 |
+
pip/_vendor/certifi/__main__.py,sha256=1k3Cr95vCxxGRGDljrW3wMdpZdL3Nhf0u1n-k2qdsCY,255
|
| 172 |
+
pip/_vendor/certifi/cacert.pem,sha256=swFTXcpJHZgU6ij6oyCsehnQ9dlCN5lvoKO1qTZDJRQ,278952
|
| 173 |
+
pip/_vendor/certifi/core.py,sha256=ZwiOsv-sD_ouU1ft8wy_xZ3LQ7UbcVzyqj2XNyrsZis,4279
|
| 174 |
+
pip/_vendor/chardet/__init__.py,sha256=57R-HSxj0PWmILMN0GFmUNqEMfrEVSamXyjD-W6_fbs,4797
|
| 175 |
+
pip/_vendor/chardet/big5freq.py,sha256=ltcfP-3PjlNHCoo5e4a7C4z-2DhBTXRfY6jbMbB7P30,31274
|
| 176 |
+
pip/_vendor/chardet/big5prober.py,sha256=lPMfwCX6v2AaPgvFh_cSWZcgLDbWiFCHLZ_p9RQ9uxE,1763
|
| 177 |
+
pip/_vendor/chardet/chardistribution.py,sha256=13B8XUG4oXDuLdXvfbIWwLFeR-ZU21AqTS1zcdON8bU,10032
|
| 178 |
+
pip/_vendor/chardet/charsetgroupprober.py,sha256=UKK3SaIZB2PCdKSIS0gnvMtLR9JJX62M-fZJu3OlWyg,3915
|
| 179 |
+
pip/_vendor/chardet/charsetprober.py,sha256=L3t8_wIOov8em-vZWOcbkdsrwe43N6_gqNh5pH7WPd4,5420
|
| 180 |
+
pip/_vendor/chardet/codingstatemachine.py,sha256=K7k69sw3jY5DmTXoSJQVsUtFIQKYPQVOSJJhBuGv_yE,3732
|
| 181 |
+
pip/_vendor/chardet/codingstatemachinedict.py,sha256=0GY3Hi2qIZvDrOOJ3AtqppM1RsYxr_66ER4EHjuMiMc,542
|
| 182 |
+
pip/_vendor/chardet/cp949prober.py,sha256=0jKRV7fECuWI16rNnks0ZECKA1iZYCIEaP8A1ZvjUSI,1860
|
| 183 |
+
pip/_vendor/chardet/enums.py,sha256=TzECiZoCKNMqgwU76cPCeKWFBqaWvAdLMev5_bCkhY8,1683
|
| 184 |
+
pip/_vendor/chardet/escprober.py,sha256=Kho48X65xE0scFylIdeJjM2bcbvRvv0h0WUbMWrJD3A,4006
|
| 185 |
+
pip/_vendor/chardet/escsm.py,sha256=AqyXpA2FQFD7k-buBty_7itGEYkhmVa8X09NLRul3QM,12176
|
| 186 |
+
pip/_vendor/chardet/eucjpprober.py,sha256=5KYaM9fsxkRYzw1b5k0fL-j_-ezIw-ij9r97a9MHxLY,3934
|
| 187 |
+
pip/_vendor/chardet/euckrfreq.py,sha256=3mHuRvXfsq_QcQysDQFb8qSudvTiol71C6Ic2w57tKM,13566
|
| 188 |
+
pip/_vendor/chardet/euckrprober.py,sha256=hiFT6wM174GIwRvqDsIcuOc-dDsq2uPKMKbyV8-1Xnc,1753
|
| 189 |
+
pip/_vendor/chardet/euctwfreq.py,sha256=2alILE1Lh5eqiFJZjzRkMQXolNJRHY5oBQd-vmZYFFM,36913
|
| 190 |
+
pip/_vendor/chardet/euctwprober.py,sha256=NxbpNdBtU0VFI0bKfGfDkpP7S2_8_6FlO87dVH0ogws,1753
|
| 191 |
+
pip/_vendor/chardet/gb2312freq.py,sha256=49OrdXzD-HXqwavkqjo8Z7gvs58hONNzDhAyMENNkvY,20735
|
| 192 |
+
pip/_vendor/chardet/gb2312prober.py,sha256=KPEBueaSLSvBpFeINMu0D6TgHcR90e5PaQawifzF4o0,1759
|
| 193 |
+
pip/_vendor/chardet/hebrewprober.py,sha256=96T_Lj_OmW-fK7JrSHojYjyG3fsGgbzkoTNleZ3kfYE,14537
|
| 194 |
+
pip/_vendor/chardet/jisfreq.py,sha256=mm8tfrwqhpOd3wzZKS4NJqkYBQVcDfTM2JiQ5aW932E,25796
|
| 195 |
+
pip/_vendor/chardet/johabfreq.py,sha256=dBpOYG34GRX6SL8k_LbS9rxZPMjLjoMlgZ03Pz5Hmqc,42498
|
| 196 |
+
pip/_vendor/chardet/johabprober.py,sha256=O1Qw9nVzRnun7vZp4UZM7wvJSv9W941mEU9uDMnY3DU,1752
|
| 197 |
+
pip/_vendor/chardet/jpcntx.py,sha256=uhHrYWkLxE_rF5OkHKInm0HUsrjgKHHVQvtt3UcvotA,27055
|
| 198 |
+
pip/_vendor/chardet/langbulgarianmodel.py,sha256=vmbvYFP8SZkSxoBvLkFqKiH1sjma5ihk3PTpdy71Rr4,104562
|
| 199 |
+
pip/_vendor/chardet/langgreekmodel.py,sha256=JfB7bupjjJH2w3X_mYnQr9cJA_7EuITC2cRW13fUjeI,98484
|
| 200 |
+
pip/_vendor/chardet/langhebrewmodel.py,sha256=3HXHaLQPNAGcXnJjkIJfozNZLTvTJmf4W5Awi6zRRKc,98196
|
| 201 |
+
pip/_vendor/chardet/langhungarianmodel.py,sha256=WxbeQIxkv8YtApiNqxQcvj-tMycsoI4Xy-fwkDHpP_Y,101363
|
| 202 |
+
pip/_vendor/chardet/langrussianmodel.py,sha256=s395bTZ87ESTrZCOdgXbEjZ9P1iGPwCl_8xSsac_DLY,128035
|
| 203 |
+
pip/_vendor/chardet/langthaimodel.py,sha256=7bJlQitRpTnVGABmbSznHnJwOHDy3InkTvtFUx13WQI,102774
|
| 204 |
+
pip/_vendor/chardet/langturkishmodel.py,sha256=XY0eGdTIy4eQ9Xg1LVPZacb-UBhHBR-cq0IpPVHowKc,95372
|
| 205 |
+
pip/_vendor/chardet/latin1prober.py,sha256=p15EEmFbmQUwbKLC7lOJVGHEZwcG45ubEZYTGu01J5g,5380
|
| 206 |
+
pip/_vendor/chardet/macromanprober.py,sha256=9anfzmY6TBfUPDyBDOdY07kqmTHpZ1tK0jL-p1JWcOY,6077
|
| 207 |
+
pip/_vendor/chardet/mbcharsetprober.py,sha256=Wr04WNI4F3X_VxEverNG-H25g7u-MDDKlNt-JGj-_uU,3715
|
| 208 |
+
pip/_vendor/chardet/mbcsgroupprober.py,sha256=iRpaNBjV0DNwYPu_z6TiHgRpwYahiM7ztI_4kZ4Uz9A,2131
|
| 209 |
+
pip/_vendor/chardet/mbcssm.py,sha256=hUtPvDYgWDaA2dWdgLsshbwRfm3Q5YRlRogdmeRUNQw,30391
|
| 210 |
+
pip/_vendor/chardet/resultdict.py,sha256=ez4FRvN5KaSosJeJ2WzUyKdDdg35HDy_SSLPXKCdt5M,402
|
| 211 |
+
pip/_vendor/chardet/sbcharsetprober.py,sha256=-nd3F90i7GpXLjehLVHqVBE0KlWzGvQUPETLBNn4o6U,6400
|
| 212 |
+
pip/_vendor/chardet/sbcsgroupprober.py,sha256=gcgI0fOfgw_3YTClpbra_MNxwyEyJ3eUXraoLHYb59E,4137
|
| 213 |
+
pip/_vendor/chardet/sjisprober.py,sha256=aqQufMzRw46ZpFlzmYaYeT2-nzmKb-hmcrApppJ862k,4007
|
| 214 |
+
pip/_vendor/chardet/universaldetector.py,sha256=xYBrg4x0dd9WnT8qclfADVD9ondrUNkqPmvte1pa520,14848
|
| 215 |
+
pip/_vendor/chardet/utf1632prober.py,sha256=pw1epGdMj1hDGiCu1AHqqzOEfjX8MVdiW7O1BlT8-eQ,8505
|
| 216 |
+
pip/_vendor/chardet/utf8prober.py,sha256=8m08Ub5490H4jQ6LYXvFysGtgKoKsHUd2zH_i8_TnVw,2812
|
| 217 |
+
pip/_vendor/chardet/version.py,sha256=lGtJcxGM44Qz4Cbk4rbbmrKxnNr1-97U25TameLehZw,244
|
| 218 |
+
pip/_vendor/chardet/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 219 |
+
pip/_vendor/chardet/cli/chardetect.py,sha256=zibMVg5RpKb-ME9_7EYG4ZM2Sf07NHcQzZ12U-rYJho,3242
|
| 220 |
+
pip/_vendor/chardet/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 221 |
+
pip/_vendor/chardet/metadata/languages.py,sha256=FhvBIdZFxRQ-dTwkb_0madRKgVBCaUMQz9I5xqjE5iQ,13560
|
| 222 |
+
pip/_vendor/colorama/__init__.py,sha256=wePQA4U20tKgYARySLEC047ucNX-g8pRLpYBuiHlLb8,266
|
| 223 |
+
pip/_vendor/colorama/ansi.py,sha256=Top4EeEuaQdBWdteKMEcGOTeKeF19Q-Wo_6_Cj5kOzQ,2522
|
| 224 |
+
pip/_vendor/colorama/ansitowin32.py,sha256=vPNYa3OZbxjbuFyaVo0Tmhmy1FZ1lKMWCnT7odXpItk,11128
|
| 225 |
+
pip/_vendor/colorama/initialise.py,sha256=-hIny86ClXo39ixh5iSCfUIa2f_h_bgKRDW7gqs-KLU,3325
|
| 226 |
+
pip/_vendor/colorama/win32.py,sha256=YQOKwMTwtGBbsY4dL5HYTvwTeP9wIQra5MvPNddpxZs,6181
|
| 227 |
+
pip/_vendor/colorama/winterm.py,sha256=XCQFDHjPi6AHYNdZwy0tA02H-Jh48Jp-HvCjeLeLp3U,7134
|
| 228 |
+
pip/_vendor/colorama/tests/__init__.py,sha256=MkgPAEzGQd-Rq0w0PZXSX2LadRWhUECcisJY8lSrm4Q,75
|
| 229 |
+
pip/_vendor/colorama/tests/ansi_test.py,sha256=FeViDrUINIZcr505PAxvU4AjXz1asEiALs9GXMhwRaE,2839
|
| 230 |
+
pip/_vendor/colorama/tests/ansitowin32_test.py,sha256=RN7AIhMJ5EqDsYaCjVo-o4u8JzDD4ukJbmevWKS70rY,10678
|
| 231 |
+
pip/_vendor/colorama/tests/initialise_test.py,sha256=BbPy-XfyHwJ6zKozuQOvNvQZzsx9vdb_0bYXn7hsBTc,6741
|
| 232 |
+
pip/_vendor/colorama/tests/isatty_test.py,sha256=Pg26LRpv0yQDB5Ac-sxgVXG7hsA1NYvapFgApZfYzZg,1866
|
| 233 |
+
pip/_vendor/colorama/tests/utils.py,sha256=1IIRylG39z5-dzq09R_ngufxyPZxgldNbrxKxUGwGKE,1079
|
| 234 |
+
pip/_vendor/colorama/tests/winterm_test.py,sha256=qoWFPEjym5gm2RuMwpf3pOis3a5r_PJZFCzK254JL8A,3709
|
| 235 |
+
pip/_vendor/distlib/__init__.py,sha256=acgfseOC55dNrVAzaBKpUiH3Z6V7Q1CaxsiQ3K7pC-E,581
|
| 236 |
+
pip/_vendor/distlib/compat.py,sha256=tfoMrj6tujk7G4UC2owL6ArgDuCKabgBxuJRGZSmpko,41259
|
| 237 |
+
pip/_vendor/distlib/database.py,sha256=o_mw0fAr93NDAHHHfqG54Y1Hi9Rkfrp2BX15XWZYK50,51697
|
| 238 |
+
pip/_vendor/distlib/index.py,sha256=HFiDG7LMoaBs829WuotrfIwcErOOExUOR_AeBtw_TCU,20834
|
| 239 |
+
pip/_vendor/distlib/locators.py,sha256=wNzG-zERzS_XGls-nBPVVyLRHa2skUlkn0-5n0trMWA,51991
|
| 240 |
+
pip/_vendor/distlib/manifest.py,sha256=nQEhYmgoreaBZzyFzwYsXxJARu3fo4EkunU163U16iE,14811
|
| 241 |
+
pip/_vendor/distlib/markers.py,sha256=TpHHHLgkzyT7YHbwj-2i6weRaq-Ivy2-MUnrDkjau-U,5058
|
| 242 |
+
pip/_vendor/distlib/metadata.py,sha256=g_DIiu8nBXRzA-mWPRpatHGbmFZqaFoss7z9TG7QSUU,39801
|
| 243 |
+
pip/_vendor/distlib/resources.py,sha256=LwbPksc0A1JMbi6XnuPdMBUn83X7BPuFNWqPGEKI698,10820
|
| 244 |
+
pip/_vendor/distlib/scripts.py,sha256=BmkTKmiTk4m2cj-iueliatwz3ut_9SsABBW51vnQnZU,18102
|
| 245 |
+
pip/_vendor/distlib/t32.exe,sha256=a0GV5kCoWsMutvliiCKmIgV98eRZ33wXoS-XrqvJQVs,97792
|
| 246 |
+
pip/_vendor/distlib/t64-arm.exe,sha256=68TAa32V504xVBnufojh0PcenpR3U4wAqTqf-MZqbPw,182784
|
| 247 |
+
pip/_vendor/distlib/t64.exe,sha256=gaYY8hy4fbkHYTTnA4i26ct8IQZzkBG2pRdy0iyuBrc,108032
|
| 248 |
+
pip/_vendor/distlib/util.py,sha256=31dPXn3Rfat0xZLeVoFpuniyhe6vsbl9_QN-qd9Lhlk,66262
|
| 249 |
+
pip/_vendor/distlib/version.py,sha256=WG__LyAa2GwmA6qSoEJtvJE8REA1LZpbSizy8WvhJLk,23513
|
| 250 |
+
pip/_vendor/distlib/w32.exe,sha256=R4csx3-OGM9kL4aPIzQKRo5TfmRSHZo6QWyLhDhNBks,91648
|
| 251 |
+
pip/_vendor/distlib/w64-arm.exe,sha256=xdyYhKj0WDcVUOCb05blQYvzdYIKMbmJn2SZvzkcey4,168448
|
| 252 |
+
pip/_vendor/distlib/w64.exe,sha256=ejGf-rojoBfXseGLpya6bFTFPWRG21X5KvU8J5iU-K0,101888
|
| 253 |
+
pip/_vendor/distlib/wheel.py,sha256=Rgqs658VsJ3R2845qwnZD8XQryV2CzWw2mghwLvxxsI,43898
|
| 254 |
+
pip/_vendor/distro/__init__.py,sha256=2fHjF-SfgPvjyNZ1iHh_wjqWdR_Yo5ODHwZC0jLBPhc,981
|
| 255 |
+
pip/_vendor/distro/__main__.py,sha256=bu9d3TifoKciZFcqRBuygV3GSuThnVD_m2IK4cz96Vs,64
|
| 256 |
+
pip/_vendor/distro/distro.py,sha256=UZO1LjIhtFCMdlbiz39gj3raV-Amf3SBwzGzfApiMHw,49330
|
| 257 |
+
pip/_vendor/idna/__init__.py,sha256=KJQN1eQBr8iIK5SKrJ47lXvxG0BJ7Lm38W4zT0v_8lk,849
|
| 258 |
+
pip/_vendor/idna/codec.py,sha256=6ly5odKfqrytKT9_7UrlGklHnf1DSK2r9C6cSM4sa28,3374
|
| 259 |
+
pip/_vendor/idna/compat.py,sha256=0_sOEUMT4CVw9doD3vyRhX80X19PwqFoUBs7gWsFME4,321
|
| 260 |
+
pip/_vendor/idna/core.py,sha256=1JxchwKzkxBSn7R_oCE12oBu3eVux0VzdxolmIad24M,12950
|
| 261 |
+
pip/_vendor/idna/idnadata.py,sha256=xUjqKqiJV8Ho_XzBpAtv5JFoVPSupK-SUXvtjygUHqw,44375
|
| 262 |
+
pip/_vendor/idna/intranges.py,sha256=YBr4fRYuWH7kTKS2tXlFjM24ZF1Pdvcir-aywniInqg,1881
|
| 263 |
+
pip/_vendor/idna/package_data.py,sha256=C_jHJzmX8PI4xq0jpzmcTMxpb5lDsq4o5VyxQzlVrZE,21
|
| 264 |
+
pip/_vendor/idna/uts46data.py,sha256=zvjZU24s58_uAS850Mcd0NnD0X7_gCMAMjzWNIeUJdc,206539
|
| 265 |
+
pip/_vendor/msgpack/__init__.py,sha256=hyGhlnmcJkxryJBKC3X5FnEph375kQoL_mG8LZUuXgY,1132
|
| 266 |
+
pip/_vendor/msgpack/exceptions.py,sha256=dCTWei8dpkrMsQDcjQk74ATl9HsIBH0ybt8zOPNqMYc,1081
|
| 267 |
+
pip/_vendor/msgpack/ext.py,sha256=C5MK8JhVYGYFWPvxsORsqZAnvOXefYQ57m1Ym0luW5M,6079
|
| 268 |
+
pip/_vendor/msgpack/fallback.py,sha256=tvNBHyxxFbuVlC8GZShETClJxjLiDMOja4XwwyvNm2g,34544
|
| 269 |
+
pip/_vendor/packaging/__about__.py,sha256=ugASIO2w1oUyH8_COqQ2X_s0rDhjbhQC3yJocD03h2c,661
|
| 270 |
+
pip/_vendor/packaging/__init__.py,sha256=b9Kk5MF7KxhhLgcDmiUWukN-LatWFxPdNug0joPhHSk,497
|
| 271 |
+
pip/_vendor/packaging/_manylinux.py,sha256=XcbiXB-qcjv3bcohp6N98TMpOP4_j3m-iOA8ptK2GWY,11488
|
| 272 |
+
pip/_vendor/packaging/_musllinux.py,sha256=_KGgY_qc7vhMGpoqss25n2hiLCNKRtvz9mCrS7gkqyc,4378
|
| 273 |
+
pip/_vendor/packaging/_structures.py,sha256=q3eVNmbWJGG_S0Dit_S3Ao8qQqz_5PYTXFAKBZe5yr4,1431
|
| 274 |
+
pip/_vendor/packaging/markers.py,sha256=AJBOcY8Oq0kYc570KuuPTkvuqjAlhufaE2c9sCUbm64,8487
|
| 275 |
+
pip/_vendor/packaging/requirements.py,sha256=NtDlPBtojpn1IUC85iMjPNsUmufjpSlwnNA-Xb4m5NA,4676
|
| 276 |
+
pip/_vendor/packaging/specifiers.py,sha256=LRQ0kFsHrl5qfcFNEEJrIFYsnIHQUJXY9fIsakTrrqE,30110
|
| 277 |
+
pip/_vendor/packaging/tags.py,sha256=lmsnGNiJ8C4D_Pf9PbM0qgbZvD9kmB9lpZBQUZa3R_Y,15699
|
| 278 |
+
pip/_vendor/packaging/utils.py,sha256=dJjeat3BS-TYn1RrUFVwufUMasbtzLfYRoy_HXENeFQ,4200
|
| 279 |
+
pip/_vendor/packaging/version.py,sha256=_fLRNrFrxYcHVfyo8vk9j8s6JM8N_xsSxVFr6RJyco8,14665
|
| 280 |
+
pip/_vendor/pkg_resources/__init__.py,sha256=hTAeJCNYb7dJseIDVsYK3mPQep_gphj4tQh-bspX8bg,109364
|
| 281 |
+
pip/_vendor/platformdirs/__init__.py,sha256=SkhEYVyC_HUHC6KX7n4M_6coyRMtEB38QMyOYIAX6Yk,20155
|
| 282 |
+
pip/_vendor/platformdirs/__main__.py,sha256=fVvSiTzr2-RM6IsjWjj4fkaOtDOgDhUWv6sA99do4CQ,1476
|
| 283 |
+
pip/_vendor/platformdirs/android.py,sha256=y_EEMKwYl2-bzYBDovksSn8m76on0Lda8eyJksVQE9U,7211
|
| 284 |
+
pip/_vendor/platformdirs/api.py,sha256=jWtX06jAJytYrkJDOqEls97mCkyHRSZkoqUlbMK5Qew,7132
|
| 285 |
+
pip/_vendor/platformdirs/macos.py,sha256=LueVOoVgGWDBwQb8OFwXkVKfVn33CM1Lkwf1-A86tRQ,3678
|
| 286 |
+
pip/_vendor/platformdirs/unix.py,sha256=22JhR8ZY0aLxSVCFnKrc6f1iz6Gv42K24Daj7aTjfSg,8809
|
| 287 |
+
pip/_vendor/platformdirs/version.py,sha256=mavZTQIJIXfdewEaSTn7EWrNfPZWeRofb-74xqW5f2M,160
|
| 288 |
+
pip/_vendor/platformdirs/windows.py,sha256=4TtbPGoWG2PRgI11uquDa7eRk8TcxvnUNuuMGZItnXc,9573
|
| 289 |
+
pip/_vendor/pygments/__init__.py,sha256=6AuDljQtvf89DTNUyWM7k3oUlP_lq70NU-INKKteOBY,2983
|
| 290 |
+
pip/_vendor/pygments/__main__.py,sha256=es8EKMvXj5yToIfQ-pf3Dv5TnIeeM6sME0LW-n4ecHo,353
|
| 291 |
+
pip/_vendor/pygments/cmdline.py,sha256=byxYJp9gnjVeyhRlZ3UTMgo_LhkXh1afvN8wJBtAcc8,23685
|
| 292 |
+
pip/_vendor/pygments/console.py,sha256=2wZ5W-U6TudJD1_NLUwjclMpbomFM91lNv11_60sfGY,1697
|
| 293 |
+
pip/_vendor/pygments/filter.py,sha256=j5aLM9a9wSx6eH1oy473oSkJ02hGWNptBlVo4s1g_30,1938
|
| 294 |
+
pip/_vendor/pygments/formatter.py,sha256=J9OL9hXLJKZk7moUgKwpjW9HNf4WlJFg_o_-Z_S_tTY,4178
|
| 295 |
+
pip/_vendor/pygments/lexer.py,sha256=2BpqLlT2ExvOOi7vnjK5nB4Fp-m52ldiPaXMox5uwug,34618
|
| 296 |
+
pip/_vendor/pygments/modeline.py,sha256=eF2vO4LpOGoPvIKKkbPfnyut8hT4UiebZPpb-BYGQdI,986
|
| 297 |
+
pip/_vendor/pygments/plugin.py,sha256=j1Fh310RbV2DQ9nvkmkqvlj38gdyuYKllLnGxbc8sJM,2591
|
| 298 |
+
pip/_vendor/pygments/regexopt.py,sha256=jg1ALogcYGU96TQS9isBl6dCrvw5y5--BP_K-uFk_8s,3072
|
| 299 |
+
pip/_vendor/pygments/scanner.py,sha256=b_nu5_f3HCgSdp5S_aNRBQ1MSCm4ZjDwec2OmTRickw,3092
|
| 300 |
+
pip/_vendor/pygments/sphinxext.py,sha256=wBFYm180qea9JKt__UzhRlNRNhczPDFDaqGD21sbuso,6882
|
| 301 |
+
pip/_vendor/pygments/style.py,sha256=C4qyoJrUTkq-OV3iO-8Vz3UtWYpJwSTdh5_vlGCGdNQ,6257
|
| 302 |
+
pip/_vendor/pygments/token.py,sha256=seNsmcch9OEHXYirh8Ool7w8xDhfNTbLj5rHAC-gc_o,6184
|
| 303 |
+
pip/_vendor/pygments/unistring.py,sha256=FaUfG14NBJEKLQoY9qj6JYeXrpYcLmKulghdxOGFaOc,63223
|
| 304 |
+
pip/_vendor/pygments/util.py,sha256=AEVY0qonyyEMgv4Do2dINrrqUAwUk2XYSqHM650uzek,10230
|
| 305 |
+
pip/_vendor/pygments/filters/__init__.py,sha256=h_koYkUFo-FFUxjs564JHUAz7O3yJpVwI6fKN3MYzG0,40386
|
| 306 |
+
pip/_vendor/pygments/formatters/__init__.py,sha256=_xgAcdFKr0QNYwh_i98AU9hvfP3X2wAkhElFcRRF3Uo,5424
|
| 307 |
+
pip/_vendor/pygments/formatters/_mapping.py,sha256=1Cw37FuQlNacnxRKmtlPX4nyLoX9_ttko5ZwscNUZZ4,4176
|
| 308 |
+
pip/_vendor/pygments/formatters/bbcode.py,sha256=r1b7wzWTJouADDLh-Z11iRi4iQxD0JKJ1qHl6mOYxsA,3314
|
| 309 |
+
pip/_vendor/pygments/formatters/groff.py,sha256=xy8Zf3tXOo6MWrXh7yPGWx3lVEkg_DhY4CxmsDb0IVo,5094
|
| 310 |
+
pip/_vendor/pygments/formatters/html.py,sha256=PIzAyilNqaTzSSP2slDG2VDLE3qNioWy2rgtSSoviuI,35610
|
| 311 |
+
pip/_vendor/pygments/formatters/img.py,sha256=XKXmg2_XONrR4mtq2jfEU8XCsoln3VSGTw-UYiEokys,21938
|
| 312 |
+
pip/_vendor/pygments/formatters/irc.py,sha256=Ep-m8jd3voFO6Fv57cUGFmz6JVA67IEgyiBOwv0N4a0,4981
|
| 313 |
+
pip/_vendor/pygments/formatters/latex.py,sha256=FGzJ-YqSTE8z_voWPdzvLY5Tq8jE_ygjGjM6dXZJ8-k,19351
|
| 314 |
+
pip/_vendor/pygments/formatters/other.py,sha256=gPxkk5BdAzWTCgbEHg1lpLi-1F6ZPh5A_aotgLXHnzg,5073
|
| 315 |
+
pip/_vendor/pygments/formatters/pangomarkup.py,sha256=6LKnQc8yh49f802bF0sPvbzck4QivMYqqoXAPaYP8uU,2212
|
| 316 |
+
pip/_vendor/pygments/formatters/rtf.py,sha256=aA0v_psW6KZI3N18TKDifxeL6mcF8EDXcPXDWI4vhVQ,5014
|
| 317 |
+
pip/_vendor/pygments/formatters/svg.py,sha256=dQONWypbzfvzGCDtdp3M_NJawScJvM2DiHbx1k-ww7g,7335
|
| 318 |
+
pip/_vendor/pygments/formatters/terminal.py,sha256=FG-rpjRpFmNpiGB4NzIucvxq6sQIXB3HOTo2meTKtrU,4674
|
| 319 |
+
pip/_vendor/pygments/formatters/terminal256.py,sha256=13SJ3D5pFdqZ9zROE6HbWnBDwHvOGE8GlsmqGhprRp4,11753
|
| 320 |
+
pip/_vendor/pygments/lexers/__init__.py,sha256=j5KEi5O_VQ5GS59H49l-10gzUOkWKxlwGeVMlGO2MMk,12130
|
| 321 |
+
pip/_vendor/pygments/lexers/_mapping.py,sha256=Hts4r_ZQ8icftGM7gkBPeED5lyVSv4affFgXYE6Ap04,72281
|
| 322 |
+
pip/_vendor/pygments/lexers/python.py,sha256=c7jnmKFU9DLxTJW0UbwXt6Z9FJqbBlVsWA1Qr9xSA_w,53424
|
| 323 |
+
pip/_vendor/pygments/styles/__init__.py,sha256=he7HjQx7sC0d2kfTVLjUs0J15mtToJM6M1brwIm9--Q,3700
|
| 324 |
+
pip/_vendor/pyparsing/__init__.py,sha256=9m1JbE2JTLdBG0Mb6B0lEaZj181Wx5cuPXZpsbHEYgE,9116
|
| 325 |
+
pip/_vendor/pyparsing/actions.py,sha256=05uaIPOznJPQ7VgRdmGCmG4sDnUPtwgv5qOYIqbL2UY,6567
|
| 326 |
+
pip/_vendor/pyparsing/common.py,sha256=p-3c83E5-DjlkF35G0O9-kjQRpoejP-2_z0hxZ-eol4,13387
|
| 327 |
+
pip/_vendor/pyparsing/core.py,sha256=yvuRlLpXSF8mgk-QhiW3OVLqD9T0rsj9tbibhRH4Yaw,224445
|
| 328 |
+
pip/_vendor/pyparsing/exceptions.py,sha256=6Jc6W1eDZBzyFu1J0YrcdNFVBC-RINujZmveSnB8Rxw,9523
|
| 329 |
+
pip/_vendor/pyparsing/helpers.py,sha256=BZJHCA8SS0pYio30KGQTc9w2qMOaK4YpZ7hcvHbnTgk,38646
|
| 330 |
+
pip/_vendor/pyparsing/results.py,sha256=9dyqQ-w3MjfmxWbFt8KEPU6IfXeyRdoWp2Og802rUQY,26692
|
| 331 |
+
pip/_vendor/pyparsing/testing.py,sha256=eJncg0p83zm1FTPvM9auNT6oavIvXaibmRFDf1qmwkY,13488
|
| 332 |
+
pip/_vendor/pyparsing/unicode.py,sha256=fAPdsJiARFbkPAih6NkYry0dpj4jPqelGVMlE4wWFW8,10646
|
| 333 |
+
pip/_vendor/pyparsing/util.py,sha256=vTMzTdwSDyV8d_dSgquUTdWgBFoA_W30nfxEJDsshRQ,8670
|
| 334 |
+
pip/_vendor/pyparsing/diagram/__init__.py,sha256=nxmDOoYF9NXuLaGYy01tKFjkNReWJlrGFuJNWEiTo84,24215
|
| 335 |
+
pip/_vendor/pyproject_hooks/__init__.py,sha256=kCehmy0UaBa9oVMD7ZIZrnswfnP3LXZ5lvnNJAL5JBM,491
|
| 336 |
+
pip/_vendor/pyproject_hooks/_compat.py,sha256=by6evrYnqkisiM-MQcvOKs5bgDMzlOSgZqRHNqf04zE,138
|
| 337 |
+
pip/_vendor/pyproject_hooks/_impl.py,sha256=61GJxzQip0IInhuO69ZI5GbNQ82XEDUB_1Gg5_KtUoc,11920
|
| 338 |
+
pip/_vendor/pyproject_hooks/_in_process/__init__.py,sha256=9gQATptbFkelkIy0OfWFEACzqxXJMQDWCH9rBOAZVwQ,546
|
| 339 |
+
pip/_vendor/pyproject_hooks/_in_process/_in_process.py,sha256=m2b34c917IW5o-Q_6TYIHlsK9lSUlNiyrITTUH_zwew,10927
|
| 340 |
+
pip/_vendor/requests/__init__.py,sha256=owujob4dk45Siy4EYtbCKR6wcFph7E04a_v_OuAacBA,5169
|
| 341 |
+
pip/_vendor/requests/__version__.py,sha256=ssI3Ezt7PaxgkOW45GhtwPUclo_SO_ygtIm4A74IOfw,435
|
| 342 |
+
pip/_vendor/requests/_internal_utils.py,sha256=nMQymr4hs32TqVo5AbCrmcJEhvPUh7xXlluyqwslLiQ,1495
|
| 343 |
+
pip/_vendor/requests/adapters.py,sha256=idj6cZcId3L5xNNeJ7ieOLtw3awJk5A64xUfetHwq3M,19697
|
| 344 |
+
pip/_vendor/requests/api.py,sha256=q61xcXq4tmiImrvcSVLTbFyCiD2F-L_-hWKGbz4y8vg,6449
|
| 345 |
+
pip/_vendor/requests/auth.py,sha256=h-HLlVx9j8rKV5hfSAycP2ApOSglTz77R0tz7qCbbEE,10187
|
| 346 |
+
pip/_vendor/requests/certs.py,sha256=PVPooB0jP5hkZEULSCwC074532UFbR2Ptgu0I5zwmCs,575
|
| 347 |
+
pip/_vendor/requests/compat.py,sha256=IhK9quyX0RRuWTNcg6d2JGSAOUbM6mym2p_2XjLTwf4,1286
|
| 348 |
+
pip/_vendor/requests/cookies.py,sha256=kD3kNEcCj-mxbtf5fJsSaT86eGoEYpD3X0CSgpzl7BM,18560
|
| 349 |
+
pip/_vendor/requests/exceptions.py,sha256=FA-_kVwBZ2jhXauRctN_ewHVK25b-fj0Azyz1THQ0Kk,3823
|
| 350 |
+
pip/_vendor/requests/help.py,sha256=FnAAklv8MGm_qb2UilDQgS6l0cUttiCFKUjx0zn2XNA,3879
|
| 351 |
+
pip/_vendor/requests/hooks.py,sha256=CiuysiHA39V5UfcCBXFIx83IrDpuwfN9RcTUgv28ftQ,733
|
| 352 |
+
pip/_vendor/requests/models.py,sha256=dDZ-iThotky-Noq9yy97cUEJhr3wnY6mv-xR_ePg_lk,35288
|
| 353 |
+
pip/_vendor/requests/packages.py,sha256=njJmVifY4aSctuW3PP5EFRCxjEwMRDO6J_feG2dKWsI,695
|
| 354 |
+
pip/_vendor/requests/sessions.py,sha256=-LvTzrPtetSTrR3buxu4XhdgMrJFLB1q5D7P--L2Xhw,30373
|
| 355 |
+
pip/_vendor/requests/status_codes.py,sha256=FvHmT5uH-_uimtRz5hH9VCbt7VV-Nei2J9upbej6j8g,4235
|
| 356 |
+
pip/_vendor/requests/structures.py,sha256=-IbmhVz06S-5aPSZuUthZ6-6D9XOjRuTXHOabY041XM,2912
|
| 357 |
+
pip/_vendor/requests/utils.py,sha256=kOPn0qYD6xRTzaxbqTdYiSInBZHl6379AJsyIgzYGLY,33460
|
| 358 |
+
pip/_vendor/resolvelib/__init__.py,sha256=h509TdEcpb5-44JonaU3ex2TM15GVBLjM9CNCPwnTTs,537
|
| 359 |
+
pip/_vendor/resolvelib/providers.py,sha256=fuuvVrCetu5gsxPB43ERyjfO8aReS3rFQHpDgiItbs4,5871
|
| 360 |
+
pip/_vendor/resolvelib/reporters.py,sha256=TSbRmWzTc26w0ggsV1bxVpeWDB8QNIre6twYl7GIZBE,1601
|
| 361 |
+
pip/_vendor/resolvelib/resolvers.py,sha256=G8rsLZSq64g5VmIq-lB7UcIJ1gjAxIQJmTF4REZleQ0,20511
|
| 362 |
+
pip/_vendor/resolvelib/structs.py,sha256=0_1_XO8z_CLhegP3Vpf9VJ3zJcfLm0NOHRM-i0Ykz3o,4963
|
| 363 |
+
pip/_vendor/resolvelib/compat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 364 |
+
pip/_vendor/resolvelib/compat/collections_abc.py,sha256=uy8xUZ-NDEw916tugUXm8HgwCGiMO0f-RcdnpkfXfOs,156
|
| 365 |
+
pip/_vendor/rich/__init__.py,sha256=dRxjIL-SbFVY0q3IjSMrfgBTHrm1LZDgLOygVBwiYZc,6090
|
| 366 |
+
pip/_vendor/rich/__main__.py,sha256=TT8sb9PTnsnKhhrGuHkLN0jdN0dtKhtPkEr9CidDbPM,8478
|
| 367 |
+
pip/_vendor/rich/_cell_widths.py,sha256=2n4EiJi3X9sqIq0O16kUZ_zy6UYMd3xFfChlKfnW1Hc,10096
|
| 368 |
+
pip/_vendor/rich/_emoji_codes.py,sha256=hu1VL9nbVdppJrVoijVshRlcRRe_v3dju3Mmd2sKZdY,140235
|
| 369 |
+
pip/_vendor/rich/_emoji_replace.py,sha256=n-kcetsEUx2ZUmhQrfeMNc-teeGhpuSQ5F8VPBsyvDo,1064
|
| 370 |
+
pip/_vendor/rich/_export_format.py,sha256=qxgV3nKnXQu1hfbnRVswPYy-AwIg1X0LSC47cK5s8jk,2100
|
| 371 |
+
pip/_vendor/rich/_extension.py,sha256=Xt47QacCKwYruzjDi-gOBq724JReDj9Cm9xUi5fr-34,265
|
| 372 |
+
pip/_vendor/rich/_fileno.py,sha256=HWZxP5C2ajMbHryvAQZseflVfQoGzsKOHzKGsLD8ynQ,799
|
| 373 |
+
pip/_vendor/rich/_inspect.py,sha256=oZJGw31e64dwXSCmrDnvZbwVb1ZKhWfU8wI3VWohjJk,9695
|
| 374 |
+
pip/_vendor/rich/_log_render.py,sha256=1ByI0PA1ZpxZY3CGJOK54hjlq4X-Bz_boIjIqCd8Kns,3225
|
| 375 |
+
pip/_vendor/rich/_loop.py,sha256=hV_6CLdoPm0va22Wpw4zKqM0RYsz3TZxXj0PoS-9eDQ,1236
|
| 376 |
+
pip/_vendor/rich/_null_file.py,sha256=tGSXk_v-IZmbj1GAzHit8A3kYIQMiCpVsCFfsC-_KJ4,1387
|
| 377 |
+
pip/_vendor/rich/_palettes.py,sha256=cdev1JQKZ0JvlguV9ipHgznTdnvlIzUFDBb0It2PzjI,7063
|
| 378 |
+
pip/_vendor/rich/_pick.py,sha256=evDt8QN4lF5CiwrUIXlOJCntitBCOsI3ZLPEIAVRLJU,423
|
| 379 |
+
pip/_vendor/rich/_ratio.py,sha256=2lLSliL025Y-YMfdfGbutkQDevhcyDqc-DtUYW9mU70,5472
|
| 380 |
+
pip/_vendor/rich/_spinners.py,sha256=U2r1_g_1zSjsjiUdAESc2iAMc3i4ri_S8PYP6kQ5z1I,19919
|
| 381 |
+
pip/_vendor/rich/_stack.py,sha256=-C8OK7rxn3sIUdVwxZBBpeHhIzX0eI-VM3MemYfaXm0,351
|
| 382 |
+
pip/_vendor/rich/_timer.py,sha256=zelxbT6oPFZnNrwWPpc1ktUeAT-Vc4fuFcRZLQGLtMI,417
|
| 383 |
+
pip/_vendor/rich/_win32_console.py,sha256=P0vxI2fcndym1UU1S37XAzQzQnkyY7YqAKmxm24_gug,22820
|
| 384 |
+
pip/_vendor/rich/_windows.py,sha256=dvNl9TmfPzNVxiKk5WDFihErZ5796g2UC9-KGGyfXmk,1926
|
| 385 |
+
pip/_vendor/rich/_windows_renderer.py,sha256=t74ZL3xuDCP3nmTp9pH1L5LiI2cakJuQRQleHCJerlk,2783
|
| 386 |
+
pip/_vendor/rich/_wrap.py,sha256=xfV_9t0Sg6rzimmrDru8fCVmUlalYAcHLDfrJZnbbwQ,1840
|
| 387 |
+
pip/_vendor/rich/abc.py,sha256=ON-E-ZqSSheZ88VrKX2M3PXpFbGEUUZPMa_Af0l-4f0,890
|
| 388 |
+
pip/_vendor/rich/align.py,sha256=Ji-Yokfkhnfe_xMmr4ISjZB07TJXggBCOYoYa-HDAr8,10368
|
| 389 |
+
pip/_vendor/rich/ansi.py,sha256=iD6532QYqnBm6hADulKjrV8l8kFJ-9fEVooHJHH3hMg,6906
|
| 390 |
+
pip/_vendor/rich/bar.py,sha256=a7UD303BccRCrEhGjfMElpv5RFYIinaAhAuqYqhUvmw,3264
|
| 391 |
+
pip/_vendor/rich/box.py,sha256=FJ6nI3jD7h2XNFU138bJUt2HYmWOlRbltoCEuIAZhew,9842
|
| 392 |
+
pip/_vendor/rich/cells.py,sha256=627ztJs9zOL-38HJ7kXBerR-gT8KBfYC8UzEwMJDYYo,4509
|
| 393 |
+
pip/_vendor/rich/color.py,sha256=9Gh958U3f75WVdLTeC0U9nkGTn2n0wnojKpJ6jQEkIE,18224
|
| 394 |
+
pip/_vendor/rich/color_triplet.py,sha256=3lhQkdJbvWPoLDO-AnYImAWmJvV5dlgYNCVZ97ORaN4,1054
|
| 395 |
+
pip/_vendor/rich/columns.py,sha256=HUX0KcMm9dsKNi11fTbiM_h2iDtl8ySCaVcxlalEzq8,7131
|
| 396 |
+
pip/_vendor/rich/console.py,sha256=pDvkbLkvtZIMIwQx_jkZ-seyNl4zGBLviXoWXte9fwg,99218
|
| 397 |
+
pip/_vendor/rich/constrain.py,sha256=1VIPuC8AgtKWrcncQrjBdYqA3JVWysu6jZo1rrh7c7Q,1288
|
| 398 |
+
pip/_vendor/rich/containers.py,sha256=aKgm5UDHn5Nmui6IJaKdsZhbHClh_X7D-_Wg8Ehrr7s,5497
|
| 399 |
+
pip/_vendor/rich/control.py,sha256=DSkHTUQLorfSERAKE_oTAEUFefZnZp4bQb4q8rHbKws,6630
|
| 400 |
+
pip/_vendor/rich/default_styles.py,sha256=-Fe318kMVI_IwciK5POpThcO0-9DYJ67TZAN6DlmlmM,8082
|
| 401 |
+
pip/_vendor/rich/diagnose.py,sha256=an6uouwhKPAlvQhYpNNpGq9EJysfMIOvvCbO3oSoR24,972
|
| 402 |
+
pip/_vendor/rich/emoji.py,sha256=omTF9asaAnsM4yLY94eR_9dgRRSm1lHUszX20D1yYCQ,2501
|
| 403 |
+
pip/_vendor/rich/errors.py,sha256=5pP3Kc5d4QJ_c0KFsxrfyhjiPVe7J1zOqSFbFAzcV-Y,642
|
| 404 |
+
pip/_vendor/rich/file_proxy.py,sha256=Tl9THMDZ-Pk5Wm8sI1gGg_U5DhusmxD-FZ0fUbcU0W0,1683
|
| 405 |
+
pip/_vendor/rich/filesize.py,sha256=9fTLAPCAwHmBXdRv7KZU194jSgNrRb6Wx7RIoBgqeKY,2508
|
| 406 |
+
pip/_vendor/rich/highlighter.py,sha256=p3C1g4QYzezFKdR7NF9EhPbzQDvdPUhGRgSyGGEmPko,9584
|
| 407 |
+
pip/_vendor/rich/json.py,sha256=EYp9ucj-nDjYDkHCV6Mk1ve8nUOpuFLaW76X50Mis2M,5032
|
| 408 |
+
pip/_vendor/rich/jupyter.py,sha256=QyoKoE_8IdCbrtiSHp9TsTSNyTHY0FO5whE7jOTd9UE,3252
|
| 409 |
+
pip/_vendor/rich/layout.py,sha256=RFYL6HdCFsHf9WRpcvi3w-fpj-8O5dMZ8W96VdKNdbI,14007
|
| 410 |
+
pip/_vendor/rich/live.py,sha256=vZzYvu7fqwlv3Gthl2xiw1Dc_O80VlGcCV0DOHwCyDM,14273
|
| 411 |
+
pip/_vendor/rich/live_render.py,sha256=zElm3PrfSIvjOce28zETHMIUf9pFYSUA5o0AflgUP64,3667
|
| 412 |
+
pip/_vendor/rich/logging.py,sha256=uB-cB-3Q4bmXDLLpbOWkmFviw-Fde39zyMV6tKJ2WHQ,11903
|
| 413 |
+
pip/_vendor/rich/markup.py,sha256=xzF4uAafiEeEYDJYt_vUnJOGoTU8RrH-PH7WcWYXjCg,8198
|
| 414 |
+
pip/_vendor/rich/measure.py,sha256=HmrIJX8sWRTHbgh8MxEay_83VkqNW_70s8aKP5ZcYI8,5305
|
| 415 |
+
pip/_vendor/rich/padding.py,sha256=kTFGsdGe0os7tXLnHKpwTI90CXEvrceeZGCshmJy5zw,4970
|
| 416 |
+
pip/_vendor/rich/pager.py,sha256=SO_ETBFKbg3n_AgOzXm41Sv36YxXAyI3_R-KOY2_uSc,828
|
| 417 |
+
pip/_vendor/rich/palette.py,sha256=lInvR1ODDT2f3UZMfL1grq7dY_pDdKHw4bdUgOGaM4Y,3396
|
| 418 |
+
pip/_vendor/rich/panel.py,sha256=wGMe40J8KCGgQoM0LyjRErmGIkv2bsYA71RCXThD0xE,10574
|
| 419 |
+
pip/_vendor/rich/pretty.py,sha256=eLEYN9xVaMNuA6EJVYm4li7HdOHxCqmVKvnOqJpyFt0,35852
|
| 420 |
+
pip/_vendor/rich/progress.py,sha256=n4KF9vky8_5iYeXcyZPEvzyLplWlDvFLkM5JI0Bs08A,59706
|
| 421 |
+
pip/_vendor/rich/progress_bar.py,sha256=cEoBfkc3lLwqba4XKsUpy4vSQKDh2QQ5J2J94-ACFoo,8165
|
| 422 |
+
pip/_vendor/rich/prompt.py,sha256=x0mW-pIPodJM4ry6grgmmLrl8VZp99kqcmdnBe70YYA,11303
|
| 423 |
+
pip/_vendor/rich/protocol.py,sha256=5hHHDDNHckdk8iWH5zEbi-zuIVSF5hbU2jIo47R7lTE,1391
|
| 424 |
+
pip/_vendor/rich/region.py,sha256=rNT9xZrVZTYIXZC0NYn41CJQwYNbR-KecPOxTgQvB8Y,166
|
| 425 |
+
pip/_vendor/rich/repr.py,sha256=9Z8otOmM-tyxnyTodvXlectP60lwahjGiDTrbrxPSTg,4431
|
| 426 |
+
pip/_vendor/rich/rule.py,sha256=0fNaS_aERa3UMRc3T5WMpN_sumtDxfaor2y3of1ftBk,4602
|
| 427 |
+
pip/_vendor/rich/scope.py,sha256=TMUU8qo17thyqQCPqjDLYpg_UU1k5qVd-WwiJvnJVas,2843
|
| 428 |
+
pip/_vendor/rich/screen.py,sha256=YoeReESUhx74grqb0mSSb9lghhysWmFHYhsbMVQjXO8,1591
|
| 429 |
+
pip/_vendor/rich/segment.py,sha256=XLnJEFvcV3bjaVzMNUJiem3n8lvvI9TJ5PTu-IG2uTg,24247
|
| 430 |
+
pip/_vendor/rich/spinner.py,sha256=15koCmF0DQeD8-k28Lpt6X_zJQUlzEhgo_6A6uy47lc,4339
|
| 431 |
+
pip/_vendor/rich/status.py,sha256=gJsIXIZeSo3urOyxRUjs6VrhX5CZrA0NxIQ-dxhCnwo,4425
|
| 432 |
+
pip/_vendor/rich/style.py,sha256=3hiocH_4N8vwRm3-8yFWzM7tSwjjEven69XqWasSQwM,27073
|
| 433 |
+
pip/_vendor/rich/styled.py,sha256=eZNnzGrI4ki_54pgY3Oj0T-x3lxdXTYh4_ryDB24wBU,1258
|
| 434 |
+
pip/_vendor/rich/syntax.py,sha256=jgDiVCK6cpR0NmBOpZmIu-Ud4eaW7fHvjJZkDbjpcSA,35173
|
| 435 |
+
pip/_vendor/rich/table.py,sha256=-WzesL-VJKsaiDU3uyczpJMHy6VCaSewBYJwx8RudI8,39684
|
| 436 |
+
pip/_vendor/rich/terminal_theme.py,sha256=1j5-ufJfnvlAo5Qsi_ACZiXDmwMXzqgmFByObT9-yJY,3370
|
| 437 |
+
pip/_vendor/rich/text.py,sha256=_8JBlSau0c2z8ENOZMi1hJ7M1ZGY408E4-hXjHyyg1A,45525
|
| 438 |
+
pip/_vendor/rich/theme.py,sha256=belFJogzA0W0HysQabKaHOc3RWH2ko3fQAJhoN-AFdo,3777
|
| 439 |
+
pip/_vendor/rich/themes.py,sha256=0xgTLozfabebYtcJtDdC5QkX5IVUEaviqDUJJh4YVFk,102
|
| 440 |
+
pip/_vendor/rich/traceback.py,sha256=yCLVrCtyoFNENd9mkm2xeG3KmqkTwH9xpFOO7p2Bq0A,29604
|
| 441 |
+
pip/_vendor/rich/tree.py,sha256=BMbUYNjS9uodNPfvtY_odmU09GA5QzcMbQ5cJZhllQI,9169
|
| 442 |
+
pip/_vendor/tenacity/__init__.py,sha256=3kvAL6KClq8GFo2KFhmOzskRKSDQI-ubrlfZ8AQEEI0,20493
|
| 443 |
+
pip/_vendor/tenacity/_asyncio.py,sha256=Qi6wgQsGa9MQibYRy3OXqcDQswIZZ00dLOoSUGN-6o8,3551
|
| 444 |
+
pip/_vendor/tenacity/_utils.py,sha256=ubs6a7sxj3JDNRKWCyCU2j5r1CB7rgyONgZzYZq6D_4,2179
|
| 445 |
+
pip/_vendor/tenacity/after.py,sha256=S5NCISScPeIrKwIeXRwdJl3kV9Q4nqZfnNPDx6Hf__g,1682
|
| 446 |
+
pip/_vendor/tenacity/before.py,sha256=dIZE9gmBTffisfwNkK0F1xFwGPV41u5GK70UY4Pi5Kc,1562
|
| 447 |
+
pip/_vendor/tenacity/before_sleep.py,sha256=YmpgN9Y7HGlH97U24vvq_YWb5deaK4_DbiD8ZuFmy-E,2372
|
| 448 |
+
pip/_vendor/tenacity/nap.py,sha256=fRWvnz1aIzbIq9Ap3gAkAZgDH6oo5zxMrU6ZOVByq0I,1383
|
| 449 |
+
pip/_vendor/tenacity/retry.py,sha256=jrzD_mxA5mSTUEdiYB7SHpxltjhPSYZSnSRATb-ggRc,8746
|
| 450 |
+
pip/_vendor/tenacity/stop.py,sha256=YMJs7ZgZfND65PRLqlGB_agpfGXlemx_5Hm4PKnBqpQ,3086
|
| 451 |
+
pip/_vendor/tenacity/tornadoweb.py,sha256=po29_F1Mt8qZpsFjX7EVwAT0ydC_NbVia9gVi7R_wXA,2142
|
| 452 |
+
pip/_vendor/tenacity/wait.py,sha256=3FcBJoCDgym12_dN6xfK8C1gROY0Hn4NSI2u8xv50uE,8024
|
| 453 |
+
pip/_vendor/tomli/__init__.py,sha256=JhUwV66DB1g4Hvt1UQCVMdfCu-IgAV8FXmvDU9onxd4,396
|
| 454 |
+
pip/_vendor/tomli/_parser.py,sha256=g9-ENaALS-B8dokYpCuzUFalWlog7T-SIYMjLZSWrtM,22633
|
| 455 |
+
pip/_vendor/tomli/_re.py,sha256=dbjg5ChZT23Ka9z9DHOXfdtSpPwUfdgMXnj8NOoly-w,2943
|
| 456 |
+
pip/_vendor/tomli/_types.py,sha256=-GTG2VUqkpxwMqzmVO4F7ybKddIbAnuAHXfmWQcTi3Q,254
|
| 457 |
+
pip/_vendor/urllib3/__init__.py,sha256=iXLcYiJySn0GNbWOOZDDApgBL1JgP44EZ8i1760S8Mc,3333
|
| 458 |
+
pip/_vendor/urllib3/_collections.py,sha256=Rp1mVyBgc_UlAcp6M3at1skJBXR5J43NawRTvW2g_XY,10811
|
| 459 |
+
pip/_vendor/urllib3/_version.py,sha256=6zoYnDykPLfe92fHqXalH8SxhWVl31yYLCP0lDri_SA,64
|
| 460 |
+
pip/_vendor/urllib3/connection.py,sha256=92k9td_y4PEiTIjNufCUa1NzMB3J3w0LEdyokYgXnW8,20300
|
| 461 |
+
pip/_vendor/urllib3/connectionpool.py,sha256=ItVDasDnPRPP9R8bNxY7tPBlC724nJ9nlxVgXG_SLbI,39990
|
| 462 |
+
pip/_vendor/urllib3/exceptions.py,sha256=0Mnno3KHTNfXRfY7638NufOPkUb6mXOm-Lqj-4x2w8A,8217
|
| 463 |
+
pip/_vendor/urllib3/fields.py,sha256=kvLDCg_JmH1lLjUUEY_FLS8UhY7hBvDPuVETbY8mdrM,8579
|
| 464 |
+
pip/_vendor/urllib3/filepost.py,sha256=5b_qqgRHVlL7uLtdAYBzBh-GHmU5AfJVt_2N0XS3PeY,2440
|
| 465 |
+
pip/_vendor/urllib3/poolmanager.py,sha256=0i8cJgrqupza67IBPZ_u9jXvnSxr5UBlVEiUqdkPtYI,19752
|
| 466 |
+
pip/_vendor/urllib3/request.py,sha256=ZFSIqX0C6WizixecChZ3_okyu7BEv0lZu1VT0s6h4SM,5985
|
| 467 |
+
pip/_vendor/urllib3/response.py,sha256=fmDJAFkG71uFTn-sVSTh2Iw0WmcXQYqkbRjihvwBjU8,30641
|
| 468 |
+
pip/_vendor/urllib3/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 469 |
+
pip/_vendor/urllib3/contrib/_appengine_environ.py,sha256=bDbyOEhW2CKLJcQqAKAyrEHN-aklsyHFKq6vF8ZFsmk,957
|
| 470 |
+
pip/_vendor/urllib3/contrib/appengine.py,sha256=VR68eAVE137lxTgjBDwCna5UiBZTOKa01Aj_-5BaCz4,11036
|
| 471 |
+
pip/_vendor/urllib3/contrib/ntlmpool.py,sha256=NlfkW7WMdW8ziqudopjHoW299og1BTWi0IeIibquFwk,4528
|
| 472 |
+
pip/_vendor/urllib3/contrib/pyopenssl.py,sha256=hDJh4MhyY_p-oKlFcYcQaVQRDv6GMmBGuW9yjxyeejM,17081
|
| 473 |
+
pip/_vendor/urllib3/contrib/securetransport.py,sha256=yhZdmVjY6PI6EeFbp7qYOp6-vp1Rkv2NMuOGaEj7pmc,34448
|
| 474 |
+
pip/_vendor/urllib3/contrib/socks.py,sha256=aRi9eWXo9ZEb95XUxef4Z21CFlnnjbEiAo9HOseoMt4,7097
|
| 475 |
+
pip/_vendor/urllib3/contrib/_securetransport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 476 |
+
pip/_vendor/urllib3/contrib/_securetransport/bindings.py,sha256=4Xk64qIkPBt09A5q-RIFUuDhNc9mXilVapm7WnYnzRw,17632
|
| 477 |
+
pip/_vendor/urllib3/contrib/_securetransport/low_level.py,sha256=B2JBB2_NRP02xK6DCa1Pa9IuxrPwxzDzZbixQkb7U9M,13922
|
| 478 |
+
pip/_vendor/urllib3/packages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 479 |
+
pip/_vendor/urllib3/packages/six.py,sha256=b9LM0wBXv7E7SrbCjAm4wwN-hrH-iNxv18LgWNMMKPo,34665
|
| 480 |
+
pip/_vendor/urllib3/packages/backports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 481 |
+
pip/_vendor/urllib3/packages/backports/makefile.py,sha256=nbzt3i0agPVP07jqqgjhaYjMmuAi_W5E0EywZivVO8E,1417
|
| 482 |
+
pip/_vendor/urllib3/packages/backports/weakref_finalize.py,sha256=tRCal5OAhNSRyb0DhHp-38AtIlCsRP8BxF3NX-6rqIA,5343
|
| 483 |
+
pip/_vendor/urllib3/util/__init__.py,sha256=JEmSmmqqLyaw8P51gUImZh8Gwg9i1zSe-DoqAitn2nc,1155
|
| 484 |
+
pip/_vendor/urllib3/util/connection.py,sha256=5Lx2B1PW29KxBn2T0xkN1CBgRBa3gGVJBKoQoRogEVk,4901
|
| 485 |
+
pip/_vendor/urllib3/util/proxy.py,sha256=zUvPPCJrp6dOF0N4GAVbOcl6o-4uXKSrGiTkkr5vUS4,1605
|
| 486 |
+
pip/_vendor/urllib3/util/queue.py,sha256=nRgX8_eX-_VkvxoX096QWoz8Ps0QHUAExILCY_7PncM,498
|
| 487 |
+
pip/_vendor/urllib3/util/request.py,sha256=C0OUt2tcU6LRiQJ7YYNP9GvPrSvl7ziIBekQ-5nlBZk,3997
|
| 488 |
+
pip/_vendor/urllib3/util/response.py,sha256=GJpg3Egi9qaJXRwBh5wv-MNuRWan5BIu40oReoxWP28,3510
|
| 489 |
+
pip/_vendor/urllib3/util/retry.py,sha256=4laWh0HpwGijLiBmdBIYtbhYekQnNzzhx2W9uys0RHA,22003
|
| 490 |
+
pip/_vendor/urllib3/util/ssl_.py,sha256=X4-AqW91aYPhPx6-xbf66yHFQKbqqfC_5Zt4WkLX1Hc,17177
|
| 491 |
+
pip/_vendor/urllib3/util/ssl_match_hostname.py,sha256=Ir4cZVEjmAk8gUAIHWSi7wtOO83UCYABY2xFD1Ql_WA,5758
|
| 492 |
+
pip/_vendor/urllib3/util/ssltransport.py,sha256=NA-u5rMTrDFDFC8QzRKUEKMG0561hOD4qBTr3Z4pv6E,6895
|
| 493 |
+
pip/_vendor/urllib3/util/timeout.py,sha256=cwq4dMk87mJHSBktK1miYJ-85G-3T3RmT20v7SFCpno,10168
|
| 494 |
+
pip/_vendor/urllib3/util/url.py,sha256=lCAE7M5myA8EDdW0sJuyyZhVB9K_j38ljWhHAnFaWoE,14296
|
| 495 |
+
pip/_vendor/urllib3/util/wait.py,sha256=fOX0_faozG2P7iVojQoE1mbydweNyTcm-hXEfFrTtLI,5403
|
| 496 |
+
pip/_vendor/webencodings/__init__.py,sha256=qOBJIuPy_4ByYH6W_bNgJF-qYQ2DoU-dKsDu5yRWCXg,10579
|
| 497 |
+
pip/_vendor/webencodings/labels.py,sha256=4AO_KxTddqGtrL9ns7kAPjb0CcN6xsCIxbK37HY9r3E,8979
|
| 498 |
+
pip/_vendor/webencodings/mklabels.py,sha256=GYIeywnpaLnP0GSic8LFWgd0UVvO_l1Nc6YoF-87R_4,1305
|
| 499 |
+
pip/_vendor/webencodings/tests.py,sha256=OtGLyjhNY1fvkW1GvLJ_FV9ZoqC9Anyjr7q3kxTbzNs,6563
|
| 500 |
+
pip/_vendor/webencodings/x_user_defined.py,sha256=yOqWSdmpytGfUgh_Z6JYgDNhoc-BAHyyeeT15Fr42tM,4307
|
| 501 |
+
pip-23.2.1.dist-info/AUTHORS.txt,sha256=Pd_qYtjluu4WDft2A179dPtIvwYVBNtDfccCitVRMQM,10082
|
| 502 |
+
pip-23.2.1.dist-info/LICENSE.txt,sha256=Y0MApmnUmurmWxLGxIySTFGkzfPR_whtw0VtyLyqIQQ,1093
|
| 503 |
+
pip-23.2.1.dist-info/METADATA,sha256=yHPLQvsD1b6f-zdCQWMibZXbsAjs886JMSh3C0oxRhQ,4239
|
| 504 |
+
pip-23.2.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
| 505 |
+
pip-23.2.1.dist-info/entry_points.txt,sha256=xg35gOct0aY8S3ftLtweJ0uw3KBAIVyW4k-0Jx1rkNE,125
|
| 506 |
+
pip-23.2.1.dist-info/top_level.txt,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 507 |
+
pip-23.2.1.dist-info/RECORD,,
|
| 508 |
+
pip\_vendor\requests\api.cpython-310.pyc,,
|
| 509 |
+
pip\_vendor\idna\__pycache__,,
|
| 510 |
+
pip\_internal\operations\install\__pycache__,,
|
| 511 |
+
pip\_internal\utils\__init__.cpython-310.pyc,,
|
| 512 |
+
pip\_vendor\chardet\euckrfreq.cpython-310.pyc,,
|
| 513 |
+
pip\_vendor\rich\live_render.cpython-310.pyc,,
|
| 514 |
+
pip\_vendor\rich\_export_format.cpython-310.pyc,,
|
| 515 |
+
pip\_vendor\rich\styled.cpython-310.pyc,,
|
| 516 |
+
pip\_vendor\pygments\formatters\groff.cpython-310.pyc,,
|
| 517 |
+
pip\_vendor\cachecontrol\wrapper.cpython-310.pyc,,
|
| 518 |
+
pip\_vendor\cachecontrol\caches\__pycache__,,
|
| 519 |
+
pip\_vendor\urllib3\packages\backports\weakref_finalize.cpython-310.pyc,,
|
| 520 |
+
pip\_internal\utils\_jaraco_text.cpython-310.pyc,,
|
| 521 |
+
pip\_vendor\cachecontrol\cache.cpython-310.pyc,,
|
| 522 |
+
pip\_vendor\pyparsing\util.cpython-310.pyc,,
|
| 523 |
+
pip\_vendor\platformdirs\macos.cpython-310.pyc,,
|
| 524 |
+
pip\_internal\operations\check.cpython-310.pyc,,
|
| 525 |
+
pip\_vendor\rich\progress_bar.cpython-310.pyc,,
|
| 526 |
+
pip\_vendor\rich\box.cpython-310.pyc,,
|
| 527 |
+
pip\_vendor\requests\help.cpython-310.pyc,,
|
| 528 |
+
pip\_vendor\rich\status.cpython-310.pyc,,
|
| 529 |
+
pip\_vendor\pyparsing\testing.cpython-310.pyc,,
|
| 530 |
+
pip\_vendor\rich\default_styles.cpython-310.pyc,,
|
| 531 |
+
pip\_vendor\urllib3\util\queue.cpython-310.pyc,,
|
| 532 |
+
pip\_internal\commands\debug.cpython-310.pyc,,
|
| 533 |
+
pip\_vendor\urllib3\util\retry.cpython-310.pyc,,
|
| 534 |
+
pip\__init__.cpython-310.pyc,,
|
| 535 |
+
pip\_vendor\distlib\scripts.cpython-310.pyc,,
|
| 536 |
+
pip\_vendor\platformdirs\unix.cpython-310.pyc,,
|
| 537 |
+
pip\_vendor\rich\color.cpython-310.pyc,,
|
| 538 |
+
pip\_vendor\distlib\manifest.cpython-310.pyc,,
|
| 539 |
+
pip\_internal\models\format_control.cpython-310.pyc,,
|
| 540 |
+
..\..\Scripts\pip3.exe,,
|
| 541 |
+
pip\_vendor\requests\cookies.cpython-310.pyc,,
|
| 542 |
+
pip\_vendor\packaging\_structures.cpython-310.pyc,,
|
| 543 |
+
pip\_internal\cli\progress_bars.cpython-310.pyc,,
|
| 544 |
+
pip\_internal\utils\inject_securetransport.cpython-310.pyc,,
|
| 545 |
+
pip\_vendor\urllib3\response.cpython-310.pyc,,
|
| 546 |
+
pip\_internal\metadata\importlib\_compat.cpython-310.pyc,,
|
| 547 |
+
pip\_vendor\colorama\initialise.cpython-310.pyc,,
|
| 548 |
+
pip\_vendor\rich\protocol.cpython-310.pyc,,
|
| 549 |
+
pip\_vendor\rich\_emoji_codes.cpython-310.pyc,,
|
| 550 |
+
pip\_internal\commands\list.cpython-310.pyc,,
|
| 551 |
+
pip\_vendor\pygments\lexers\_mapping.cpython-310.pyc,,
|
| 552 |
+
pip\_vendor\urllib3\_collections.cpython-310.pyc,,
|
| 553 |
+
pip\_vendor\urllib3\request.cpython-310.pyc,,
|
| 554 |
+
pip\_vendor\urllib3\util\response.cpython-310.pyc,,
|
| 555 |
+
pip\_vendor\tenacity\before_sleep.cpython-310.pyc,,
|
| 556 |
+
pip\_internal\cli\spinners.cpython-310.pyc,,
|
| 557 |
+
pip\_vendor\urllib3\contrib\__pycache__,,
|
| 558 |
+
pip\_vendor\urllib3\util\request.cpython-310.pyc,,
|
| 559 |
+
pip\_vendor\distlib\compat.cpython-310.pyc,,
|
| 560 |
+
pip\_vendor\chardet\langbulgarianmodel.cpython-310.pyc,,
|
| 561 |
+
pip\_vendor\packaging\__init__.cpython-310.pyc,,
|
| 562 |
+
pip\_vendor\pygments\style.cpython-310.pyc,,
|
| 563 |
+
pip\_vendor\__pycache__,,
|
| 564 |
+
pip\_vendor\rich\__main__.cpython-310.pyc,,
|
| 565 |
+
pip\_internal\resolution\resolvelib\candidates.cpython-310.pyc,,
|
| 566 |
+
pip\_vendor\urllib3\util\proxy.cpython-310.pyc,,
|
| 567 |
+
pip\_vendor\pyproject_hooks\__init__.cpython-310.pyc,,
|
| 568 |
+
pip\_internal\utils\deprecation.cpython-310.pyc,,
|
| 569 |
+
pip\_vendor\pygments\formatters\irc.cpython-310.pyc,,
|
| 570 |
+
pip\_internal\__pycache__,,
|
| 571 |
+
pip\_vendor\rich\diagnose.cpython-310.pyc,,
|
| 572 |
+
pip\_internal\commands\uninstall.cpython-310.pyc,,
|
| 573 |
+
pip\_vendor\rich\text.cpython-310.pyc,,
|
| 574 |
+
pip\_vendor\chardet\codingstatemachinedict.cpython-310.pyc,,
|
| 575 |
+
pip\_internal\resolution\resolvelib\found_candidates.cpython-310.pyc,,
|
| 576 |
+
pip\_vendor\pygments\formatters\pangomarkup.cpython-310.pyc,,
|
| 577 |
+
pip\_internal\utils\appdirs.cpython-310.pyc,,
|
| 578 |
+
pip\_internal\utils\glibc.cpython-310.pyc,,
|
| 579 |
+
pip\_vendor\tomli\__init__.cpython-310.pyc,,
|
| 580 |
+
pip\_vendor\tenacity\wait.cpython-310.pyc,,
|
| 581 |
+
pip\_internal\vcs\mercurial.cpython-310.pyc,,
|
| 582 |
+
pip\_vendor\colorama\tests\__pycache__,,
|
| 583 |
+
pip\_vendor\tomli\_re.cpython-310.pyc,,
|
| 584 |
+
pip\_vendor\colorama\win32.cpython-310.pyc,,
|
| 585 |
+
pip\_vendor\cachecontrol\serialize.cpython-310.pyc,,
|
| 586 |
+
pip\_vendor\requests\compat.cpython-310.pyc,,
|
| 587 |
+
pip\_vendor\rich\json.cpython-310.pyc,,
|
| 588 |
+
pip\_vendor\urllib3\_version.cpython-310.pyc,,
|
| 589 |
+
pip\_vendor\chardet\langhungarianmodel.cpython-310.pyc,,
|
| 590 |
+
pip\_vendor\rich\markup.cpython-310.pyc,,
|
| 591 |
+
pip\_vendor\rich\region.cpython-310.pyc,,
|
| 592 |
+
pip\_vendor\chardet\utf8prober.cpython-310.pyc,,
|
| 593 |
+
pip\_vendor\packaging\specifiers.cpython-310.pyc,,
|
| 594 |
+
pip\_vendor\pygments\unistring.cpython-310.pyc,,
|
| 595 |
+
pip\_internal\utils\hashes.cpython-310.pyc,,
|
| 596 |
+
pip\_internal\metadata\__pycache__,,
|
| 597 |
+
pip\_vendor\packaging\markers.cpython-310.pyc,,
|
| 598 |
+
pip\_internal\locations\__pycache__,,
|
| 599 |
+
pip\_internal\self_outdated_check.cpython-310.pyc,,
|
| 600 |
+
pip\_internal\metadata\importlib\_dists.cpython-310.pyc,,
|
| 601 |
+
pip\_vendor\cachecontrol\caches\redis_cache.cpython-310.pyc,,
|
| 602 |
+
pip\_internal\network\session.cpython-310.pyc,,
|
| 603 |
+
pip\_vendor\cachecontrol\compat.cpython-310.pyc,,
|
| 604 |
+
pip\_internal\models\direct_url.cpython-310.pyc,,
|
| 605 |
+
pip\_vendor\chardet\johabprober.cpython-310.pyc,,
|
| 606 |
+
pip\_vendor\chardet\macromanprober.cpython-310.pyc,,
|
| 607 |
+
pip\_internal\distributions\installed.cpython-310.pyc,,
|
| 608 |
+
pip\_internal\utils\unpacking.cpython-310.pyc,,
|
| 609 |
+
pip\_internal\main.cpython-310.pyc,,
|
| 610 |
+
pip\_vendor\pygments\__pycache__,,
|
| 611 |
+
pip\_vendor\colorama\winterm.cpython-310.pyc,,
|
| 612 |
+
pip\_vendor\packaging\requirements.cpython-310.pyc,,
|
| 613 |
+
pip\_vendor\rich\style.cpython-310.pyc,,
|
| 614 |
+
pip\_internal\cli\parser.cpython-310.pyc,,
|
| 615 |
+
pip\_internal\models\scheme.cpython-310.pyc,,
|
| 616 |
+
..\..\Scripts\pip3.10.exe,,
|
| 617 |
+
pip\_vendor\rich\terminal_theme.cpython-310.pyc,,
|
| 618 |
+
pip\_vendor\urllib3\__pycache__,,
|
| 619 |
+
pip\_vendor\idna\intranges.cpython-310.pyc,,
|
| 620 |
+
pip\__main__.cpython-310.pyc,,
|
| 621 |
+
pip\_internal\commands\download.cpython-310.pyc,,
|
| 622 |
+
pip\_internal\operations\build\wheel_legacy.cpython-310.pyc,,
|
| 623 |
+
pip\_internal\distributions\sdist.cpython-310.pyc,,
|
| 624 |
+
pip\_vendor\distlib\__pycache__,,
|
| 625 |
+
pip\_vendor\rich\syntax.cpython-310.pyc,,
|
| 626 |
+
pip\_vendor\distro\__main__.cpython-310.pyc,,
|
| 627 |
+
pip\_vendor\typing_extensions.cpython-310.pyc,,
|
| 628 |
+
pip\_internal\metadata\importlib\__pycache__,,
|
| 629 |
+
pip\_vendor\colorama\__pycache__,,
|
| 630 |
+
pip\_vendor\urllib3\packages\__pycache__,,
|
| 631 |
+
pip\_vendor\pygments\formatters\terminal.cpython-310.pyc,,
|
| 632 |
+
pip\_vendor\rich\progress.cpython-310.pyc,,
|
| 633 |
+
pip\_internal\network\__pycache__,,
|
| 634 |
+
pip\_internal\utils\subprocess.cpython-310.pyc,,
|
| 635 |
+
pip\_internal\operations\prepare.cpython-310.pyc,,
|
| 636 |
+
pip\_vendor\chardet\langthaimodel.cpython-310.pyc,,
|
| 637 |
+
pip\_vendor\rich\repr.cpython-310.pyc,,
|
| 638 |
+
pip\_internal\cli\base_command.cpython-310.pyc,,
|
| 639 |
+
pip\_vendor\urllib3\util\__pycache__,,
|
| 640 |
+
pip\_internal\utils\compat.cpython-310.pyc,,
|
| 641 |
+
pip\_vendor\rich\constrain.cpython-310.pyc,,
|
| 642 |
+
pip\_vendor\tomli\_parser.cpython-310.pyc,,
|
| 643 |
+
pip\_vendor\colorama\tests\initialise_test.cpython-310.pyc,,
|
| 644 |
+
pip\_vendor\certifi\__init__.cpython-310.pyc,,
|
| 645 |
+
pip\_vendor\tenacity\__init__.cpython-310.pyc,,
|
| 646 |
+
pip\_vendor\packaging\_manylinux.cpython-310.pyc,,
|
| 647 |
+
pip\_internal\pyproject.cpython-310.pyc,,
|
| 648 |
+
pip\_vendor\requests\models.cpython-310.pyc,,
|
| 649 |
+
pip\_internal\req\req_uninstall.cpython-310.pyc,,
|
| 650 |
+
pip\_vendor\pyparsing\exceptions.cpython-310.pyc,,
|
| 651 |
+
pip\_internal\operations\build\__init__.cpython-310.pyc,,
|
| 652 |
+
pip\_vendor\msgpack\__pycache__,,
|
| 653 |
+
pip\_vendor\chardet\escprober.cpython-310.pyc,,
|
| 654 |
+
pip\_vendor\chardet\gb2312prober.cpython-310.pyc,,
|
| 655 |
+
pip\_internal\models\wheel.cpython-310.pyc,,
|
| 656 |
+
pip\_vendor\requests\__pycache__,,
|
| 657 |
+
pip\_vendor\cachecontrol\_cmd.cpython-310.pyc,,
|
| 658 |
+
pip\_vendor\rich\__pycache__,,
|
| 659 |
+
pip\_internal\build_env.cpython-310.pyc,,
|
| 660 |
+
pip\_vendor\pyparsing\helpers.cpython-310.pyc,,
|
| 661 |
+
pip\_vendor\requests\sessions.cpython-310.pyc,,
|
| 662 |
+
pip\_internal\resolution\legacy\__init__.cpython-310.pyc,,
|
| 663 |
+
pip\_internal\index\collector.cpython-310.pyc,,
|
| 664 |
+
pip\_vendor\chardet\version.cpython-310.pyc,,
|
| 665 |
+
pip\_vendor\rich\_win32_console.cpython-310.pyc,,
|
| 666 |
+
pip\_vendor\rich\_fileno.cpython-310.pyc,,
|
| 667 |
+
pip\_vendor\rich\_pick.cpython-310.pyc,,
|
| 668 |
+
pip\_vendor\colorama\ansi.cpython-310.pyc,,
|
| 669 |
+
pip\_internal\operations\build\metadata.cpython-310.pyc,,
|
| 670 |
+
pip\_vendor\cachecontrol\__pycache__,,
|
| 671 |
+
pip\_internal\operations\__init__.cpython-310.pyc,,
|
| 672 |
+
pip\_vendor\chardet\cli\chardetect.cpython-310.pyc,,
|
| 673 |
+
pip\_vendor\pygments\filters\__init__.cpython-310.pyc,,
|
| 674 |
+
pip\_vendor\cachecontrol\caches\file_cache.cpython-310.pyc,,
|
| 675 |
+
pip\_vendor\requests\status_codes.cpython-310.pyc,,
|
| 676 |
+
pip\_internal\utils\compatibility_tags.cpython-310.pyc,,
|
| 677 |
+
pip\_vendor\resolvelib\__pycache__,,
|
| 678 |
+
pip\_internal\resolution\__pycache__,,
|
| 679 |
+
pip\_vendor\pyparsing\unicode.cpython-310.pyc,,
|
| 680 |
+
pip\_vendor\chardet\johabfreq.cpython-310.pyc,,
|
| 681 |
+
pip\_vendor\rich\_stack.cpython-310.pyc,,
|
| 682 |
+
pip\_internal\utils\temp_dir.cpython-310.pyc,,
|
| 683 |
+
pip\_vendor\rich\_log_render.cpython-310.pyc,,
|
| 684 |
+
pip\_vendor\rich\emoji.cpython-310.pyc,,
|
| 685 |
+
pip\_vendor\tenacity\_asyncio.cpython-310.pyc,,
|
| 686 |
+
pip\_internal\index\__pycache__,,
|
| 687 |
+
pip\_vendor\chardet\cp949prober.cpython-310.pyc,,
|
| 688 |
+
pip\_vendor\colorama\tests\ansitowin32_test.cpython-310.pyc,,
|
| 689 |
+
pip\_internal\utils\models.cpython-310.pyc,,
|
| 690 |
+
pip\_vendor\idna\__init__.cpython-310.pyc,,
|
| 691 |
+
pip\_internal\distributions\wheel.cpython-310.pyc,,
|
| 692 |
+
pip\_internal\operations\install\__init__.cpython-310.pyc,,
|
| 693 |
+
pip\_vendor\chardet\metadata\__pycache__,,
|
| 694 |
+
pip\_vendor\rich\_loop.cpython-310.pyc,,
|
| 695 |
+
pip\_vendor\rich\cells.cpython-310.pyc,,
|
| 696 |
+
pip\_internal\wheel_builder.cpython-310.pyc,,
|
| 697 |
+
pip\_vendor\pygments\modeline.cpython-310.pyc,,
|
| 698 |
+
pip\_internal\commands\check.cpython-310.pyc,,
|
| 699 |
+
pip\_internal\commands\install.cpython-310.pyc,,
|
| 700 |
+
pip\_internal\req\__pycache__,,
|
| 701 |
+
pip\_internal\utils\__pycache__,,
|
| 702 |
+
pip\_vendor\pyparsing\core.cpython-310.pyc,,
|
| 703 |
+
pip\_vendor\chardet\langgreekmodel.cpython-310.pyc,,
|
| 704 |
+
pip\_vendor\chardet\resultdict.cpython-310.pyc,,
|
| 705 |
+
pip\_vendor\platformdirs\windows.cpython-310.pyc,,
|
| 706 |
+
pip\_vendor\rich\ansi.cpython-310.pyc,,
|
| 707 |
+
pip\_vendor\pygments\scanner.cpython-310.pyc,,
|
| 708 |
+
pip\_vendor\urllib3\util\ssl_.cpython-310.pyc,,
|
| 709 |
+
pip\_internal\network\auth.cpython-310.pyc,,
|
| 710 |
+
pip\_vendor\platformdirs\__main__.cpython-310.pyc,,
|
| 711 |
+
pip\_internal\utils\direct_url_helpers.cpython-310.pyc,,
|
| 712 |
+
pip\_vendor\rich\errors.cpython-310.pyc,,
|
| 713 |
+
pip\_internal\operations\install\editable_legacy.cpython-310.pyc,,
|
| 714 |
+
pip\_vendor\platformdirs\android.cpython-310.pyc,,
|
| 715 |
+
pip\_internal\utils\misc.cpython-310.pyc,,
|
| 716 |
+
pip-23.2.1.dist-info\__pycache__,,
|
| 717 |
+
pip\_vendor\resolvelib\resolvers.cpython-310.pyc,,
|
| 718 |
+
pip\_internal\models\index.cpython-310.pyc,,
|
| 719 |
+
pip\_vendor\chardet\chardistribution.cpython-310.pyc,,
|
| 720 |
+
pip\_vendor\rich\table.cpython-310.pyc,,
|
| 721 |
+
pip\_internal\vcs\subversion.cpython-310.pyc,,
|
| 722 |
+
pip\_vendor\urllib3\contrib\_securetransport\__pycache__,,
|
| 723 |
+
pip\_internal\commands\completion.cpython-310.pyc,,
|
| 724 |
+
pip\_vendor\pyproject_hooks\_in_process\__pycache__,,
|
| 725 |
+
pip\_internal\models\__pycache__,,
|
| 726 |
+
pip\_vendor\distro\__pycache__,,
|
| 727 |
+
pip\_vendor\pygments\token.cpython-310.pyc,,
|
| 728 |
+
pip\_vendor\rich\_timer.cpython-310.pyc,,
|
| 729 |
+
pip\_vendor\chardet\euckrprober.cpython-310.pyc,,
|
| 730 |
+
pip\_vendor\chardet\gb2312freq.cpython-310.pyc,,
|
| 731 |
+
pip\_internal\vcs\bazaar.cpython-310.pyc,,
|
| 732 |
+
pip\_internal\utils\egg_link.cpython-310.pyc,,
|
| 733 |
+
pip\_vendor\pygments\lexers\__pycache__,,
|
| 734 |
+
pip\_vendor\urllib3\util\timeout.cpython-310.pyc,,
|
| 735 |
+
pip\_internal\cli\__init__.cpython-310.pyc,,
|
| 736 |
+
pip\_vendor\pyparsing\actions.cpython-310.pyc,,
|
| 737 |
+
pip\_internal\metadata\pkg_resources.cpython-310.pyc,,
|
| 738 |
+
pip\_vendor\distlib\wheel.cpython-310.pyc,,
|
| 739 |
+
pip\_vendor\webencodings\mklabels.cpython-310.pyc,,
|
| 740 |
+
pip\_vendor\chardet\metadata\languages.cpython-310.pyc,,
|
| 741 |
+
pip\_vendor\pyproject_hooks\_in_process\_in_process.cpython-310.pyc,,
|
| 742 |
+
pip\_vendor\resolvelib\structs.cpython-310.pyc,,
|
| 743 |
+
pip\_vendor\chardet\eucjpprober.cpython-310.pyc,,
|
| 744 |
+
pip\_vendor\rich\live.cpython-310.pyc,,
|
| 745 |
+
pip\_vendor\certifi\__main__.cpython-310.pyc,,
|
| 746 |
+
pip\_vendor\pygments\formatters\__init__.cpython-310.pyc,,
|
| 747 |
+
pip\_vendor\rich\_wrap.cpython-310.pyc,,
|
| 748 |
+
pip\_vendor\urllib3\contrib\__init__.cpython-310.pyc,,
|
| 749 |
+
pip\_vendor\pkg_resources\__pycache__,,
|
| 750 |
+
pip\_vendor\tenacity\before.cpython-310.pyc,,
|
| 751 |
+
pip\_internal\utils\entrypoints.cpython-310.pyc,,
|
| 752 |
+
pip\_vendor\rich\_emoji_replace.cpython-310.pyc,,
|
| 753 |
+
pip-23.2.1.virtualenv,,
|
| 754 |
+
pip\_vendor\webencodings\tests.cpython-310.pyc,,
|
| 755 |
+
pip\_internal\locations\_sysconfig.cpython-310.pyc,,
|
| 756 |
+
pip\_internal\distributions\__pycache__,,
|
| 757 |
+
pip\_internal\cli\autocompletion.cpython-310.pyc,,
|
| 758 |
+
pip-23.2.1.dist-info\INSTALLER,,
|
| 759 |
+
pip\_vendor\urllib3\contrib\pyopenssl.cpython-310.pyc,,
|
| 760 |
+
pip\_vendor\chardet\__init__.cpython-310.pyc,,
|
| 761 |
+
pip\_vendor\rich\palette.cpython-310.pyc,,
|
| 762 |
+
pip\_vendor\chardet\enums.cpython-310.pyc,,
|
| 763 |
+
pip\_internal\__init__.cpython-310.pyc,,
|
| 764 |
+
pip\_internal\models\target_python.cpython-310.pyc,,
|
| 765 |
+
pip\_internal\network\download.cpython-310.pyc,,
|
| 766 |
+
pip\_vendor\rich\segment.cpython-310.pyc,,
|
| 767 |
+
pip\_vendor\rich\layout.cpython-310.pyc,,
|
| 768 |
+
pip\_vendor\rich\padding.cpython-310.pyc,,
|
| 769 |
+
pip\_internal\resolution\resolvelib\base.cpython-310.pyc,,
|
| 770 |
+
pip\_vendor\resolvelib\reporters.cpython-310.pyc,,
|
| 771 |
+
pip\_internal\commands\hash.cpython-310.pyc,,
|
| 772 |
+
pip\_vendor\rich\prompt.cpython-310.pyc,,
|
| 773 |
+
pip\_vendor\tomli\_types.cpython-310.pyc,,
|
| 774 |
+
pip\_vendor\pygments\formatters\svg.cpython-310.pyc,,
|
| 775 |
+
pip\_internal\operations\build\metadata_editable.cpython-310.pyc,,
|
| 776 |
+
pip\_vendor\urllib3\contrib\_appengine_environ.cpython-310.pyc,,
|
| 777 |
+
pip\_vendor\tenacity\tornadoweb.cpython-310.pyc,,
|
| 778 |
+
pip\_internal\cli\main_parser.cpython-310.pyc,,
|
| 779 |
+
pip\_internal\index\package_finder.cpython-310.pyc,,
|
| 780 |
+
pip\_vendor\pygments\styles\__init__.cpython-310.pyc,,
|
| 781 |
+
pip\_vendor\tomli\__pycache__,,
|
| 782 |
+
pip\_vendor\chardet\mbcsgroupprober.cpython-310.pyc,,
|
| 783 |
+
pip\_vendor\pygments\formatters\html.cpython-310.pyc,,
|
| 784 |
+
pip\_internal\metadata\__init__.cpython-310.pyc,,
|
| 785 |
+
pip\_internal\locations\__init__.cpython-310.pyc,,
|
| 786 |
+
pip\_vendor\packaging\__about__.cpython-310.pyc,,
|
| 787 |
+
pip\_internal\resolution\resolvelib\provider.cpython-310.pyc,,
|
| 788 |
+
pip\_internal\utils\setuptools_build.cpython-310.pyc,,
|
| 789 |
+
pip\_vendor\distlib\index.cpython-310.pyc,,
|
| 790 |
+
pip\_vendor\chardet\cli\__init__.cpython-310.pyc,,
|
| 791 |
+
pip\_vendor\requests\packages.cpython-310.pyc,,
|
| 792 |
+
pip\_vendor\pyparsing\diagram\__pycache__,,
|
| 793 |
+
pip\_internal\models\installation_report.cpython-310.pyc,,
|
| 794 |
+
pip\_vendor\packaging\_musllinux.cpython-310.pyc,,
|
| 795 |
+
pip\_vendor\cachecontrol\adapter.cpython-310.pyc,,
|
| 796 |
+
pip\_vendor\rich\bar.cpython-310.pyc,,
|
| 797 |
+
pip\_vendor\pygments\__init__.cpython-310.pyc,,
|
| 798 |
+
pip\_vendor\msgpack\fallback.cpython-310.pyc,,
|
| 799 |
+
pip\_vendor\distlib\locators.cpython-310.pyc,,
|
| 800 |
+
pip\_vendor\rich\themes.cpython-310.pyc,,
|
| 801 |
+
pip\_vendor\platformdirs\__pycache__,,
|
| 802 |
+
pip\_vendor\pygments\cmdline.cpython-310.pyc,,
|
| 803 |
+
pip\_vendor\rich\control.cpython-310.pyc,,
|
| 804 |
+
pip\_internal\vcs\__init__.cpython-310.pyc,,
|
| 805 |
+
pip\_vendor\rich\rule.cpython-310.pyc,,
|
| 806 |
+
pip\_vendor\pygments\formatters\latex.cpython-310.pyc,,
|
| 807 |
+
pip\_vendor\urllib3\__init__.cpython-310.pyc,,
|
| 808 |
+
pip\_internal\utils\packaging.cpython-310.pyc,,
|
| 809 |
+
pip\_vendor\chardet\jisfreq.cpython-310.pyc,,
|
| 810 |
+
pip\_vendor\idna\codec.cpython-310.pyc,,
|
| 811 |
+
pip\_internal\metadata\_json.cpython-310.pyc,,
|
| 812 |
+
pip\_vendor\urllib3\util\ssltransport.cpython-310.pyc,,
|
| 813 |
+
pip\_vendor\colorama\ansitowin32.cpython-310.pyc,,
|
| 814 |
+
pip\_vendor\rich\traceback.cpython-310.pyc,,
|
| 815 |
+
pip\_vendor\distlib\database.cpython-310.pyc,,
|
| 816 |
+
pip\_vendor\rich\pager.cpython-310.pyc,,
|
| 817 |
+
pip\_internal\network\xmlrpc.cpython-310.pyc,,
|
| 818 |
+
pip\_internal\utils\wheel.cpython-310.pyc,,
|
| 819 |
+
pip\_vendor\requests\certs.cpython-310.pyc,,
|
| 820 |
+
pip\_internal\metadata\importlib\__init__.cpython-310.pyc,,
|
| 821 |
+
pip\_vendor\urllib3\packages\__init__.cpython-310.pyc,,
|
| 822 |
+
pip\_vendor\chardet\utf1632prober.cpython-310.pyc,,
|
| 823 |
+
pip\_vendor\urllib3\filepost.cpython-310.pyc,,
|
| 824 |
+
pip\_vendor\six.cpython-310.pyc,,
|
| 825 |
+
pip\_vendor\rich\_spinners.cpython-310.pyc,,
|
| 826 |
+
pip\_vendor\idna\package_data.cpython-310.pyc,,
|
| 827 |
+
pip\_internal\operations\build\build_tracker.cpython-310.pyc,,
|
| 828 |
+
pip\_internal\resolution\resolvelib\resolver.cpython-310.pyc,,
|
| 829 |
+
pip\_vendor\urllib3\util\__init__.cpython-310.pyc,,
|
| 830 |
+
pip\_vendor\requests\__version__.cpython-310.pyc,,
|
| 831 |
+
pip\_vendor\pyparsing\__pycache__,,
|
| 832 |
+
pip\_internal\resolution\legacy\resolver.cpython-310.pyc,,
|
| 833 |
+
pip\_vendor\pygments\formatters\bbcode.cpython-310.pyc,,
|
| 834 |
+
pip\_vendor\urllib3\util\ssl_match_hostname.cpython-310.pyc,,
|
| 835 |
+
pip\_vendor\chardet\langrussianmodel.cpython-310.pyc,,
|
| 836 |
+
pip\_vendor\rich\_extension.cpython-310.pyc,,
|
| 837 |
+
pip\_vendor\webencodings\__pycache__,,
|
| 838 |
+
pip\_vendor\urllib3\exceptions.cpython-310.pyc,,
|
| 839 |
+
pip\_vendor\rich\panel.cpython-310.pyc,,
|
| 840 |
+
pip\_internal\resolution\resolvelib\factory.cpython-310.pyc,,
|
| 841 |
+
pip\_internal\commands\search.cpython-310.pyc,,
|
| 842 |
+
pip\_vendor\pygments\lexer.cpython-310.pyc,,
|
| 843 |
+
pip\_vendor\idna\idnadata.cpython-310.pyc,,
|
| 844 |
+
pip\_vendor\urllib3\util\url.cpython-310.pyc,,
|
| 845 |
+
pip\_vendor\certifi\__pycache__,,
|
| 846 |
+
pip\_vendor\chardet\sbcsgroupprober.cpython-310.pyc,,
|
| 847 |
+
pip\_vendor\tenacity\__pycache__,,
|
| 848 |
+
pip\_vendor\urllib3\packages\backports\__pycache__,,
|
| 849 |
+
pip\_internal\resolution\resolvelib\__init__.cpython-310.pyc,,
|
| 850 |
+
pip\_vendor\rich\logging.cpython-310.pyc,,
|
| 851 |
+
pip\_internal\req\req_file.cpython-310.pyc,,
|
| 852 |
+
pip\_vendor\urllib3\fields.cpython-310.pyc,,
|
| 853 |
+
pip\_vendor\tenacity\stop.cpython-310.pyc,,
|
| 854 |
+
pip\_internal\commands\configuration.cpython-310.pyc,,
|
| 855 |
+
pip\_vendor\pyproject_hooks\_compat.cpython-310.pyc,,
|
| 856 |
+
pip\_vendor\requests\hooks.cpython-310.pyc,,
|
| 857 |
+
pip\_internal\operations\build\__pycache__,,
|
| 858 |
+
pip\_vendor\rich\__init__.cpython-310.pyc,,
|
| 859 |
+
pip\_vendor\colorama\tests\utils.cpython-310.pyc,,
|
| 860 |
+
pip\_internal\commands\show.cpython-310.pyc,,
|
| 861 |
+
pip\_internal\commands\__init__.cpython-310.pyc,,
|
| 862 |
+
pip\_vendor\chardet\jpcntx.cpython-310.pyc,,
|
| 863 |
+
pip\_vendor\chardet\langhebrewmodel.cpython-310.pyc,,
|
| 864 |
+
pip\_vendor\urllib3\contrib\socks.cpython-310.pyc,,
|
| 865 |
+
pip\_internal\models\search_scope.cpython-310.pyc,,
|
| 866 |
+
pip\_vendor\pygments\util.cpython-310.pyc,,
|
| 867 |
+
pip\_vendor\pygments\formatters\terminal256.cpython-310.pyc,,
|
| 868 |
+
pip\_vendor\rich\jupyter.cpython-310.pyc,,
|
| 869 |
+
pip\__pip-runner__.cpython-310.pyc,,
|
| 870 |
+
pip\_vendor\pygments\formatters\other.cpython-310.pyc,,
|
| 871 |
+
pip\_vendor\resolvelib\compat\__pycache__,,
|
| 872 |
+
pip\_vendor\resolvelib\__init__.cpython-310.pyc,,
|
| 873 |
+
pip\_internal\resolution\__init__.cpython-310.pyc,,
|
| 874 |
+
pip\_internal\network\lazy_wheel.cpython-310.pyc,,
|
| 875 |
+
pip\_internal\models\link.cpython-310.pyc,,
|
| 876 |
+
pip\_vendor\pygments\lexers\python.cpython-310.pyc,,
|
| 877 |
+
pip\_vendor\tenacity\nap.cpython-310.pyc,,
|
| 878 |
+
pip\_internal\index\sources.cpython-310.pyc,,
|
| 879 |
+
pip\_vendor\requests\structures.cpython-310.pyc,,
|
| 880 |
+
pip\_internal\index\__init__.cpython-310.pyc,,
|
| 881 |
+
pip\_vendor\cachecontrol\caches\__init__.cpython-310.pyc,,
|
| 882 |
+
pip\_vendor\pygments\regexopt.cpython-310.pyc,,
|
| 883 |
+
pip\_vendor\chardet\metadata\__init__.cpython-310.pyc,,
|
| 884 |
+
pip\_vendor\rich\screen.cpython-310.pyc,,
|
| 885 |
+
pip\_internal\utils\logging.cpython-310.pyc,,
|
| 886 |
+
pip\_vendor\urllib3\packages\six.cpython-310.pyc,,
|
| 887 |
+
pip\_vendor\pygments\formatters\rtf.cpython-310.pyc,,
|
| 888 |
+
pip\_vendor\rich\theme.cpython-310.pyc,,
|
| 889 |
+
pip\_internal\req\__init__.cpython-310.pyc,,
|
| 890 |
+
pip\_internal\commands\cache.cpython-310.pyc,,
|
| 891 |
+
pip\_internal\metadata\base.cpython-310.pyc,,
|
| 892 |
+
pip\_internal\locations\base.cpython-310.pyc,,
|
| 893 |
+
pip\_internal\resolution\resolvelib\requirements.cpython-310.pyc,,
|
| 894 |
+
pip\__pycache__,,
|
| 895 |
+
pip\_internal\network\utils.cpython-310.pyc,,
|
| 896 |
+
pip\_vendor\certifi\core.cpython-310.pyc,,
|
| 897 |
+
pip\_vendor\chardet\big5freq.cpython-310.pyc,,
|
| 898 |
+
pip\_vendor\distlib\version.cpython-310.pyc,,
|
| 899 |
+
pip\_vendor\cachecontrol\heuristics.cpython-310.pyc,,
|
| 900 |
+
pip\_vendor\pygments\formatter.cpython-310.pyc,,
|
| 901 |
+
pip\_vendor\pygments\__main__.cpython-310.pyc,,
|
| 902 |
+
pip\_vendor\platformdirs\version.cpython-310.pyc,,
|
| 903 |
+
pip\_internal\metadata\importlib\_envs.cpython-310.pyc,,
|
| 904 |
+
pip\_vendor\urllib3\contrib\_securetransport\__init__.cpython-310.pyc,,
|
| 905 |
+
pip\_vendor\urllib3\contrib\_securetransport\low_level.cpython-310.pyc,,
|
| 906 |
+
pip\_vendor\urllib3\contrib\ntlmpool.cpython-310.pyc,,
|
| 907 |
+
pip\_vendor\urllib3\packages\backports\makefile.cpython-310.pyc,,
|
| 908 |
+
pip\_vendor\tenacity\retry.cpython-310.pyc,,
|
| 909 |
+
pip\_vendor\chardet\charsetgroupprober.cpython-310.pyc,,
|
| 910 |
+
pip\_vendor\urllib3\contrib\appengine.cpython-310.pyc,,
|
| 911 |
+
pip\_vendor\pyproject_hooks\_in_process\__init__.cpython-310.pyc,,
|
| 912 |
+
pip\_internal\models\__init__.cpython-310.pyc,,
|
| 913 |
+
pip\_vendor\distro\__init__.cpython-310.pyc,,
|
| 914 |
+
pip\_vendor\pyparsing\results.cpython-310.pyc,,
|
| 915 |
+
pip\_internal\commands\help.cpython-310.pyc,,
|
| 916 |
+
pip\_vendor\rich\_inspect.cpython-310.pyc,,
|
| 917 |
+
pip\_internal\cli\cmdoptions.cpython-310.pyc,,
|
| 918 |
+
pip\_vendor\requests\auth.cpython-310.pyc,,
|
| 919 |
+
pip\_vendor\chardet\codingstatemachine.cpython-310.pyc,,
|
| 920 |
+
pip\_vendor\rich\_null_file.cpython-310.pyc,,
|
| 921 |
+
pip\_vendor\pygments\lexers\__init__.cpython-310.pyc,,
|
| 922 |
+
pip\_internal\operations\freeze.cpython-310.pyc,,
|
| 923 |
+
pip\_vendor\rich\_ratio.cpython-310.pyc,,
|
| 924 |
+
pip\_internal\resolution\resolvelib\reporter.cpython-310.pyc,,
|
| 925 |
+
pip\_vendor\pygments\formatters\_mapping.cpython-310.pyc,,
|
| 926 |
+
pip\_vendor\rich\spinner.cpython-310.pyc,,
|
| 927 |
+
pip\_vendor\requests\utils.cpython-310.pyc,,
|
| 928 |
+
pip\_vendor\resolvelib\compat\collections_abc.cpython-310.pyc,,
|
| 929 |
+
pip\_internal\commands\freeze.cpython-310.pyc,,
|
| 930 |
+
pip\_internal\req\constructors.cpython-310.pyc,,
|
| 931 |
+
pip\_vendor\pygments\plugin.cpython-310.pyc,,
|
| 932 |
+
pip\_internal\utils\filetypes.cpython-310.pyc,,
|
| 933 |
+
pip\_internal\req\req_install.cpython-310.pyc,,
|
| 934 |
+
pip\_vendor\rich\align.cpython-310.pyc,,
|
| 935 |
+
pip\_vendor\urllib3\connection.cpython-310.pyc,,
|
| 936 |
+
pip\_internal\configuration.cpython-310.pyc,,
|
| 937 |
+
pip\_vendor\__init__.cpython-310.pyc,,
|
| 938 |
+
pip\_vendor\requests\_internal_utils.cpython-310.pyc,,
|
| 939 |
+
pip\_internal\cli\__pycache__,,
|
| 940 |
+
pip\_vendor\pkg_resources\__init__.cpython-310.pyc,,
|
| 941 |
+
pip\_vendor\urllib3\connectionpool.cpython-310.pyc,,
|
| 942 |
+
pip\_internal\utils\urls.cpython-310.pyc,,
|
| 943 |
+
pip\_internal\commands\inspect.cpython-310.pyc,,
|
| 944 |
+
pip\_vendor\rich\columns.cpython-310.pyc,,
|
| 945 |
+
pip\_vendor\rich\_windows_renderer.cpython-310.pyc,,
|
| 946 |
+
pip\_vendor\chardet\escsm.cpython-310.pyc,,
|
| 947 |
+
pip\_vendor\chardet\charsetprober.cpython-310.pyc,,
|
| 948 |
+
pip\_vendor\packaging\__pycache__,,
|
| 949 |
+
pip\_vendor\chardet\latin1prober.cpython-310.pyc,,
|
| 950 |
+
pip\_vendor\rich\scope.cpython-310.pyc,,
|
| 951 |
+
pip\_vendor\urllib3\contrib\_securetransport\bindings.cpython-310.pyc,,
|
| 952 |
+
pip\_vendor\pygments\console.cpython-310.pyc,,
|
| 953 |
+
pip\_vendor\pygments\formatters\__pycache__,,
|
| 954 |
+
pip\_vendor\urllib3\util\connection.cpython-310.pyc,,
|
| 955 |
+
pip\_vendor\rich\containers.cpython-310.pyc,,
|
| 956 |
+
pip\_vendor\urllib3\util\wait.cpython-310.pyc,,
|
| 957 |
+
pip\_internal\distributions\__init__.cpython-310.pyc,,
|
| 958 |
+
pip\_vendor\idna\core.cpython-310.pyc,,
|
| 959 |
+
pip\_vendor\pyproject_hooks\__pycache__,,
|
| 960 |
+
pip\_internal\cli\status_codes.cpython-310.pyc,,
|
| 961 |
+
pip\_internal\cli\command_context.cpython-310.pyc,,
|
| 962 |
+
pip\_vendor\colorama\tests\__init__.cpython-310.pyc,,
|
| 963 |
+
pip\_vendor\rich\_windows.cpython-310.pyc,,
|
| 964 |
+
pip\_internal\utils\virtualenv.cpython-310.pyc,,
|
| 965 |
+
pip\_vendor\rich\_cell_widths.cpython-310.pyc,,
|
| 966 |
+
pip\_vendor\tenacity\_utils.cpython-310.pyc,,
|
| 967 |
+
pip\_vendor\chardet\__pycache__,,
|
| 968 |
+
pip\_vendor\rich\measure.cpython-310.pyc,,
|
| 969 |
+
pip\_vendor\rich\tree.cpython-310.pyc,,
|
| 970 |
+
pip\_internal\exceptions.cpython-310.pyc,,
|
| 971 |
+
pip\_internal\operations\build\wheel.cpython-310.pyc,,
|
| 972 |
+
pip\_vendor\requests\adapters.cpython-310.pyc,,
|
| 973 |
+
pip\_vendor\rich\filesize.cpython-310.pyc,,
|
| 974 |
+
pip\_internal\cli\main.cpython-310.pyc,,
|
| 975 |
+
pip\_internal\resolution\base.cpython-310.pyc,,
|
| 976 |
+
pip\_internal\cli\req_command.cpython-310.pyc,,
|
| 977 |
+
pip\_vendor\chardet\universaldetector.cpython-310.pyc,,
|
| 978 |
+
pip\_internal\operations\build\wheel_editable.cpython-310.pyc,,
|
| 979 |
+
pip\_internal\cache.cpython-310.pyc,,
|
| 980 |
+
pip\_vendor\tenacity\after.cpython-310.pyc,,
|
| 981 |
+
pip\_vendor\pygments\styles\__pycache__,,
|
| 982 |
+
pip\_vendor\chardet\sbcharsetprober.cpython-310.pyc,,
|
| 983 |
+
pip\_internal\operations\build\metadata_legacy.cpython-310.pyc,,
|
| 984 |
+
pip\_internal\models\selection_prefs.cpython-310.pyc,,
|
| 985 |
+
pip\_internal\vcs\git.cpython-310.pyc,,
|
| 986 |
+
pip\_vendor\pyparsing\diagram\__init__.cpython-310.pyc,,
|
| 987 |
+
pip\_vendor\colorama\tests\ansi_test.cpython-310.pyc,,
|
| 988 |
+
pip\_internal\commands\wheel.cpython-310.pyc,,
|
| 989 |
+
pip\_vendor\distlib\__init__.cpython-310.pyc,,
|
| 990 |
+
pip\_vendor\urllib3\poolmanager.cpython-310.pyc,,
|
| 991 |
+
pip\_vendor\chardet\cli\__pycache__,,
|
| 992 |
+
pip\_vendor\platformdirs\__init__.cpython-310.pyc,,
|
| 993 |
+
pip\_vendor\rich\console.cpython-310.pyc,,
|
| 994 |
+
pip\_vendor\chardet\mbcharsetprober.cpython-310.pyc,,
|
| 995 |
+
pip\_vendor\colorama\__init__.cpython-310.pyc,,
|
| 996 |
+
pip\_vendor\chardet\langturkishmodel.cpython-310.pyc,,
|
| 997 |
+
pip\_internal\network\__init__.cpython-310.pyc,,
|
| 998 |
+
pip\_vendor\pygments\filter.cpython-310.pyc,,
|
| 999 |
+
pip\_vendor\idna\compat.cpython-310.pyc,,
|
| 1000 |
+
pip\_internal\utils\datetime.cpython-310.pyc,,
|
| 1001 |
+
pip\_internal\operations\install\wheel.cpython-310.pyc,,
|
| 1002 |
+
pip\_vendor\rich\file_proxy.cpython-310.pyc,,
|
| 1003 |
+
pip\_internal\vcs\__pycache__,,
|
| 1004 |
+
pip\_internal\utils\filesystem.cpython-310.pyc,,
|
| 1005 |
+
pip\_vendor\rich\_palettes.cpython-310.pyc,,
|
| 1006 |
+
pip\_internal\utils\encoding.cpython-310.pyc,,
|
| 1007 |
+
pip\_internal\utils\_log.cpython-310.pyc,,
|
| 1008 |
+
pip\_vendor\urllib3\contrib\securetransport.cpython-310.pyc,,
|
| 1009 |
+
pip\_vendor\distlib\metadata.cpython-310.pyc,,
|
| 1010 |
+
pip\_vendor\pygments\sphinxext.cpython-310.pyc,,
|
| 1011 |
+
pip\_vendor\pyparsing\__init__.cpython-310.pyc,,
|
| 1012 |
+
pip\_internal\models\candidate.cpython-310.pyc,,
|
| 1013 |
+
pip\_vendor\pyproject_hooks\_impl.cpython-310.pyc,,
|
| 1014 |
+
pip\_internal\locations\_distutils.cpython-310.pyc,,
|
| 1015 |
+
pip\_vendor\pygments\formatters\img.cpython-310.pyc,,
|
| 1016 |
+
pip\_vendor\webencodings\__init__.cpython-310.pyc,,
|
| 1017 |
+
pip\_vendor\msgpack\__init__.cpython-310.pyc,,
|
| 1018 |
+
pip\_internal\vcs\versioncontrol.cpython-310.pyc,,
|
| 1019 |
+
pip\_vendor\rich\pretty.cpython-310.pyc,,
|
| 1020 |
+
pip\_vendor\msgpack\ext.cpython-310.pyc,,
|
| 1021 |
+
pip\_vendor\requests\__init__.cpython-310.pyc,,
|
| 1022 |
+
pip\_vendor\packaging\utils.cpython-310.pyc,,
|
| 1023 |
+
pip\_vendor\distro\distro.cpython-310.pyc,,
|
| 1024 |
+
pip\_vendor\chardet\sjisprober.cpython-310.pyc,,
|
| 1025 |
+
pip\_vendor\webencodings\x_user_defined.cpython-310.pyc,,
|
| 1026 |
+
pip\_vendor\urllib3\packages\backports\__init__.cpython-310.pyc,,
|
| 1027 |
+
pip\_vendor\distlib\markers.cpython-310.pyc,,
|
| 1028 |
+
pip\_vendor\platformdirs\api.cpython-310.pyc,,
|
| 1029 |
+
pip\_vendor\chardet\big5prober.cpython-310.pyc,,
|
| 1030 |
+
pip\_internal\req\req_set.cpython-310.pyc,,
|
| 1031 |
+
pip\_internal\network\cache.cpython-310.pyc,,
|
| 1032 |
+
pip\_vendor\idna\uts46data.cpython-310.pyc,,
|
| 1033 |
+
pip\_vendor\packaging\version.cpython-310.pyc,,
|
| 1034 |
+
pip\_vendor\chardet\euctwfreq.cpython-310.pyc,,
|
| 1035 |
+
..\..\Scripts\pip-3.10.exe,,
|
| 1036 |
+
pip\_vendor\cachecontrol\__init__.cpython-310.pyc,,
|
| 1037 |
+
pip\_vendor\colorama\tests\winterm_test.cpython-310.pyc,,
|
| 1038 |
+
pip\_vendor\rich\highlighter.cpython-310.pyc,,
|
| 1039 |
+
pip\_internal\resolution\resolvelib\__pycache__,,
|
| 1040 |
+
pip\_vendor\chardet\mbcssm.cpython-310.pyc,,
|
| 1041 |
+
pip\_vendor\msgpack\exceptions.cpython-310.pyc,,
|
| 1042 |
+
pip\_vendor\colorama\tests\isatty_test.cpython-310.pyc,,
|
| 1043 |
+
pip\_internal\resolution\legacy\__pycache__,,
|
| 1044 |
+
..\..\Scripts\pip.exe,,
|
| 1045 |
+
pip\_internal\commands\index.cpython-310.pyc,,
|
| 1046 |
+
pip\_internal\distributions\base.cpython-310.pyc,,
|
| 1047 |
+
pip\_vendor\rich\color_triplet.cpython-310.pyc,,
|
| 1048 |
+
pip\_vendor\requests\exceptions.cpython-310.pyc,,
|
| 1049 |
+
pip\_internal\operations\__pycache__,,
|
| 1050 |
+
pip\_vendor\pygments\filters\__pycache__,,
|
| 1051 |
+
pip\_vendor\chardet\hebrewprober.cpython-310.pyc,,
|
| 1052 |
+
pip\_vendor\distlib\util.cpython-310.pyc,,
|
| 1053 |
+
pip\_vendor\pyparsing\common.cpython-310.pyc,,
|
| 1054 |
+
pip\_vendor\resolvelib\compat\__init__.cpython-310.pyc,,
|
| 1055 |
+
pip\_vendor\cachecontrol\filewrapper.cpython-310.pyc,,
|
| 1056 |
+
pip\_internal\commands\__pycache__,,
|
| 1057 |
+
pip\_vendor\cachecontrol\controller.cpython-310.pyc,,
|
| 1058 |
+
pip\_vendor\rich\abc.cpython-310.pyc,,
|
| 1059 |
+
pip\_vendor\distlib\resources.cpython-310.pyc,,
|
| 1060 |
+
pip\_vendor\resolvelib\providers.cpython-310.pyc,,
|
| 1061 |
+
pip\_vendor\packaging\tags.cpython-310.pyc,,
|
| 1062 |
+
pip\_vendor\webencodings\labels.cpython-310.pyc,,
|
| 1063 |
+
pip\_vendor\chardet\euctwprober.cpython-310.pyc,,
|
.venv/Lib/site-packages/pip-23.2.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: bdist_wheel (0.40.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
.venv/Lib/site-packages/pip-23.2.1.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
pip = pip._internal.cli.main:main
|
| 3 |
+
pip3 = pip._internal.cli.main:main
|
| 4 |
+
pip3.11 = pip._internal.cli.main:main
|
.venv/Lib/site-packages/pip-23.2.1.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/Lib/site-packages/pip/_vendor/rich/__init__.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Rich text and beautiful formatting in the terminal."""
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union
|
| 5 |
+
|
| 6 |
+
from ._extension import load_ipython_extension # noqa: F401
|
| 7 |
+
|
| 8 |
+
__all__ = ["get_console", "reconfigure", "print", "inspect", "print_json"]
|
| 9 |
+
|
| 10 |
+
if TYPE_CHECKING:
|
| 11 |
+
from .console import Console
|
| 12 |
+
|
| 13 |
+
# Global console used by alternative print
|
| 14 |
+
_console: Optional["Console"] = None
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
_IMPORT_CWD = os.path.abspath(os.getcwd())
|
| 18 |
+
except FileNotFoundError:
|
| 19 |
+
# Can happen if the cwd has been deleted
|
| 20 |
+
_IMPORT_CWD = ""
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def get_console() -> "Console":
|
| 24 |
+
"""Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console,
|
| 25 |
+
and hasn't been explicitly given one.
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
Console: A console instance.
|
| 29 |
+
"""
|
| 30 |
+
global _console
|
| 31 |
+
if _console is None:
|
| 32 |
+
from .console import Console
|
| 33 |
+
|
| 34 |
+
_console = Console()
|
| 35 |
+
|
| 36 |
+
return _console
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def reconfigure(*args: Any, **kwargs: Any) -> None:
|
| 40 |
+
"""Reconfigures the global console by replacing it with another.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
*args (Any): Positional arguments for the replacement :class:`~rich.console.Console`.
|
| 44 |
+
**kwargs (Any): Keyword arguments for the replacement :class:`~rich.console.Console`.
|
| 45 |
+
"""
|
| 46 |
+
from pip._vendor.rich.console import Console
|
| 47 |
+
|
| 48 |
+
new_console = Console(*args, **kwargs)
|
| 49 |
+
_console = get_console()
|
| 50 |
+
_console.__dict__ = new_console.__dict__
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def print(
|
| 54 |
+
*objects: Any,
|
| 55 |
+
sep: str = " ",
|
| 56 |
+
end: str = "\n",
|
| 57 |
+
file: Optional[IO[str]] = None,
|
| 58 |
+
flush: bool = False,
|
| 59 |
+
) -> None:
|
| 60 |
+
r"""Print object(s) supplied via positional arguments.
|
| 61 |
+
This function has an identical signature to the built-in print.
|
| 62 |
+
For more advanced features, see the :class:`~rich.console.Console` class.
|
| 63 |
+
|
| 64 |
+
Args:
|
| 65 |
+
sep (str, optional): Separator between printed objects. Defaults to " ".
|
| 66 |
+
end (str, optional): Character to write at end of output. Defaults to "\\n".
|
| 67 |
+
file (IO[str], optional): File to write to, or None for stdout. Defaults to None.
|
| 68 |
+
flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.
|
| 69 |
+
|
| 70 |
+
"""
|
| 71 |
+
from .console import Console
|
| 72 |
+
|
| 73 |
+
write_console = get_console() if file is None else Console(file=file)
|
| 74 |
+
return write_console.print(*objects, sep=sep, end=end)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def print_json(
|
| 78 |
+
json: Optional[str] = None,
|
| 79 |
+
*,
|
| 80 |
+
data: Any = None,
|
| 81 |
+
indent: Union[None, int, str] = 2,
|
| 82 |
+
highlight: bool = True,
|
| 83 |
+
skip_keys: bool = False,
|
| 84 |
+
ensure_ascii: bool = False,
|
| 85 |
+
check_circular: bool = True,
|
| 86 |
+
allow_nan: bool = True,
|
| 87 |
+
default: Optional[Callable[[Any], Any]] = None,
|
| 88 |
+
sort_keys: bool = False,
|
| 89 |
+
) -> None:
|
| 90 |
+
"""Pretty prints JSON. Output will be valid JSON.
|
| 91 |
+
|
| 92 |
+
Args:
|
| 93 |
+
json (str): A string containing JSON.
|
| 94 |
+
data (Any): If json is not supplied, then encode this data.
|
| 95 |
+
indent (int, optional): Number of spaces to indent. Defaults to 2.
|
| 96 |
+
highlight (bool, optional): Enable highlighting of output: Defaults to True.
|
| 97 |
+
skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
|
| 98 |
+
ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
|
| 99 |
+
check_circular (bool, optional): Check for circular references. Defaults to True.
|
| 100 |
+
allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
|
| 101 |
+
default (Callable, optional): A callable that converts values that can not be encoded
|
| 102 |
+
in to something that can be JSON encoded. Defaults to None.
|
| 103 |
+
sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
|
| 104 |
+
"""
|
| 105 |
+
|
| 106 |
+
get_console().print_json(
|
| 107 |
+
json,
|
| 108 |
+
data=data,
|
| 109 |
+
indent=indent,
|
| 110 |
+
highlight=highlight,
|
| 111 |
+
skip_keys=skip_keys,
|
| 112 |
+
ensure_ascii=ensure_ascii,
|
| 113 |
+
check_circular=check_circular,
|
| 114 |
+
allow_nan=allow_nan,
|
| 115 |
+
default=default,
|
| 116 |
+
sort_keys=sort_keys,
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def inspect(
|
| 121 |
+
obj: Any,
|
| 122 |
+
*,
|
| 123 |
+
console: Optional["Console"] = None,
|
| 124 |
+
title: Optional[str] = None,
|
| 125 |
+
help: bool = False,
|
| 126 |
+
methods: bool = False,
|
| 127 |
+
docs: bool = True,
|
| 128 |
+
private: bool = False,
|
| 129 |
+
dunder: bool = False,
|
| 130 |
+
sort: bool = True,
|
| 131 |
+
all: bool = False,
|
| 132 |
+
value: bool = True,
|
| 133 |
+
) -> None:
|
| 134 |
+
"""Inspect any Python object.
|
| 135 |
+
|
| 136 |
+
* inspect(<OBJECT>) to see summarized info.
|
| 137 |
+
* inspect(<OBJECT>, methods=True) to see methods.
|
| 138 |
+
* inspect(<OBJECT>, help=True) to see full (non-abbreviated) help.
|
| 139 |
+
* inspect(<OBJECT>, private=True) to see private attributes (single underscore).
|
| 140 |
+
* inspect(<OBJECT>, dunder=True) to see attributes beginning with double underscore.
|
| 141 |
+
* inspect(<OBJECT>, all=True) to see all attributes.
|
| 142 |
+
|
| 143 |
+
Args:
|
| 144 |
+
obj (Any): An object to inspect.
|
| 145 |
+
title (str, optional): Title to display over inspect result, or None use type. Defaults to None.
|
| 146 |
+
help (bool, optional): Show full help text rather than just first paragraph. Defaults to False.
|
| 147 |
+
methods (bool, optional): Enable inspection of callables. Defaults to False.
|
| 148 |
+
docs (bool, optional): Also render doc strings. Defaults to True.
|
| 149 |
+
private (bool, optional): Show private attributes (beginning with underscore). Defaults to False.
|
| 150 |
+
dunder (bool, optional): Show attributes starting with double underscore. Defaults to False.
|
| 151 |
+
sort (bool, optional): Sort attributes alphabetically. Defaults to True.
|
| 152 |
+
all (bool, optional): Show all attributes. Defaults to False.
|
| 153 |
+
value (bool, optional): Pretty print value. Defaults to True.
|
| 154 |
+
"""
|
| 155 |
+
_console = console or get_console()
|
| 156 |
+
from pip._vendor.rich._inspect import Inspect
|
| 157 |
+
|
| 158 |
+
# Special case for inspect(inspect)
|
| 159 |
+
is_inspect = obj is inspect
|
| 160 |
+
|
| 161 |
+
_inspect = Inspect(
|
| 162 |
+
obj,
|
| 163 |
+
title=title,
|
| 164 |
+
help=is_inspect or help,
|
| 165 |
+
methods=is_inspect or methods,
|
| 166 |
+
docs=is_inspect or docs,
|
| 167 |
+
private=private,
|
| 168 |
+
dunder=dunder,
|
| 169 |
+
sort=sort,
|
| 170 |
+
all=all,
|
| 171 |
+
value=value,
|
| 172 |
+
)
|
| 173 |
+
_console.print(_inspect)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
if __name__ == "__main__": # pragma: no cover
|
| 177 |
+
print("Hello, **World**")
|
.venv/Lib/site-packages/pip/_vendor/rich/__main__.py
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import colorsys
|
| 2 |
+
import io
|
| 3 |
+
from time import process_time
|
| 4 |
+
|
| 5 |
+
from pip._vendor.rich import box
|
| 6 |
+
from pip._vendor.rich.color import Color
|
| 7 |
+
from pip._vendor.rich.console import Console, ConsoleOptions, Group, RenderableType, RenderResult
|
| 8 |
+
from pip._vendor.rich.markdown import Markdown
|
| 9 |
+
from pip._vendor.rich.measure import Measurement
|
| 10 |
+
from pip._vendor.rich.pretty import Pretty
|
| 11 |
+
from pip._vendor.rich.segment import Segment
|
| 12 |
+
from pip._vendor.rich.style import Style
|
| 13 |
+
from pip._vendor.rich.syntax import Syntax
|
| 14 |
+
from pip._vendor.rich.table import Table
|
| 15 |
+
from pip._vendor.rich.text import Text
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ColorBox:
|
| 19 |
+
def __rich_console__(
|
| 20 |
+
self, console: Console, options: ConsoleOptions
|
| 21 |
+
) -> RenderResult:
|
| 22 |
+
for y in range(0, 5):
|
| 23 |
+
for x in range(options.max_width):
|
| 24 |
+
h = x / options.max_width
|
| 25 |
+
l = 0.1 + ((y / 5) * 0.7)
|
| 26 |
+
r1, g1, b1 = colorsys.hls_to_rgb(h, l, 1.0)
|
| 27 |
+
r2, g2, b2 = colorsys.hls_to_rgb(h, l + 0.7 / 10, 1.0)
|
| 28 |
+
bgcolor = Color.from_rgb(r1 * 255, g1 * 255, b1 * 255)
|
| 29 |
+
color = Color.from_rgb(r2 * 255, g2 * 255, b2 * 255)
|
| 30 |
+
yield Segment("▄", Style(color=color, bgcolor=bgcolor))
|
| 31 |
+
yield Segment.line()
|
| 32 |
+
|
| 33 |
+
def __rich_measure__(
|
| 34 |
+
self, console: "Console", options: ConsoleOptions
|
| 35 |
+
) -> Measurement:
|
| 36 |
+
return Measurement(1, options.max_width)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def make_test_card() -> Table:
|
| 40 |
+
"""Get a renderable that demonstrates a number of features."""
|
| 41 |
+
table = Table.grid(padding=1, pad_edge=True)
|
| 42 |
+
table.title = "Rich features"
|
| 43 |
+
table.add_column("Feature", no_wrap=True, justify="center", style="bold red")
|
| 44 |
+
table.add_column("Demonstration")
|
| 45 |
+
|
| 46 |
+
color_table = Table(
|
| 47 |
+
box=None,
|
| 48 |
+
expand=False,
|
| 49 |
+
show_header=False,
|
| 50 |
+
show_edge=False,
|
| 51 |
+
pad_edge=False,
|
| 52 |
+
)
|
| 53 |
+
color_table.add_row(
|
| 54 |
+
(
|
| 55 |
+
"✓ [bold green]4-bit color[/]\n"
|
| 56 |
+
"✓ [bold blue]8-bit color[/]\n"
|
| 57 |
+
"✓ [bold magenta]Truecolor (16.7 million)[/]\n"
|
| 58 |
+
"✓ [bold yellow]Dumb terminals[/]\n"
|
| 59 |
+
"✓ [bold cyan]Automatic color conversion"
|
| 60 |
+
),
|
| 61 |
+
ColorBox(),
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
table.add_row("Colors", color_table)
|
| 65 |
+
|
| 66 |
+
table.add_row(
|
| 67 |
+
"Styles",
|
| 68 |
+
"All ansi styles: [bold]bold[/], [dim]dim[/], [italic]italic[/italic], [underline]underline[/], [strike]strikethrough[/], [reverse]reverse[/], and even [blink]blink[/].",
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in metus sed sapien ultricies pretium a at justo. Maecenas luctus velit et auctor maximus."
|
| 72 |
+
lorem_table = Table.grid(padding=1, collapse_padding=True)
|
| 73 |
+
lorem_table.pad_edge = False
|
| 74 |
+
lorem_table.add_row(
|
| 75 |
+
Text(lorem, justify="left", style="green"),
|
| 76 |
+
Text(lorem, justify="center", style="yellow"),
|
| 77 |
+
Text(lorem, justify="right", style="blue"),
|
| 78 |
+
Text(lorem, justify="full", style="red"),
|
| 79 |
+
)
|
| 80 |
+
table.add_row(
|
| 81 |
+
"Text",
|
| 82 |
+
Group(
|
| 83 |
+
Text.from_markup(
|
| 84 |
+
"""Word wrap text. Justify [green]left[/], [yellow]center[/], [blue]right[/] or [red]full[/].\n"""
|
| 85 |
+
),
|
| 86 |
+
lorem_table,
|
| 87 |
+
),
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
def comparison(renderable1: RenderableType, renderable2: RenderableType) -> Table:
|
| 91 |
+
table = Table(show_header=False, pad_edge=False, box=None, expand=True)
|
| 92 |
+
table.add_column("1", ratio=1)
|
| 93 |
+
table.add_column("2", ratio=1)
|
| 94 |
+
table.add_row(renderable1, renderable2)
|
| 95 |
+
return table
|
| 96 |
+
|
| 97 |
+
table.add_row(
|
| 98 |
+
"Asian\nlanguage\nsupport",
|
| 99 |
+
":flag_for_china: 该库支持中文,日文和韩文文本!\n:flag_for_japan: ライブラリは中国語、日本語、韓国語のテキストをサポートしています\n:flag_for_south_korea: 이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다",
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
markup_example = (
|
| 103 |
+
"[bold magenta]Rich[/] supports a simple [i]bbcode[/i]-like [b]markup[/b] for [yellow]color[/], [underline]style[/], and emoji! "
|
| 104 |
+
":+1: :apple: :ant: :bear: :baguette_bread: :bus: "
|
| 105 |
+
)
|
| 106 |
+
table.add_row("Markup", markup_example)
|
| 107 |
+
|
| 108 |
+
example_table = Table(
|
| 109 |
+
show_edge=False,
|
| 110 |
+
show_header=True,
|
| 111 |
+
expand=False,
|
| 112 |
+
row_styles=["none", "dim"],
|
| 113 |
+
box=box.SIMPLE,
|
| 114 |
+
)
|
| 115 |
+
example_table.add_column("[green]Date", style="green", no_wrap=True)
|
| 116 |
+
example_table.add_column("[blue]Title", style="blue")
|
| 117 |
+
example_table.add_column(
|
| 118 |
+
"[cyan]Production Budget",
|
| 119 |
+
style="cyan",
|
| 120 |
+
justify="right",
|
| 121 |
+
no_wrap=True,
|
| 122 |
+
)
|
| 123 |
+
example_table.add_column(
|
| 124 |
+
"[magenta]Box Office",
|
| 125 |
+
style="magenta",
|
| 126 |
+
justify="right",
|
| 127 |
+
no_wrap=True,
|
| 128 |
+
)
|
| 129 |
+
example_table.add_row(
|
| 130 |
+
"Dec 20, 2019",
|
| 131 |
+
"Star Wars: The Rise of Skywalker",
|
| 132 |
+
"$275,000,000",
|
| 133 |
+
"$375,126,118",
|
| 134 |
+
)
|
| 135 |
+
example_table.add_row(
|
| 136 |
+
"May 25, 2018",
|
| 137 |
+
"[b]Solo[/]: A Star Wars Story",
|
| 138 |
+
"$275,000,000",
|
| 139 |
+
"$393,151,347",
|
| 140 |
+
)
|
| 141 |
+
example_table.add_row(
|
| 142 |
+
"Dec 15, 2017",
|
| 143 |
+
"Star Wars Ep. VIII: The Last Jedi",
|
| 144 |
+
"$262,000,000",
|
| 145 |
+
"[bold]$1,332,539,889[/bold]",
|
| 146 |
+
)
|
| 147 |
+
example_table.add_row(
|
| 148 |
+
"May 19, 1999",
|
| 149 |
+
"Star Wars Ep. [b]I[/b]: [i]The phantom Menace",
|
| 150 |
+
"$115,000,000",
|
| 151 |
+
"$1,027,044,677",
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
table.add_row("Tables", example_table)
|
| 155 |
+
|
| 156 |
+
code = '''\
|
| 157 |
+
def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
|
| 158 |
+
"""Iterate and generate a tuple with a flag for last value."""
|
| 159 |
+
iter_values = iter(values)
|
| 160 |
+
try:
|
| 161 |
+
previous_value = next(iter_values)
|
| 162 |
+
except StopIteration:
|
| 163 |
+
return
|
| 164 |
+
for value in iter_values:
|
| 165 |
+
yield False, previous_value
|
| 166 |
+
previous_value = value
|
| 167 |
+
yield True, previous_value'''
|
| 168 |
+
|
| 169 |
+
pretty_data = {
|
| 170 |
+
"foo": [
|
| 171 |
+
3.1427,
|
| 172 |
+
(
|
| 173 |
+
"Paul Atreides",
|
| 174 |
+
"Vladimir Harkonnen",
|
| 175 |
+
"Thufir Hawat",
|
| 176 |
+
),
|
| 177 |
+
],
|
| 178 |
+
"atomic": (False, True, None),
|
| 179 |
+
}
|
| 180 |
+
table.add_row(
|
| 181 |
+
"Syntax\nhighlighting\n&\npretty\nprinting",
|
| 182 |
+
comparison(
|
| 183 |
+
Syntax(code, "python3", line_numbers=True, indent_guides=True),
|
| 184 |
+
Pretty(pretty_data, indent_guides=True),
|
| 185 |
+
),
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
markdown_example = """\
|
| 189 |
+
# Markdown
|
| 190 |
+
|
| 191 |
+
Supports much of the *markdown* __syntax__!
|
| 192 |
+
|
| 193 |
+
- Headers
|
| 194 |
+
- Basic formatting: **bold**, *italic*, `code`
|
| 195 |
+
- Block quotes
|
| 196 |
+
- Lists, and more...
|
| 197 |
+
"""
|
| 198 |
+
table.add_row(
|
| 199 |
+
"Markdown", comparison("[cyan]" + markdown_example, Markdown(markdown_example))
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
table.add_row(
|
| 203 |
+
"+more!",
|
| 204 |
+
"""Progress bars, columns, styled logging handler, tracebacks, etc...""",
|
| 205 |
+
)
|
| 206 |
+
return table
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
if __name__ == "__main__": # pragma: no cover
|
| 210 |
+
|
| 211 |
+
console = Console(
|
| 212 |
+
file=io.StringIO(),
|
| 213 |
+
force_terminal=True,
|
| 214 |
+
)
|
| 215 |
+
test_card = make_test_card()
|
| 216 |
+
|
| 217 |
+
# Print once to warm cache
|
| 218 |
+
start = process_time()
|
| 219 |
+
console.print(test_card)
|
| 220 |
+
pre_cache_taken = round((process_time() - start) * 1000.0, 1)
|
| 221 |
+
|
| 222 |
+
console.file = io.StringIO()
|
| 223 |
+
|
| 224 |
+
start = process_time()
|
| 225 |
+
console.print(test_card)
|
| 226 |
+
taken = round((process_time() - start) * 1000.0, 1)
|
| 227 |
+
|
| 228 |
+
c = Console(record=True)
|
| 229 |
+
c.print(test_card)
|
| 230 |
+
|
| 231 |
+
print(f"rendered in {pre_cache_taken}ms (cold cache)")
|
| 232 |
+
print(f"rendered in {taken}ms (warm cache)")
|
| 233 |
+
|
| 234 |
+
from pip._vendor.rich.panel import Panel
|
| 235 |
+
|
| 236 |
+
console = Console()
|
| 237 |
+
|
| 238 |
+
sponsor_message = Table.grid(padding=1)
|
| 239 |
+
sponsor_message.add_column(style="green", justify="right")
|
| 240 |
+
sponsor_message.add_column(no_wrap=True)
|
| 241 |
+
|
| 242 |
+
sponsor_message.add_row(
|
| 243 |
+
"Textualize",
|
| 244 |
+
"[u blue link=https://github.com/textualize]https://github.com/textualize",
|
| 245 |
+
)
|
| 246 |
+
sponsor_message.add_row(
|
| 247 |
+
"Twitter",
|
| 248 |
+
"[u blue link=https://twitter.com/willmcgugan]https://twitter.com/willmcgugan",
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
intro_message = Text.from_markup(
|
| 252 |
+
"""\
|
| 253 |
+
We hope you enjoy using Rich!
|
| 254 |
+
|
| 255 |
+
Rich is maintained with [red]:heart:[/] by [link=https://www.textualize.io]Textualize.io[/]
|
| 256 |
+
|
| 257 |
+
- Will McGugan"""
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
message = Table.grid(padding=2)
|
| 261 |
+
message.add_column()
|
| 262 |
+
message.add_column(no_wrap=True)
|
| 263 |
+
message.add_row(intro_message, sponsor_message)
|
| 264 |
+
|
| 265 |
+
console.print(
|
| 266 |
+
Panel.fit(
|
| 267 |
+
message,
|
| 268 |
+
box=box.ROUNDED,
|
| 269 |
+
padding=(1, 2),
|
| 270 |
+
title="[b red]Thanks for trying out Rich!",
|
| 271 |
+
border_style="bright_blue",
|
| 272 |
+
),
|
| 273 |
+
justify="center",
|
| 274 |
+
)
|
.venv/Lib/site-packages/pip/_vendor/rich/_timer.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Timer context manager, only used in debug.
|
| 3 |
+
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from time import time
|
| 7 |
+
|
| 8 |
+
import contextlib
|
| 9 |
+
from typing import Generator
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@contextlib.contextmanager
|
| 13 |
+
def timer(subject: str = "time") -> Generator[None, None, None]:
|
| 14 |
+
"""print the elapsed time. (only used in debugging)"""
|
| 15 |
+
start = time()
|
| 16 |
+
yield
|
| 17 |
+
elapsed = time() - start
|
| 18 |
+
elapsed_ms = elapsed * 1000
|
| 19 |
+
print(f"{subject} elapsed {elapsed_ms:.1f}ms")
|
.venv/Lib/site-packages/pip/_vendor/rich/_win32_console.py
ADDED
|
@@ -0,0 +1,662 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Light wrapper around the Win32 Console API - this module should only be imported on Windows
|
| 2 |
+
|
| 3 |
+
The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions
|
| 4 |
+
"""
|
| 5 |
+
import ctypes
|
| 6 |
+
import sys
|
| 7 |
+
from typing import Any
|
| 8 |
+
|
| 9 |
+
windll: Any = None
|
| 10 |
+
if sys.platform == "win32":
|
| 11 |
+
windll = ctypes.LibraryLoader(ctypes.WinDLL)
|
| 12 |
+
else:
|
| 13 |
+
raise ImportError(f"{__name__} can only be imported on Windows")
|
| 14 |
+
|
| 15 |
+
import time
|
| 16 |
+
from ctypes import Structure, byref, wintypes
|
| 17 |
+
from typing import IO, NamedTuple, Type, cast
|
| 18 |
+
|
| 19 |
+
from pip._vendor.rich.color import ColorSystem
|
| 20 |
+
from pip._vendor.rich.style import Style
|
| 21 |
+
|
| 22 |
+
STDOUT = -11
|
| 23 |
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
|
| 24 |
+
|
| 25 |
+
COORD = wintypes._COORD
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class LegacyWindowsError(Exception):
|
| 29 |
+
pass
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class WindowsCoordinates(NamedTuple):
|
| 33 |
+
"""Coordinates in the Windows Console API are (y, x), not (x, y).
|
| 34 |
+
This class is intended to prevent that confusion.
|
| 35 |
+
Rows and columns are indexed from 0.
|
| 36 |
+
This class can be used in place of wintypes._COORD in arguments and argtypes.
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
row: int
|
| 40 |
+
col: int
|
| 41 |
+
|
| 42 |
+
@classmethod
|
| 43 |
+
def from_param(cls, value: "WindowsCoordinates") -> COORD:
|
| 44 |
+
"""Converts a WindowsCoordinates into a wintypes _COORD structure.
|
| 45 |
+
This classmethod is internally called by ctypes to perform the conversion.
|
| 46 |
+
|
| 47 |
+
Args:
|
| 48 |
+
value (WindowsCoordinates): The input coordinates to convert.
|
| 49 |
+
|
| 50 |
+
Returns:
|
| 51 |
+
wintypes._COORD: The converted coordinates struct.
|
| 52 |
+
"""
|
| 53 |
+
return COORD(value.col, value.row)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
|
| 57 |
+
_fields_ = [
|
| 58 |
+
("dwSize", COORD),
|
| 59 |
+
("dwCursorPosition", COORD),
|
| 60 |
+
("wAttributes", wintypes.WORD),
|
| 61 |
+
("srWindow", wintypes.SMALL_RECT),
|
| 62 |
+
("dwMaximumWindowSize", COORD),
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class CONSOLE_CURSOR_INFO(ctypes.Structure):
|
| 67 |
+
_fields_ = [("dwSize", wintypes.DWORD), ("bVisible", wintypes.BOOL)]
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
_GetStdHandle = windll.kernel32.GetStdHandle
|
| 71 |
+
_GetStdHandle.argtypes = [
|
| 72 |
+
wintypes.DWORD,
|
| 73 |
+
]
|
| 74 |
+
_GetStdHandle.restype = wintypes.HANDLE
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def GetStdHandle(handle: int = STDOUT) -> wintypes.HANDLE:
|
| 78 |
+
"""Retrieves a handle to the specified standard device (standard input, standard output, or standard error).
|
| 79 |
+
|
| 80 |
+
Args:
|
| 81 |
+
handle (int): Integer identifier for the handle. Defaults to -11 (stdout).
|
| 82 |
+
|
| 83 |
+
Returns:
|
| 84 |
+
wintypes.HANDLE: The handle
|
| 85 |
+
"""
|
| 86 |
+
return cast(wintypes.HANDLE, _GetStdHandle(handle))
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
_GetConsoleMode = windll.kernel32.GetConsoleMode
|
| 90 |
+
_GetConsoleMode.argtypes = [wintypes.HANDLE, wintypes.LPDWORD]
|
| 91 |
+
_GetConsoleMode.restype = wintypes.BOOL
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def GetConsoleMode(std_handle: wintypes.HANDLE) -> int:
|
| 95 |
+
"""Retrieves the current input mode of a console's input buffer
|
| 96 |
+
or the current output mode of a console screen buffer.
|
| 97 |
+
|
| 98 |
+
Args:
|
| 99 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 100 |
+
|
| 101 |
+
Raises:
|
| 102 |
+
LegacyWindowsError: If any error occurs while calling the Windows console API.
|
| 103 |
+
|
| 104 |
+
Returns:
|
| 105 |
+
int: Value representing the current console mode as documented at
|
| 106 |
+
https://docs.microsoft.com/en-us/windows/console/getconsolemode#parameters
|
| 107 |
+
"""
|
| 108 |
+
|
| 109 |
+
console_mode = wintypes.DWORD()
|
| 110 |
+
success = bool(_GetConsoleMode(std_handle, console_mode))
|
| 111 |
+
if not success:
|
| 112 |
+
raise LegacyWindowsError("Unable to get legacy Windows Console Mode")
|
| 113 |
+
return console_mode.value
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
_FillConsoleOutputCharacterW = windll.kernel32.FillConsoleOutputCharacterW
|
| 117 |
+
_FillConsoleOutputCharacterW.argtypes = [
|
| 118 |
+
wintypes.HANDLE,
|
| 119 |
+
ctypes.c_char,
|
| 120 |
+
wintypes.DWORD,
|
| 121 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 122 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 123 |
+
]
|
| 124 |
+
_FillConsoleOutputCharacterW.restype = wintypes.BOOL
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def FillConsoleOutputCharacter(
|
| 128 |
+
std_handle: wintypes.HANDLE,
|
| 129 |
+
char: str,
|
| 130 |
+
length: int,
|
| 131 |
+
start: WindowsCoordinates,
|
| 132 |
+
) -> int:
|
| 133 |
+
"""Writes a character to the console screen buffer a specified number of times, beginning at the specified coordinates.
|
| 134 |
+
|
| 135 |
+
Args:
|
| 136 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 137 |
+
char (str): The character to write. Must be a string of length 1.
|
| 138 |
+
length (int): The number of times to write the character.
|
| 139 |
+
start (WindowsCoordinates): The coordinates to start writing at.
|
| 140 |
+
|
| 141 |
+
Returns:
|
| 142 |
+
int: The number of characters written.
|
| 143 |
+
"""
|
| 144 |
+
character = ctypes.c_char(char.encode())
|
| 145 |
+
num_characters = wintypes.DWORD(length)
|
| 146 |
+
num_written = wintypes.DWORD(0)
|
| 147 |
+
_FillConsoleOutputCharacterW(
|
| 148 |
+
std_handle,
|
| 149 |
+
character,
|
| 150 |
+
num_characters,
|
| 151 |
+
start,
|
| 152 |
+
byref(num_written),
|
| 153 |
+
)
|
| 154 |
+
return num_written.value
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
|
| 158 |
+
_FillConsoleOutputAttribute.argtypes = [
|
| 159 |
+
wintypes.HANDLE,
|
| 160 |
+
wintypes.WORD,
|
| 161 |
+
wintypes.DWORD,
|
| 162 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 163 |
+
ctypes.POINTER(wintypes.DWORD),
|
| 164 |
+
]
|
| 165 |
+
_FillConsoleOutputAttribute.restype = wintypes.BOOL
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def FillConsoleOutputAttribute(
|
| 169 |
+
std_handle: wintypes.HANDLE,
|
| 170 |
+
attributes: int,
|
| 171 |
+
length: int,
|
| 172 |
+
start: WindowsCoordinates,
|
| 173 |
+
) -> int:
|
| 174 |
+
"""Sets the character attributes for a specified number of character cells,
|
| 175 |
+
beginning at the specified coordinates in a screen buffer.
|
| 176 |
+
|
| 177 |
+
Args:
|
| 178 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 179 |
+
attributes (int): Integer value representing the foreground and background colours of the cells.
|
| 180 |
+
length (int): The number of cells to set the output attribute of.
|
| 181 |
+
start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set.
|
| 182 |
+
|
| 183 |
+
Returns:
|
| 184 |
+
int: The number of cells whose attributes were actually set.
|
| 185 |
+
"""
|
| 186 |
+
num_cells = wintypes.DWORD(length)
|
| 187 |
+
style_attrs = wintypes.WORD(attributes)
|
| 188 |
+
num_written = wintypes.DWORD(0)
|
| 189 |
+
_FillConsoleOutputAttribute(
|
| 190 |
+
std_handle, style_attrs, num_cells, start, byref(num_written)
|
| 191 |
+
)
|
| 192 |
+
return num_written.value
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
|
| 196 |
+
_SetConsoleTextAttribute.argtypes = [
|
| 197 |
+
wintypes.HANDLE,
|
| 198 |
+
wintypes.WORD,
|
| 199 |
+
]
|
| 200 |
+
_SetConsoleTextAttribute.restype = wintypes.BOOL
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def SetConsoleTextAttribute(
|
| 204 |
+
std_handle: wintypes.HANDLE, attributes: wintypes.WORD
|
| 205 |
+
) -> bool:
|
| 206 |
+
"""Set the colour attributes for all text written after this function is called.
|
| 207 |
+
|
| 208 |
+
Args:
|
| 209 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 210 |
+
attributes (int): Integer value representing the foreground and background colours.
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
Returns:
|
| 214 |
+
bool: True if the attribute was set successfully, otherwise False.
|
| 215 |
+
"""
|
| 216 |
+
return bool(_SetConsoleTextAttribute(std_handle, attributes))
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
|
| 220 |
+
_GetConsoleScreenBufferInfo.argtypes = [
|
| 221 |
+
wintypes.HANDLE,
|
| 222 |
+
ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO),
|
| 223 |
+
]
|
| 224 |
+
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def GetConsoleScreenBufferInfo(
|
| 228 |
+
std_handle: wintypes.HANDLE,
|
| 229 |
+
) -> CONSOLE_SCREEN_BUFFER_INFO:
|
| 230 |
+
"""Retrieves information about the specified console screen buffer.
|
| 231 |
+
|
| 232 |
+
Args:
|
| 233 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 234 |
+
|
| 235 |
+
Returns:
|
| 236 |
+
CONSOLE_SCREEN_BUFFER_INFO: A CONSOLE_SCREEN_BUFFER_INFO ctype struct contain information about
|
| 237 |
+
screen size, cursor position, colour attributes, and more."""
|
| 238 |
+
console_screen_buffer_info = CONSOLE_SCREEN_BUFFER_INFO()
|
| 239 |
+
_GetConsoleScreenBufferInfo(std_handle, byref(console_screen_buffer_info))
|
| 240 |
+
return console_screen_buffer_info
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
|
| 244 |
+
_SetConsoleCursorPosition.argtypes = [
|
| 245 |
+
wintypes.HANDLE,
|
| 246 |
+
cast(Type[COORD], WindowsCoordinates),
|
| 247 |
+
]
|
| 248 |
+
_SetConsoleCursorPosition.restype = wintypes.BOOL
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def SetConsoleCursorPosition(
|
| 252 |
+
std_handle: wintypes.HANDLE, coords: WindowsCoordinates
|
| 253 |
+
) -> bool:
|
| 254 |
+
"""Set the position of the cursor in the console screen
|
| 255 |
+
|
| 256 |
+
Args:
|
| 257 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 258 |
+
coords (WindowsCoordinates): The coordinates to move the cursor to.
|
| 259 |
+
|
| 260 |
+
Returns:
|
| 261 |
+
bool: True if the function succeeds, otherwise False.
|
| 262 |
+
"""
|
| 263 |
+
return bool(_SetConsoleCursorPosition(std_handle, coords))
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
_GetConsoleCursorInfo = windll.kernel32.GetConsoleCursorInfo
|
| 267 |
+
_GetConsoleCursorInfo.argtypes = [
|
| 268 |
+
wintypes.HANDLE,
|
| 269 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 270 |
+
]
|
| 271 |
+
_GetConsoleCursorInfo.restype = wintypes.BOOL
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
def GetConsoleCursorInfo(
|
| 275 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 276 |
+
) -> bool:
|
| 277 |
+
"""Get the cursor info - used to get cursor visibility and width
|
| 278 |
+
|
| 279 |
+
Args:
|
| 280 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 281 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct that receives information
|
| 282 |
+
about the console's cursor.
|
| 283 |
+
|
| 284 |
+
Returns:
|
| 285 |
+
bool: True if the function succeeds, otherwise False.
|
| 286 |
+
"""
|
| 287 |
+
return bool(_GetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
_SetConsoleCursorInfo = windll.kernel32.SetConsoleCursorInfo
|
| 291 |
+
_SetConsoleCursorInfo.argtypes = [
|
| 292 |
+
wintypes.HANDLE,
|
| 293 |
+
ctypes.POINTER(CONSOLE_CURSOR_INFO),
|
| 294 |
+
]
|
| 295 |
+
_SetConsoleCursorInfo.restype = wintypes.BOOL
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
def SetConsoleCursorInfo(
|
| 299 |
+
std_handle: wintypes.HANDLE, cursor_info: CONSOLE_CURSOR_INFO
|
| 300 |
+
) -> bool:
|
| 301 |
+
"""Set the cursor info - used for adjusting cursor visibility and width
|
| 302 |
+
|
| 303 |
+
Args:
|
| 304 |
+
std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
|
| 305 |
+
cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct containing the new cursor info.
|
| 306 |
+
|
| 307 |
+
Returns:
|
| 308 |
+
bool: True if the function succeeds, otherwise False.
|
| 309 |
+
"""
|
| 310 |
+
return bool(_SetConsoleCursorInfo(std_handle, byref(cursor_info)))
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
_SetConsoleTitle = windll.kernel32.SetConsoleTitleW
|
| 314 |
+
_SetConsoleTitle.argtypes = [wintypes.LPCWSTR]
|
| 315 |
+
_SetConsoleTitle.restype = wintypes.BOOL
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
def SetConsoleTitle(title: str) -> bool:
|
| 319 |
+
"""Sets the title of the current console window
|
| 320 |
+
|
| 321 |
+
Args:
|
| 322 |
+
title (str): The new title of the console window.
|
| 323 |
+
|
| 324 |
+
Returns:
|
| 325 |
+
bool: True if the function succeeds, otherwise False.
|
| 326 |
+
"""
|
| 327 |
+
return bool(_SetConsoleTitle(title))
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
class LegacyWindowsTerm:
|
| 331 |
+
"""This class allows interaction with the legacy Windows Console API. It should only be used in the context
|
| 332 |
+
of environments where virtual terminal processing is not available. However, if it is used in a Windows environment,
|
| 333 |
+
the entire API should work.
|
| 334 |
+
|
| 335 |
+
Args:
|
| 336 |
+
file (IO[str]): The file which the Windows Console API HANDLE is retrieved from, defaults to sys.stdout.
|
| 337 |
+
"""
|
| 338 |
+
|
| 339 |
+
BRIGHT_BIT = 8
|
| 340 |
+
|
| 341 |
+
# Indices are ANSI color numbers, values are the corresponding Windows Console API color numbers
|
| 342 |
+
ANSI_TO_WINDOWS = [
|
| 343 |
+
0, # black The Windows colours are defined in wincon.h as follows:
|
| 344 |
+
4, # red define FOREGROUND_BLUE 0x0001 -- 0000 0001
|
| 345 |
+
2, # green define FOREGROUND_GREEN 0x0002 -- 0000 0010
|
| 346 |
+
6, # yellow define FOREGROUND_RED 0x0004 -- 0000 0100
|
| 347 |
+
1, # blue define FOREGROUND_INTENSITY 0x0008 -- 0000 1000
|
| 348 |
+
5, # magenta define BACKGROUND_BLUE 0x0010 -- 0001 0000
|
| 349 |
+
3, # cyan define BACKGROUND_GREEN 0x0020 -- 0010 0000
|
| 350 |
+
7, # white define BACKGROUND_RED 0x0040 -- 0100 0000
|
| 351 |
+
8, # bright black (grey) define BACKGROUND_INTENSITY 0x0080 -- 1000 0000
|
| 352 |
+
12, # bright red
|
| 353 |
+
10, # bright green
|
| 354 |
+
14, # bright yellow
|
| 355 |
+
9, # bright blue
|
| 356 |
+
13, # bright magenta
|
| 357 |
+
11, # bright cyan
|
| 358 |
+
15, # bright white
|
| 359 |
+
]
|
| 360 |
+
|
| 361 |
+
def __init__(self, file: "IO[str]") -> None:
|
| 362 |
+
handle = GetStdHandle(STDOUT)
|
| 363 |
+
self._handle = handle
|
| 364 |
+
default_text = GetConsoleScreenBufferInfo(handle).wAttributes
|
| 365 |
+
self._default_text = default_text
|
| 366 |
+
|
| 367 |
+
self._default_fore = default_text & 7
|
| 368 |
+
self._default_back = (default_text >> 4) & 7
|
| 369 |
+
self._default_attrs = self._default_fore | (self._default_back << 4)
|
| 370 |
+
|
| 371 |
+
self._file = file
|
| 372 |
+
self.write = file.write
|
| 373 |
+
self.flush = file.flush
|
| 374 |
+
|
| 375 |
+
@property
|
| 376 |
+
def cursor_position(self) -> WindowsCoordinates:
|
| 377 |
+
"""Returns the current position of the cursor (0-based)
|
| 378 |
+
|
| 379 |
+
Returns:
|
| 380 |
+
WindowsCoordinates: The current cursor position.
|
| 381 |
+
"""
|
| 382 |
+
coord: COORD = GetConsoleScreenBufferInfo(self._handle).dwCursorPosition
|
| 383 |
+
return WindowsCoordinates(row=cast(int, coord.Y), col=cast(int, coord.X))
|
| 384 |
+
|
| 385 |
+
@property
|
| 386 |
+
def screen_size(self) -> WindowsCoordinates:
|
| 387 |
+
"""Returns the current size of the console screen buffer, in character columns and rows
|
| 388 |
+
|
| 389 |
+
Returns:
|
| 390 |
+
WindowsCoordinates: The width and height of the screen as WindowsCoordinates.
|
| 391 |
+
"""
|
| 392 |
+
screen_size: COORD = GetConsoleScreenBufferInfo(self._handle).dwSize
|
| 393 |
+
return WindowsCoordinates(
|
| 394 |
+
row=cast(int, screen_size.Y), col=cast(int, screen_size.X)
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
def write_text(self, text: str) -> None:
|
| 398 |
+
"""Write text directly to the terminal without any modification of styles
|
| 399 |
+
|
| 400 |
+
Args:
|
| 401 |
+
text (str): The text to write to the console
|
| 402 |
+
"""
|
| 403 |
+
self.write(text)
|
| 404 |
+
self.flush()
|
| 405 |
+
|
| 406 |
+
def write_styled(self, text: str, style: Style) -> None:
|
| 407 |
+
"""Write styled text to the terminal.
|
| 408 |
+
|
| 409 |
+
Args:
|
| 410 |
+
text (str): The text to write
|
| 411 |
+
style (Style): The style of the text
|
| 412 |
+
"""
|
| 413 |
+
color = style.color
|
| 414 |
+
bgcolor = style.bgcolor
|
| 415 |
+
if style.reverse:
|
| 416 |
+
color, bgcolor = bgcolor, color
|
| 417 |
+
|
| 418 |
+
if color:
|
| 419 |
+
fore = color.downgrade(ColorSystem.WINDOWS).number
|
| 420 |
+
fore = fore if fore is not None else 7 # Default to ANSI 7: White
|
| 421 |
+
if style.bold:
|
| 422 |
+
fore = fore | self.BRIGHT_BIT
|
| 423 |
+
if style.dim:
|
| 424 |
+
fore = fore & ~self.BRIGHT_BIT
|
| 425 |
+
fore = self.ANSI_TO_WINDOWS[fore]
|
| 426 |
+
else:
|
| 427 |
+
fore = self._default_fore
|
| 428 |
+
|
| 429 |
+
if bgcolor:
|
| 430 |
+
back = bgcolor.downgrade(ColorSystem.WINDOWS).number
|
| 431 |
+
back = back if back is not None else 0 # Default to ANSI 0: Black
|
| 432 |
+
back = self.ANSI_TO_WINDOWS[back]
|
| 433 |
+
else:
|
| 434 |
+
back = self._default_back
|
| 435 |
+
|
| 436 |
+
assert fore is not None
|
| 437 |
+
assert back is not None
|
| 438 |
+
|
| 439 |
+
SetConsoleTextAttribute(
|
| 440 |
+
self._handle, attributes=ctypes.c_ushort(fore | (back << 4))
|
| 441 |
+
)
|
| 442 |
+
self.write_text(text)
|
| 443 |
+
SetConsoleTextAttribute(self._handle, attributes=self._default_text)
|
| 444 |
+
|
| 445 |
+
def move_cursor_to(self, new_position: WindowsCoordinates) -> None:
|
| 446 |
+
"""Set the position of the cursor
|
| 447 |
+
|
| 448 |
+
Args:
|
| 449 |
+
new_position (WindowsCoordinates): The WindowsCoordinates representing the new position of the cursor.
|
| 450 |
+
"""
|
| 451 |
+
if new_position.col < 0 or new_position.row < 0:
|
| 452 |
+
return
|
| 453 |
+
SetConsoleCursorPosition(self._handle, coords=new_position)
|
| 454 |
+
|
| 455 |
+
def erase_line(self) -> None:
|
| 456 |
+
"""Erase all content on the line the cursor is currently located at"""
|
| 457 |
+
screen_size = self.screen_size
|
| 458 |
+
cursor_position = self.cursor_position
|
| 459 |
+
cells_to_erase = screen_size.col
|
| 460 |
+
start_coordinates = WindowsCoordinates(row=cursor_position.row, col=0)
|
| 461 |
+
FillConsoleOutputCharacter(
|
| 462 |
+
self._handle, " ", length=cells_to_erase, start=start_coordinates
|
| 463 |
+
)
|
| 464 |
+
FillConsoleOutputAttribute(
|
| 465 |
+
self._handle,
|
| 466 |
+
self._default_attrs,
|
| 467 |
+
length=cells_to_erase,
|
| 468 |
+
start=start_coordinates,
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
def erase_end_of_line(self) -> None:
|
| 472 |
+
"""Erase all content from the cursor position to the end of that line"""
|
| 473 |
+
cursor_position = self.cursor_position
|
| 474 |
+
cells_to_erase = self.screen_size.col - cursor_position.col
|
| 475 |
+
FillConsoleOutputCharacter(
|
| 476 |
+
self._handle, " ", length=cells_to_erase, start=cursor_position
|
| 477 |
+
)
|
| 478 |
+
FillConsoleOutputAttribute(
|
| 479 |
+
self._handle,
|
| 480 |
+
self._default_attrs,
|
| 481 |
+
length=cells_to_erase,
|
| 482 |
+
start=cursor_position,
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
def erase_start_of_line(self) -> None:
|
| 486 |
+
"""Erase all content from the cursor position to the start of that line"""
|
| 487 |
+
row, col = self.cursor_position
|
| 488 |
+
start = WindowsCoordinates(row, 0)
|
| 489 |
+
FillConsoleOutputCharacter(self._handle, " ", length=col, start=start)
|
| 490 |
+
FillConsoleOutputAttribute(
|
| 491 |
+
self._handle, self._default_attrs, length=col, start=start
|
| 492 |
+
)
|
| 493 |
+
|
| 494 |
+
def move_cursor_up(self) -> None:
|
| 495 |
+
"""Move the cursor up a single cell"""
|
| 496 |
+
cursor_position = self.cursor_position
|
| 497 |
+
SetConsoleCursorPosition(
|
| 498 |
+
self._handle,
|
| 499 |
+
coords=WindowsCoordinates(
|
| 500 |
+
row=cursor_position.row - 1, col=cursor_position.col
|
| 501 |
+
),
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
def move_cursor_down(self) -> None:
|
| 505 |
+
"""Move the cursor down a single cell"""
|
| 506 |
+
cursor_position = self.cursor_position
|
| 507 |
+
SetConsoleCursorPosition(
|
| 508 |
+
self._handle,
|
| 509 |
+
coords=WindowsCoordinates(
|
| 510 |
+
row=cursor_position.row + 1,
|
| 511 |
+
col=cursor_position.col,
|
| 512 |
+
),
|
| 513 |
+
)
|
| 514 |
+
|
| 515 |
+
def move_cursor_forward(self) -> None:
|
| 516 |
+
"""Move the cursor forward a single cell. Wrap to the next line if required."""
|
| 517 |
+
row, col = self.cursor_position
|
| 518 |
+
if col == self.screen_size.col - 1:
|
| 519 |
+
row += 1
|
| 520 |
+
col = 0
|
| 521 |
+
else:
|
| 522 |
+
col += 1
|
| 523 |
+
SetConsoleCursorPosition(
|
| 524 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 525 |
+
)
|
| 526 |
+
|
| 527 |
+
def move_cursor_to_column(self, column: int) -> None:
|
| 528 |
+
"""Move cursor to the column specified by the zero-based column index, staying on the same row
|
| 529 |
+
|
| 530 |
+
Args:
|
| 531 |
+
column (int): The zero-based column index to move the cursor to.
|
| 532 |
+
"""
|
| 533 |
+
row, _ = self.cursor_position
|
| 534 |
+
SetConsoleCursorPosition(self._handle, coords=WindowsCoordinates(row, column))
|
| 535 |
+
|
| 536 |
+
def move_cursor_backward(self) -> None:
|
| 537 |
+
"""Move the cursor backward a single cell. Wrap to the previous line if required."""
|
| 538 |
+
row, col = self.cursor_position
|
| 539 |
+
if col == 0:
|
| 540 |
+
row -= 1
|
| 541 |
+
col = self.screen_size.col - 1
|
| 542 |
+
else:
|
| 543 |
+
col -= 1
|
| 544 |
+
SetConsoleCursorPosition(
|
| 545 |
+
self._handle, coords=WindowsCoordinates(row=row, col=col)
|
| 546 |
+
)
|
| 547 |
+
|
| 548 |
+
def hide_cursor(self) -> None:
|
| 549 |
+
"""Hide the cursor"""
|
| 550 |
+
current_cursor_size = self._get_cursor_size()
|
| 551 |
+
invisible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=0)
|
| 552 |
+
SetConsoleCursorInfo(self._handle, cursor_info=invisible_cursor)
|
| 553 |
+
|
| 554 |
+
def show_cursor(self) -> None:
|
| 555 |
+
"""Show the cursor"""
|
| 556 |
+
current_cursor_size = self._get_cursor_size()
|
| 557 |
+
visible_cursor = CONSOLE_CURSOR_INFO(dwSize=current_cursor_size, bVisible=1)
|
| 558 |
+
SetConsoleCursorInfo(self._handle, cursor_info=visible_cursor)
|
| 559 |
+
|
| 560 |
+
def set_title(self, title: str) -> None:
|
| 561 |
+
"""Set the title of the terminal window
|
| 562 |
+
|
| 563 |
+
Args:
|
| 564 |
+
title (str): The new title of the console window
|
| 565 |
+
"""
|
| 566 |
+
assert len(title) < 255, "Console title must be less than 255 characters"
|
| 567 |
+
SetConsoleTitle(title)
|
| 568 |
+
|
| 569 |
+
def _get_cursor_size(self) -> int:
|
| 570 |
+
"""Get the percentage of the character cell that is filled by the cursor"""
|
| 571 |
+
cursor_info = CONSOLE_CURSOR_INFO()
|
| 572 |
+
GetConsoleCursorInfo(self._handle, cursor_info=cursor_info)
|
| 573 |
+
return int(cursor_info.dwSize)
|
| 574 |
+
|
| 575 |
+
|
| 576 |
+
if __name__ == "__main__":
|
| 577 |
+
handle = GetStdHandle()
|
| 578 |
+
|
| 579 |
+
from pip._vendor.rich.console import Console
|
| 580 |
+
|
| 581 |
+
console = Console()
|
| 582 |
+
|
| 583 |
+
term = LegacyWindowsTerm(sys.stdout)
|
| 584 |
+
term.set_title("Win32 Console Examples")
|
| 585 |
+
|
| 586 |
+
style = Style(color="black", bgcolor="red")
|
| 587 |
+
|
| 588 |
+
heading = Style.parse("black on green")
|
| 589 |
+
|
| 590 |
+
# Check colour output
|
| 591 |
+
console.rule("Checking colour output")
|
| 592 |
+
console.print("[on red]on red!")
|
| 593 |
+
console.print("[blue]blue!")
|
| 594 |
+
console.print("[yellow]yellow!")
|
| 595 |
+
console.print("[bold yellow]bold yellow!")
|
| 596 |
+
console.print("[bright_yellow]bright_yellow!")
|
| 597 |
+
console.print("[dim bright_yellow]dim bright_yellow!")
|
| 598 |
+
console.print("[italic cyan]italic cyan!")
|
| 599 |
+
console.print("[bold white on blue]bold white on blue!")
|
| 600 |
+
console.print("[reverse bold white on blue]reverse bold white on blue!")
|
| 601 |
+
console.print("[bold black on cyan]bold black on cyan!")
|
| 602 |
+
console.print("[black on green]black on green!")
|
| 603 |
+
console.print("[blue on green]blue on green!")
|
| 604 |
+
console.print("[white on black]white on black!")
|
| 605 |
+
console.print("[black on white]black on white!")
|
| 606 |
+
console.print("[#1BB152 on #DA812D]#1BB152 on #DA812D!")
|
| 607 |
+
|
| 608 |
+
# Check cursor movement
|
| 609 |
+
console.rule("Checking cursor movement")
|
| 610 |
+
console.print()
|
| 611 |
+
term.move_cursor_backward()
|
| 612 |
+
term.move_cursor_backward()
|
| 613 |
+
term.write_text("went back and wrapped to prev line")
|
| 614 |
+
time.sleep(1)
|
| 615 |
+
term.move_cursor_up()
|
| 616 |
+
term.write_text("we go up")
|
| 617 |
+
time.sleep(1)
|
| 618 |
+
term.move_cursor_down()
|
| 619 |
+
term.write_text("and down")
|
| 620 |
+
time.sleep(1)
|
| 621 |
+
term.move_cursor_up()
|
| 622 |
+
term.move_cursor_backward()
|
| 623 |
+
term.move_cursor_backward()
|
| 624 |
+
term.write_text("we went up and back 2")
|
| 625 |
+
time.sleep(1)
|
| 626 |
+
term.move_cursor_down()
|
| 627 |
+
term.move_cursor_backward()
|
| 628 |
+
term.move_cursor_backward()
|
| 629 |
+
term.write_text("we went down and back 2")
|
| 630 |
+
time.sleep(1)
|
| 631 |
+
|
| 632 |
+
# Check erasing of lines
|
| 633 |
+
term.hide_cursor()
|
| 634 |
+
console.print()
|
| 635 |
+
console.rule("Checking line erasing")
|
| 636 |
+
console.print("\n...Deleting to the start of the line...")
|
| 637 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 638 |
+
time.sleep(1)
|
| 639 |
+
term.move_cursor_to_column(16)
|
| 640 |
+
term.write_styled("<", Style.parse("black on red"))
|
| 641 |
+
term.move_cursor_backward()
|
| 642 |
+
time.sleep(1)
|
| 643 |
+
term.erase_start_of_line()
|
| 644 |
+
time.sleep(1)
|
| 645 |
+
|
| 646 |
+
console.print("\n\n...And to the end of the line...")
|
| 647 |
+
term.write_text("The red arrow shows the cursor location, and direction of erase")
|
| 648 |
+
time.sleep(1)
|
| 649 |
+
|
| 650 |
+
term.move_cursor_to_column(16)
|
| 651 |
+
term.write_styled(">", Style.parse("black on red"))
|
| 652 |
+
time.sleep(1)
|
| 653 |
+
term.erase_end_of_line()
|
| 654 |
+
time.sleep(1)
|
| 655 |
+
|
| 656 |
+
console.print("\n\n...Now the whole line will be erased...")
|
| 657 |
+
term.write_styled("I'm going to disappear!", style=Style.parse("black on cyan"))
|
| 658 |
+
time.sleep(1)
|
| 659 |
+
term.erase_line()
|
| 660 |
+
|
| 661 |
+
term.show_cursor()
|
| 662 |
+
print("\n")
|
.venv/Lib/site-packages/pip/_vendor/rich/_windows.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from dataclasses import dataclass
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@dataclass
|
| 6 |
+
class WindowsConsoleFeatures:
|
| 7 |
+
"""Windows features available."""
|
| 8 |
+
|
| 9 |
+
vt: bool = False
|
| 10 |
+
"""The console supports VT codes."""
|
| 11 |
+
truecolor: bool = False
|
| 12 |
+
"""The console supports truecolor."""
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
import ctypes
|
| 17 |
+
from ctypes import LibraryLoader
|
| 18 |
+
|
| 19 |
+
if sys.platform == "win32":
|
| 20 |
+
windll = LibraryLoader(ctypes.WinDLL)
|
| 21 |
+
else:
|
| 22 |
+
windll = None
|
| 23 |
+
raise ImportError("Not windows")
|
| 24 |
+
|
| 25 |
+
from pip._vendor.rich._win32_console import (
|
| 26 |
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING,
|
| 27 |
+
GetConsoleMode,
|
| 28 |
+
GetStdHandle,
|
| 29 |
+
LegacyWindowsError,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
except (AttributeError, ImportError, ValueError):
|
| 33 |
+
|
| 34 |
+
# Fallback if we can't load the Windows DLL
|
| 35 |
+
def get_windows_console_features() -> WindowsConsoleFeatures:
|
| 36 |
+
features = WindowsConsoleFeatures()
|
| 37 |
+
return features
|
| 38 |
+
|
| 39 |
+
else:
|
| 40 |
+
|
| 41 |
+
def get_windows_console_features() -> WindowsConsoleFeatures:
|
| 42 |
+
"""Get windows console features.
|
| 43 |
+
|
| 44 |
+
Returns:
|
| 45 |
+
WindowsConsoleFeatures: An instance of WindowsConsoleFeatures.
|
| 46 |
+
"""
|
| 47 |
+
handle = GetStdHandle()
|
| 48 |
+
try:
|
| 49 |
+
console_mode = GetConsoleMode(handle)
|
| 50 |
+
success = True
|
| 51 |
+
except LegacyWindowsError:
|
| 52 |
+
console_mode = 0
|
| 53 |
+
success = False
|
| 54 |
+
vt = bool(success and console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
| 55 |
+
truecolor = False
|
| 56 |
+
if vt:
|
| 57 |
+
win_version = sys.getwindowsversion()
|
| 58 |
+
truecolor = win_version.major > 10 or (
|
| 59 |
+
win_version.major == 10 and win_version.build >= 15063
|
| 60 |
+
)
|
| 61 |
+
features = WindowsConsoleFeatures(vt=vt, truecolor=truecolor)
|
| 62 |
+
return features
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
if __name__ == "__main__":
|
| 66 |
+
import platform
|
| 67 |
+
|
| 68 |
+
features = get_windows_console_features()
|
| 69 |
+
from pip._vendor.rich import print
|
| 70 |
+
|
| 71 |
+
print(f'platform="{platform.system()}"')
|
| 72 |
+
print(repr(features))
|
.venv/Lib/site-packages/pip/_vendor/rich/_windows_renderer.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Iterable, Sequence, Tuple, cast
|
| 2 |
+
|
| 3 |
+
from pip._vendor.rich._win32_console import LegacyWindowsTerm, WindowsCoordinates
|
| 4 |
+
from pip._vendor.rich.segment import ControlCode, ControlType, Segment
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def legacy_windows_render(buffer: Iterable[Segment], term: LegacyWindowsTerm) -> None:
|
| 8 |
+
"""Makes appropriate Windows Console API calls based on the segments in the buffer.
|
| 9 |
+
|
| 10 |
+
Args:
|
| 11 |
+
buffer (Iterable[Segment]): Iterable of Segments to convert to Win32 API calls.
|
| 12 |
+
term (LegacyWindowsTerm): Used to call the Windows Console API.
|
| 13 |
+
"""
|
| 14 |
+
for text, style, control in buffer:
|
| 15 |
+
if not control:
|
| 16 |
+
if style:
|
| 17 |
+
term.write_styled(text, style)
|
| 18 |
+
else:
|
| 19 |
+
term.write_text(text)
|
| 20 |
+
else:
|
| 21 |
+
control_codes: Sequence[ControlCode] = control
|
| 22 |
+
for control_code in control_codes:
|
| 23 |
+
control_type = control_code[0]
|
| 24 |
+
if control_type == ControlType.CURSOR_MOVE_TO:
|
| 25 |
+
_, x, y = cast(Tuple[ControlType, int, int], control_code)
|
| 26 |
+
term.move_cursor_to(WindowsCoordinates(row=y - 1, col=x - 1))
|
| 27 |
+
elif control_type == ControlType.CARRIAGE_RETURN:
|
| 28 |
+
term.write_text("\r")
|
| 29 |
+
elif control_type == ControlType.HOME:
|
| 30 |
+
term.move_cursor_to(WindowsCoordinates(0, 0))
|
| 31 |
+
elif control_type == ControlType.CURSOR_UP:
|
| 32 |
+
term.move_cursor_up()
|
| 33 |
+
elif control_type == ControlType.CURSOR_DOWN:
|
| 34 |
+
term.move_cursor_down()
|
| 35 |
+
elif control_type == ControlType.CURSOR_FORWARD:
|
| 36 |
+
term.move_cursor_forward()
|
| 37 |
+
elif control_type == ControlType.CURSOR_BACKWARD:
|
| 38 |
+
term.move_cursor_backward()
|
| 39 |
+
elif control_type == ControlType.CURSOR_MOVE_TO_COLUMN:
|
| 40 |
+
_, column = cast(Tuple[ControlType, int], control_code)
|
| 41 |
+
term.move_cursor_to_column(column - 1)
|
| 42 |
+
elif control_type == ControlType.HIDE_CURSOR:
|
| 43 |
+
term.hide_cursor()
|
| 44 |
+
elif control_type == ControlType.SHOW_CURSOR:
|
| 45 |
+
term.show_cursor()
|
| 46 |
+
elif control_type == ControlType.ERASE_IN_LINE:
|
| 47 |
+
_, mode = cast(Tuple[ControlType, int], control_code)
|
| 48 |
+
if mode == 0:
|
| 49 |
+
term.erase_end_of_line()
|
| 50 |
+
elif mode == 1:
|
| 51 |
+
term.erase_start_of_line()
|
| 52 |
+
elif mode == 2:
|
| 53 |
+
term.erase_line()
|
| 54 |
+
elif control_type == ControlType.SET_WINDOW_TITLE:
|
| 55 |
+
_, title = cast(Tuple[ControlType, str], control_code)
|
| 56 |
+
term.set_title(title)
|
.venv/Lib/site-packages/pip/_vendor/rich/_wrap.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Iterable, List, Tuple
|
| 3 |
+
|
| 4 |
+
from ._loop import loop_last
|
| 5 |
+
from .cells import cell_len, chop_cells
|
| 6 |
+
|
| 7 |
+
re_word = re.compile(r"\s*\S+\s*")
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def words(text: str) -> Iterable[Tuple[int, int, str]]:
|
| 11 |
+
position = 0
|
| 12 |
+
word_match = re_word.match(text, position)
|
| 13 |
+
while word_match is not None:
|
| 14 |
+
start, end = word_match.span()
|
| 15 |
+
word = word_match.group(0)
|
| 16 |
+
yield start, end, word
|
| 17 |
+
word_match = re_word.match(text, end)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def divide_line(text: str, width: int, fold: bool = True) -> List[int]:
|
| 21 |
+
divides: List[int] = []
|
| 22 |
+
append = divides.append
|
| 23 |
+
line_position = 0
|
| 24 |
+
_cell_len = cell_len
|
| 25 |
+
for start, _end, word in words(text):
|
| 26 |
+
word_length = _cell_len(word.rstrip())
|
| 27 |
+
if line_position + word_length > width:
|
| 28 |
+
if word_length > width:
|
| 29 |
+
if fold:
|
| 30 |
+
chopped_words = chop_cells(word, max_size=width, position=0)
|
| 31 |
+
for last, line in loop_last(chopped_words):
|
| 32 |
+
if start:
|
| 33 |
+
append(start)
|
| 34 |
+
|
| 35 |
+
if last:
|
| 36 |
+
line_position = _cell_len(line)
|
| 37 |
+
else:
|
| 38 |
+
start += len(line)
|
| 39 |
+
else:
|
| 40 |
+
if start:
|
| 41 |
+
append(start)
|
| 42 |
+
line_position = _cell_len(word)
|
| 43 |
+
elif line_position and start:
|
| 44 |
+
append(start)
|
| 45 |
+
line_position = _cell_len(word)
|
| 46 |
+
else:
|
| 47 |
+
line_position += _cell_len(word)
|
| 48 |
+
return divides
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if __name__ == "__main__": # pragma: no cover
|
| 52 |
+
from .console import Console
|
| 53 |
+
|
| 54 |
+
console = Console(width=10)
|
| 55 |
+
console.print("12345 abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ 12345")
|
| 56 |
+
print(chop_cells("abcdefghijklmnopqrstuvwxyz", 10, position=2))
|
.venv/Lib/site-packages/pip/_vendor/tenacity/__init__.py
ADDED
|
@@ -0,0 +1,608 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016-2018 Julien Danjou
|
| 2 |
+
# Copyright 2017 Elisey Zanko
|
| 3 |
+
# Copyright 2016 Étienne Bersac
|
| 4 |
+
# Copyright 2016 Joshua Harlow
|
| 5 |
+
# Copyright 2013-2014 Ray Holder
|
| 6 |
+
#
|
| 7 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 |
+
# you may not use this file except in compliance with the License.
|
| 9 |
+
# You may obtain a copy of the License at
|
| 10 |
+
#
|
| 11 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 12 |
+
#
|
| 13 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 14 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 |
+
# See the License for the specific language governing permissions and
|
| 17 |
+
# limitations under the License.
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
import functools
|
| 21 |
+
import sys
|
| 22 |
+
import threading
|
| 23 |
+
import time
|
| 24 |
+
import typing as t
|
| 25 |
+
import warnings
|
| 26 |
+
from abc import ABC, abstractmethod
|
| 27 |
+
from concurrent import futures
|
| 28 |
+
from inspect import iscoroutinefunction
|
| 29 |
+
|
| 30 |
+
# Import all built-in retry strategies for easier usage.
|
| 31 |
+
from .retry import retry_base # noqa
|
| 32 |
+
from .retry import retry_all # noqa
|
| 33 |
+
from .retry import retry_always # noqa
|
| 34 |
+
from .retry import retry_any # noqa
|
| 35 |
+
from .retry import retry_if_exception # noqa
|
| 36 |
+
from .retry import retry_if_exception_type # noqa
|
| 37 |
+
from .retry import retry_if_exception_cause_type # noqa
|
| 38 |
+
from .retry import retry_if_not_exception_type # noqa
|
| 39 |
+
from .retry import retry_if_not_result # noqa
|
| 40 |
+
from .retry import retry_if_result # noqa
|
| 41 |
+
from .retry import retry_never # noqa
|
| 42 |
+
from .retry import retry_unless_exception_type # noqa
|
| 43 |
+
from .retry import retry_if_exception_message # noqa
|
| 44 |
+
from .retry import retry_if_not_exception_message # noqa
|
| 45 |
+
|
| 46 |
+
# Import all nap strategies for easier usage.
|
| 47 |
+
from .nap import sleep # noqa
|
| 48 |
+
from .nap import sleep_using_event # noqa
|
| 49 |
+
|
| 50 |
+
# Import all built-in stop strategies for easier usage.
|
| 51 |
+
from .stop import stop_after_attempt # noqa
|
| 52 |
+
from .stop import stop_after_delay # noqa
|
| 53 |
+
from .stop import stop_all # noqa
|
| 54 |
+
from .stop import stop_any # noqa
|
| 55 |
+
from .stop import stop_never # noqa
|
| 56 |
+
from .stop import stop_when_event_set # noqa
|
| 57 |
+
|
| 58 |
+
# Import all built-in wait strategies for easier usage.
|
| 59 |
+
from .wait import wait_chain # noqa
|
| 60 |
+
from .wait import wait_combine # noqa
|
| 61 |
+
from .wait import wait_exponential # noqa
|
| 62 |
+
from .wait import wait_fixed # noqa
|
| 63 |
+
from .wait import wait_incrementing # noqa
|
| 64 |
+
from .wait import wait_none # noqa
|
| 65 |
+
from .wait import wait_random # noqa
|
| 66 |
+
from .wait import wait_random_exponential # noqa
|
| 67 |
+
from .wait import wait_random_exponential as wait_full_jitter # noqa
|
| 68 |
+
from .wait import wait_exponential_jitter # noqa
|
| 69 |
+
|
| 70 |
+
# Import all built-in before strategies for easier usage.
|
| 71 |
+
from .before import before_log # noqa
|
| 72 |
+
from .before import before_nothing # noqa
|
| 73 |
+
|
| 74 |
+
# Import all built-in after strategies for easier usage.
|
| 75 |
+
from .after import after_log # noqa
|
| 76 |
+
from .after import after_nothing # noqa
|
| 77 |
+
|
| 78 |
+
# Import all built-in after strategies for easier usage.
|
| 79 |
+
from .before_sleep import before_sleep_log # noqa
|
| 80 |
+
from .before_sleep import before_sleep_nothing # noqa
|
| 81 |
+
|
| 82 |
+
# Replace a conditional import with a hard-coded None so that pip does
|
| 83 |
+
# not attempt to use tornado even if it is present in the environment.
|
| 84 |
+
# If tornado is non-None, tenacity will attempt to execute some code
|
| 85 |
+
# that is sensitive to the version of tornado, which could break pip
|
| 86 |
+
# if an old version is found.
|
| 87 |
+
tornado = None # type: ignore
|
| 88 |
+
|
| 89 |
+
if t.TYPE_CHECKING:
|
| 90 |
+
import types
|
| 91 |
+
|
| 92 |
+
from .retry import RetryBaseT
|
| 93 |
+
from .stop import StopBaseT
|
| 94 |
+
from .wait import WaitBaseT
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
WrappedFnReturnT = t.TypeVar("WrappedFnReturnT")
|
| 98 |
+
WrappedFn = t.TypeVar("WrappedFn", bound=t.Callable[..., t.Any])
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
class TryAgain(Exception):
|
| 102 |
+
"""Always retry the executed function when raised."""
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
NO_RESULT = object()
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class DoAttempt:
|
| 109 |
+
pass
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class DoSleep(float):
|
| 113 |
+
pass
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class BaseAction:
|
| 117 |
+
"""Base class for representing actions to take by retry object.
|
| 118 |
+
|
| 119 |
+
Concrete implementations must define:
|
| 120 |
+
- __init__: to initialize all necessary fields
|
| 121 |
+
- REPR_FIELDS: class variable specifying attributes to include in repr(self)
|
| 122 |
+
- NAME: for identification in retry object methods and callbacks
|
| 123 |
+
"""
|
| 124 |
+
|
| 125 |
+
REPR_FIELDS: t.Sequence[str] = ()
|
| 126 |
+
NAME: t.Optional[str] = None
|
| 127 |
+
|
| 128 |
+
def __repr__(self) -> str:
|
| 129 |
+
state_str = ", ".join(f"{field}={getattr(self, field)!r}" for field in self.REPR_FIELDS)
|
| 130 |
+
return f"{self.__class__.__name__}({state_str})"
|
| 131 |
+
|
| 132 |
+
def __str__(self) -> str:
|
| 133 |
+
return repr(self)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class RetryAction(BaseAction):
|
| 137 |
+
REPR_FIELDS = ("sleep",)
|
| 138 |
+
NAME = "retry"
|
| 139 |
+
|
| 140 |
+
def __init__(self, sleep: t.SupportsFloat) -> None:
|
| 141 |
+
self.sleep = float(sleep)
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
_unset = object()
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def _first_set(first: t.Union[t.Any, object], second: t.Any) -> t.Any:
|
| 148 |
+
return second if first is _unset else first
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
class RetryError(Exception):
|
| 152 |
+
"""Encapsulates the last attempt instance right before giving up."""
|
| 153 |
+
|
| 154 |
+
def __init__(self, last_attempt: "Future") -> None:
|
| 155 |
+
self.last_attempt = last_attempt
|
| 156 |
+
super().__init__(last_attempt)
|
| 157 |
+
|
| 158 |
+
def reraise(self) -> "t.NoReturn":
|
| 159 |
+
if self.last_attempt.failed:
|
| 160 |
+
raise self.last_attempt.result()
|
| 161 |
+
raise self
|
| 162 |
+
|
| 163 |
+
def __str__(self) -> str:
|
| 164 |
+
return f"{self.__class__.__name__}[{self.last_attempt}]"
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
class AttemptManager:
|
| 168 |
+
"""Manage attempt context."""
|
| 169 |
+
|
| 170 |
+
def __init__(self, retry_state: "RetryCallState"):
|
| 171 |
+
self.retry_state = retry_state
|
| 172 |
+
|
| 173 |
+
def __enter__(self) -> None:
|
| 174 |
+
pass
|
| 175 |
+
|
| 176 |
+
def __exit__(
|
| 177 |
+
self,
|
| 178 |
+
exc_type: t.Optional[t.Type[BaseException]],
|
| 179 |
+
exc_value: t.Optional[BaseException],
|
| 180 |
+
traceback: t.Optional["types.TracebackType"],
|
| 181 |
+
) -> t.Optional[bool]:
|
| 182 |
+
if exc_type is not None and exc_value is not None:
|
| 183 |
+
self.retry_state.set_exception((exc_type, exc_value, traceback))
|
| 184 |
+
return True # Swallow exception.
|
| 185 |
+
else:
|
| 186 |
+
# We don't have the result, actually.
|
| 187 |
+
self.retry_state.set_result(None)
|
| 188 |
+
return None
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
class BaseRetrying(ABC):
|
| 192 |
+
def __init__(
|
| 193 |
+
self,
|
| 194 |
+
sleep: t.Callable[[t.Union[int, float]], None] = sleep,
|
| 195 |
+
stop: "StopBaseT" = stop_never,
|
| 196 |
+
wait: "WaitBaseT" = wait_none(),
|
| 197 |
+
retry: "RetryBaseT" = retry_if_exception_type(),
|
| 198 |
+
before: t.Callable[["RetryCallState"], None] = before_nothing,
|
| 199 |
+
after: t.Callable[["RetryCallState"], None] = after_nothing,
|
| 200 |
+
before_sleep: t.Optional[t.Callable[["RetryCallState"], None]] = None,
|
| 201 |
+
reraise: bool = False,
|
| 202 |
+
retry_error_cls: t.Type[RetryError] = RetryError,
|
| 203 |
+
retry_error_callback: t.Optional[t.Callable[["RetryCallState"], t.Any]] = None,
|
| 204 |
+
):
|
| 205 |
+
self.sleep = sleep
|
| 206 |
+
self.stop = stop
|
| 207 |
+
self.wait = wait
|
| 208 |
+
self.retry = retry
|
| 209 |
+
self.before = before
|
| 210 |
+
self.after = after
|
| 211 |
+
self.before_sleep = before_sleep
|
| 212 |
+
self.reraise = reraise
|
| 213 |
+
self._local = threading.local()
|
| 214 |
+
self.retry_error_cls = retry_error_cls
|
| 215 |
+
self.retry_error_callback = retry_error_callback
|
| 216 |
+
|
| 217 |
+
def copy(
|
| 218 |
+
self,
|
| 219 |
+
sleep: t.Union[t.Callable[[t.Union[int, float]], None], object] = _unset,
|
| 220 |
+
stop: t.Union["StopBaseT", object] = _unset,
|
| 221 |
+
wait: t.Union["WaitBaseT", object] = _unset,
|
| 222 |
+
retry: t.Union[retry_base, object] = _unset,
|
| 223 |
+
before: t.Union[t.Callable[["RetryCallState"], None], object] = _unset,
|
| 224 |
+
after: t.Union[t.Callable[["RetryCallState"], None], object] = _unset,
|
| 225 |
+
before_sleep: t.Union[t.Optional[t.Callable[["RetryCallState"], None]], object] = _unset,
|
| 226 |
+
reraise: t.Union[bool, object] = _unset,
|
| 227 |
+
retry_error_cls: t.Union[t.Type[RetryError], object] = _unset,
|
| 228 |
+
retry_error_callback: t.Union[t.Optional[t.Callable[["RetryCallState"], t.Any]], object] = _unset,
|
| 229 |
+
) -> "BaseRetrying":
|
| 230 |
+
"""Copy this object with some parameters changed if needed."""
|
| 231 |
+
return self.__class__(
|
| 232 |
+
sleep=_first_set(sleep, self.sleep),
|
| 233 |
+
stop=_first_set(stop, self.stop),
|
| 234 |
+
wait=_first_set(wait, self.wait),
|
| 235 |
+
retry=_first_set(retry, self.retry),
|
| 236 |
+
before=_first_set(before, self.before),
|
| 237 |
+
after=_first_set(after, self.after),
|
| 238 |
+
before_sleep=_first_set(before_sleep, self.before_sleep),
|
| 239 |
+
reraise=_first_set(reraise, self.reraise),
|
| 240 |
+
retry_error_cls=_first_set(retry_error_cls, self.retry_error_cls),
|
| 241 |
+
retry_error_callback=_first_set(retry_error_callback, self.retry_error_callback),
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
def __repr__(self) -> str:
|
| 245 |
+
return (
|
| 246 |
+
f"<{self.__class__.__name__} object at 0x{id(self):x} ("
|
| 247 |
+
f"stop={self.stop}, "
|
| 248 |
+
f"wait={self.wait}, "
|
| 249 |
+
f"sleep={self.sleep}, "
|
| 250 |
+
f"retry={self.retry}, "
|
| 251 |
+
f"before={self.before}, "
|
| 252 |
+
f"after={self.after})>"
|
| 253 |
+
)
|
| 254 |
+
|
| 255 |
+
@property
|
| 256 |
+
def statistics(self) -> t.Dict[str, t.Any]:
|
| 257 |
+
"""Return a dictionary of runtime statistics.
|
| 258 |
+
|
| 259 |
+
This dictionary will be empty when the controller has never been
|
| 260 |
+
ran. When it is running or has ran previously it should have (but
|
| 261 |
+
may not) have useful and/or informational keys and values when
|
| 262 |
+
running is underway and/or completed.
|
| 263 |
+
|
| 264 |
+
.. warning:: The keys in this dictionary **should** be some what
|
| 265 |
+
stable (not changing), but there existence **may**
|
| 266 |
+
change between major releases as new statistics are
|
| 267 |
+
gathered or removed so before accessing keys ensure that
|
| 268 |
+
they actually exist and handle when they do not.
|
| 269 |
+
|
| 270 |
+
.. note:: The values in this dictionary are local to the thread
|
| 271 |
+
running call (so if multiple threads share the same retrying
|
| 272 |
+
object - either directly or indirectly) they will each have
|
| 273 |
+
there own view of statistics they have collected (in the
|
| 274 |
+
future we may provide a way to aggregate the various
|
| 275 |
+
statistics from each thread).
|
| 276 |
+
"""
|
| 277 |
+
try:
|
| 278 |
+
return self._local.statistics # type: ignore[no-any-return]
|
| 279 |
+
except AttributeError:
|
| 280 |
+
self._local.statistics = t.cast(t.Dict[str, t.Any], {})
|
| 281 |
+
return self._local.statistics
|
| 282 |
+
|
| 283 |
+
def wraps(self, f: WrappedFn) -> WrappedFn:
|
| 284 |
+
"""Wrap a function for retrying.
|
| 285 |
+
|
| 286 |
+
:param f: A function to wraps for retrying.
|
| 287 |
+
"""
|
| 288 |
+
|
| 289 |
+
@functools.wraps(f)
|
| 290 |
+
def wrapped_f(*args: t.Any, **kw: t.Any) -> t.Any:
|
| 291 |
+
return self(f, *args, **kw)
|
| 292 |
+
|
| 293 |
+
def retry_with(*args: t.Any, **kwargs: t.Any) -> WrappedFn:
|
| 294 |
+
return self.copy(*args, **kwargs).wraps(f)
|
| 295 |
+
|
| 296 |
+
wrapped_f.retry = self # type: ignore[attr-defined]
|
| 297 |
+
wrapped_f.retry_with = retry_with # type: ignore[attr-defined]
|
| 298 |
+
|
| 299 |
+
return wrapped_f # type: ignore[return-value]
|
| 300 |
+
|
| 301 |
+
def begin(self) -> None:
|
| 302 |
+
self.statistics.clear()
|
| 303 |
+
self.statistics["start_time"] = time.monotonic()
|
| 304 |
+
self.statistics["attempt_number"] = 1
|
| 305 |
+
self.statistics["idle_for"] = 0
|
| 306 |
+
|
| 307 |
+
def iter(self, retry_state: "RetryCallState") -> t.Union[DoAttempt, DoSleep, t.Any]: # noqa
|
| 308 |
+
fut = retry_state.outcome
|
| 309 |
+
if fut is None:
|
| 310 |
+
if self.before is not None:
|
| 311 |
+
self.before(retry_state)
|
| 312 |
+
return DoAttempt()
|
| 313 |
+
|
| 314 |
+
is_explicit_retry = fut.failed and isinstance(fut.exception(), TryAgain)
|
| 315 |
+
if not (is_explicit_retry or self.retry(retry_state)):
|
| 316 |
+
return fut.result()
|
| 317 |
+
|
| 318 |
+
if self.after is not None:
|
| 319 |
+
self.after(retry_state)
|
| 320 |
+
|
| 321 |
+
self.statistics["delay_since_first_attempt"] = retry_state.seconds_since_start
|
| 322 |
+
if self.stop(retry_state):
|
| 323 |
+
if self.retry_error_callback:
|
| 324 |
+
return self.retry_error_callback(retry_state)
|
| 325 |
+
retry_exc = self.retry_error_cls(fut)
|
| 326 |
+
if self.reraise:
|
| 327 |
+
raise retry_exc.reraise()
|
| 328 |
+
raise retry_exc from fut.exception()
|
| 329 |
+
|
| 330 |
+
if self.wait:
|
| 331 |
+
sleep = self.wait(retry_state)
|
| 332 |
+
else:
|
| 333 |
+
sleep = 0.0
|
| 334 |
+
retry_state.next_action = RetryAction(sleep)
|
| 335 |
+
retry_state.idle_for += sleep
|
| 336 |
+
self.statistics["idle_for"] += sleep
|
| 337 |
+
self.statistics["attempt_number"] += 1
|
| 338 |
+
|
| 339 |
+
if self.before_sleep is not None:
|
| 340 |
+
self.before_sleep(retry_state)
|
| 341 |
+
|
| 342 |
+
return DoSleep(sleep)
|
| 343 |
+
|
| 344 |
+
def __iter__(self) -> t.Generator[AttemptManager, None, None]:
|
| 345 |
+
self.begin()
|
| 346 |
+
|
| 347 |
+
retry_state = RetryCallState(self, fn=None, args=(), kwargs={})
|
| 348 |
+
while True:
|
| 349 |
+
do = self.iter(retry_state=retry_state)
|
| 350 |
+
if isinstance(do, DoAttempt):
|
| 351 |
+
yield AttemptManager(retry_state=retry_state)
|
| 352 |
+
elif isinstance(do, DoSleep):
|
| 353 |
+
retry_state.prepare_for_next_attempt()
|
| 354 |
+
self.sleep(do)
|
| 355 |
+
else:
|
| 356 |
+
break
|
| 357 |
+
|
| 358 |
+
@abstractmethod
|
| 359 |
+
def __call__(
|
| 360 |
+
self,
|
| 361 |
+
fn: t.Callable[..., WrappedFnReturnT],
|
| 362 |
+
*args: t.Any,
|
| 363 |
+
**kwargs: t.Any,
|
| 364 |
+
) -> WrappedFnReturnT:
|
| 365 |
+
pass
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
class Retrying(BaseRetrying):
|
| 369 |
+
"""Retrying controller."""
|
| 370 |
+
|
| 371 |
+
def __call__(
|
| 372 |
+
self,
|
| 373 |
+
fn: t.Callable[..., WrappedFnReturnT],
|
| 374 |
+
*args: t.Any,
|
| 375 |
+
**kwargs: t.Any,
|
| 376 |
+
) -> WrappedFnReturnT:
|
| 377 |
+
self.begin()
|
| 378 |
+
|
| 379 |
+
retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
|
| 380 |
+
while True:
|
| 381 |
+
do = self.iter(retry_state=retry_state)
|
| 382 |
+
if isinstance(do, DoAttempt):
|
| 383 |
+
try:
|
| 384 |
+
result = fn(*args, **kwargs)
|
| 385 |
+
except BaseException: # noqa: B902
|
| 386 |
+
retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
|
| 387 |
+
else:
|
| 388 |
+
retry_state.set_result(result)
|
| 389 |
+
elif isinstance(do, DoSleep):
|
| 390 |
+
retry_state.prepare_for_next_attempt()
|
| 391 |
+
self.sleep(do)
|
| 392 |
+
else:
|
| 393 |
+
return do # type: ignore[no-any-return]
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
if sys.version_info[1] >= 9:
|
| 397 |
+
FutureGenericT = futures.Future[t.Any]
|
| 398 |
+
else:
|
| 399 |
+
FutureGenericT = futures.Future
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
class Future(FutureGenericT):
|
| 403 |
+
"""Encapsulates a (future or past) attempted call to a target function."""
|
| 404 |
+
|
| 405 |
+
def __init__(self, attempt_number: int) -> None:
|
| 406 |
+
super().__init__()
|
| 407 |
+
self.attempt_number = attempt_number
|
| 408 |
+
|
| 409 |
+
@property
|
| 410 |
+
def failed(self) -> bool:
|
| 411 |
+
"""Return whether a exception is being held in this future."""
|
| 412 |
+
return self.exception() is not None
|
| 413 |
+
|
| 414 |
+
@classmethod
|
| 415 |
+
def construct(cls, attempt_number: int, value: t.Any, has_exception: bool) -> "Future":
|
| 416 |
+
"""Construct a new Future object."""
|
| 417 |
+
fut = cls(attempt_number)
|
| 418 |
+
if has_exception:
|
| 419 |
+
fut.set_exception(value)
|
| 420 |
+
else:
|
| 421 |
+
fut.set_result(value)
|
| 422 |
+
return fut
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
class RetryCallState:
|
| 426 |
+
"""State related to a single call wrapped with Retrying."""
|
| 427 |
+
|
| 428 |
+
def __init__(
|
| 429 |
+
self,
|
| 430 |
+
retry_object: BaseRetrying,
|
| 431 |
+
fn: t.Optional[WrappedFn],
|
| 432 |
+
args: t.Any,
|
| 433 |
+
kwargs: t.Any,
|
| 434 |
+
) -> None:
|
| 435 |
+
#: Retry call start timestamp
|
| 436 |
+
self.start_time = time.monotonic()
|
| 437 |
+
#: Retry manager object
|
| 438 |
+
self.retry_object = retry_object
|
| 439 |
+
#: Function wrapped by this retry call
|
| 440 |
+
self.fn = fn
|
| 441 |
+
#: Arguments of the function wrapped by this retry call
|
| 442 |
+
self.args = args
|
| 443 |
+
#: Keyword arguments of the function wrapped by this retry call
|
| 444 |
+
self.kwargs = kwargs
|
| 445 |
+
|
| 446 |
+
#: The number of the current attempt
|
| 447 |
+
self.attempt_number: int = 1
|
| 448 |
+
#: Last outcome (result or exception) produced by the function
|
| 449 |
+
self.outcome: t.Optional[Future] = None
|
| 450 |
+
#: Timestamp of the last outcome
|
| 451 |
+
self.outcome_timestamp: t.Optional[float] = None
|
| 452 |
+
#: Time spent sleeping in retries
|
| 453 |
+
self.idle_for: float = 0.0
|
| 454 |
+
#: Next action as decided by the retry manager
|
| 455 |
+
self.next_action: t.Optional[RetryAction] = None
|
| 456 |
+
|
| 457 |
+
@property
|
| 458 |
+
def seconds_since_start(self) -> t.Optional[float]:
|
| 459 |
+
if self.outcome_timestamp is None:
|
| 460 |
+
return None
|
| 461 |
+
return self.outcome_timestamp - self.start_time
|
| 462 |
+
|
| 463 |
+
def prepare_for_next_attempt(self) -> None:
|
| 464 |
+
self.outcome = None
|
| 465 |
+
self.outcome_timestamp = None
|
| 466 |
+
self.attempt_number += 1
|
| 467 |
+
self.next_action = None
|
| 468 |
+
|
| 469 |
+
def set_result(self, val: t.Any) -> None:
|
| 470 |
+
ts = time.monotonic()
|
| 471 |
+
fut = Future(self.attempt_number)
|
| 472 |
+
fut.set_result(val)
|
| 473 |
+
self.outcome, self.outcome_timestamp = fut, ts
|
| 474 |
+
|
| 475 |
+
def set_exception(
|
| 476 |
+
self, exc_info: t.Tuple[t.Type[BaseException], BaseException, "types.TracebackType| None"]
|
| 477 |
+
) -> None:
|
| 478 |
+
ts = time.monotonic()
|
| 479 |
+
fut = Future(self.attempt_number)
|
| 480 |
+
fut.set_exception(exc_info[1])
|
| 481 |
+
self.outcome, self.outcome_timestamp = fut, ts
|
| 482 |
+
|
| 483 |
+
def __repr__(self) -> str:
|
| 484 |
+
if self.outcome is None:
|
| 485 |
+
result = "none yet"
|
| 486 |
+
elif self.outcome.failed:
|
| 487 |
+
exception = self.outcome.exception()
|
| 488 |
+
result = f"failed ({exception.__class__.__name__} {exception})"
|
| 489 |
+
else:
|
| 490 |
+
result = f"returned {self.outcome.result()}"
|
| 491 |
+
|
| 492 |
+
slept = float(round(self.idle_for, 2))
|
| 493 |
+
clsname = self.__class__.__name__
|
| 494 |
+
return f"<{clsname} {id(self)}: attempt #{self.attempt_number}; slept for {slept}; last result: {result}>"
|
| 495 |
+
|
| 496 |
+
|
| 497 |
+
@t.overload
|
| 498 |
+
def retry(func: WrappedFn) -> WrappedFn:
|
| 499 |
+
...
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
@t.overload
|
| 503 |
+
def retry(
|
| 504 |
+
sleep: t.Callable[[t.Union[int, float]], None] = sleep,
|
| 505 |
+
stop: "StopBaseT" = stop_never,
|
| 506 |
+
wait: "WaitBaseT" = wait_none(),
|
| 507 |
+
retry: "RetryBaseT" = retry_if_exception_type(),
|
| 508 |
+
before: t.Callable[["RetryCallState"], None] = before_nothing,
|
| 509 |
+
after: t.Callable[["RetryCallState"], None] = after_nothing,
|
| 510 |
+
before_sleep: t.Optional[t.Callable[["RetryCallState"], None]] = None,
|
| 511 |
+
reraise: bool = False,
|
| 512 |
+
retry_error_cls: t.Type["RetryError"] = RetryError,
|
| 513 |
+
retry_error_callback: t.Optional[t.Callable[["RetryCallState"], t.Any]] = None,
|
| 514 |
+
) -> t.Callable[[WrappedFn], WrappedFn]:
|
| 515 |
+
...
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
def retry(*dargs: t.Any, **dkw: t.Any) -> t.Any:
|
| 519 |
+
"""Wrap a function with a new `Retrying` object.
|
| 520 |
+
|
| 521 |
+
:param dargs: positional arguments passed to Retrying object
|
| 522 |
+
:param dkw: keyword arguments passed to the Retrying object
|
| 523 |
+
"""
|
| 524 |
+
# support both @retry and @retry() as valid syntax
|
| 525 |
+
if len(dargs) == 1 and callable(dargs[0]):
|
| 526 |
+
return retry()(dargs[0])
|
| 527 |
+
else:
|
| 528 |
+
|
| 529 |
+
def wrap(f: WrappedFn) -> WrappedFn:
|
| 530 |
+
if isinstance(f, retry_base):
|
| 531 |
+
warnings.warn(
|
| 532 |
+
f"Got retry_base instance ({f.__class__.__name__}) as callable argument, "
|
| 533 |
+
f"this will probably hang indefinitely (did you mean retry={f.__class__.__name__}(...)?)"
|
| 534 |
+
)
|
| 535 |
+
r: "BaseRetrying"
|
| 536 |
+
if iscoroutinefunction(f):
|
| 537 |
+
r = AsyncRetrying(*dargs, **dkw)
|
| 538 |
+
elif tornado and hasattr(tornado.gen, "is_coroutine_function") and tornado.gen.is_coroutine_function(f):
|
| 539 |
+
r = TornadoRetrying(*dargs, **dkw)
|
| 540 |
+
else:
|
| 541 |
+
r = Retrying(*dargs, **dkw)
|
| 542 |
+
|
| 543 |
+
return r.wraps(f)
|
| 544 |
+
|
| 545 |
+
return wrap
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
from pip._vendor.tenacity._asyncio import AsyncRetrying # noqa:E402,I100
|
| 549 |
+
|
| 550 |
+
if tornado:
|
| 551 |
+
from pip._vendor.tenacity.tornadoweb import TornadoRetrying
|
| 552 |
+
|
| 553 |
+
|
| 554 |
+
__all__ = [
|
| 555 |
+
"retry_base",
|
| 556 |
+
"retry_all",
|
| 557 |
+
"retry_always",
|
| 558 |
+
"retry_any",
|
| 559 |
+
"retry_if_exception",
|
| 560 |
+
"retry_if_exception_type",
|
| 561 |
+
"retry_if_exception_cause_type",
|
| 562 |
+
"retry_if_not_exception_type",
|
| 563 |
+
"retry_if_not_result",
|
| 564 |
+
"retry_if_result",
|
| 565 |
+
"retry_never",
|
| 566 |
+
"retry_unless_exception_type",
|
| 567 |
+
"retry_if_exception_message",
|
| 568 |
+
"retry_if_not_exception_message",
|
| 569 |
+
"sleep",
|
| 570 |
+
"sleep_using_event",
|
| 571 |
+
"stop_after_attempt",
|
| 572 |
+
"stop_after_delay",
|
| 573 |
+
"stop_all",
|
| 574 |
+
"stop_any",
|
| 575 |
+
"stop_never",
|
| 576 |
+
"stop_when_event_set",
|
| 577 |
+
"wait_chain",
|
| 578 |
+
"wait_combine",
|
| 579 |
+
"wait_exponential",
|
| 580 |
+
"wait_fixed",
|
| 581 |
+
"wait_incrementing",
|
| 582 |
+
"wait_none",
|
| 583 |
+
"wait_random",
|
| 584 |
+
"wait_random_exponential",
|
| 585 |
+
"wait_full_jitter",
|
| 586 |
+
"wait_exponential_jitter",
|
| 587 |
+
"before_log",
|
| 588 |
+
"before_nothing",
|
| 589 |
+
"after_log",
|
| 590 |
+
"after_nothing",
|
| 591 |
+
"before_sleep_log",
|
| 592 |
+
"before_sleep_nothing",
|
| 593 |
+
"retry",
|
| 594 |
+
"WrappedFn",
|
| 595 |
+
"TryAgain",
|
| 596 |
+
"NO_RESULT",
|
| 597 |
+
"DoAttempt",
|
| 598 |
+
"DoSleep",
|
| 599 |
+
"BaseAction",
|
| 600 |
+
"RetryAction",
|
| 601 |
+
"RetryError",
|
| 602 |
+
"AttemptManager",
|
| 603 |
+
"BaseRetrying",
|
| 604 |
+
"Retrying",
|
| 605 |
+
"Future",
|
| 606 |
+
"RetryCallState",
|
| 607 |
+
"AsyncRetrying",
|
| 608 |
+
]
|
.venv/Lib/site-packages/pip/_vendor/tenacity/_asyncio.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Étienne Bersac
|
| 2 |
+
# Copyright 2016 Julien Danjou
|
| 3 |
+
# Copyright 2016 Joshua Harlow
|
| 4 |
+
# Copyright 2013-2014 Ray Holder
|
| 5 |
+
#
|
| 6 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 7 |
+
# you may not use this file except in compliance with the License.
|
| 8 |
+
# You may obtain a copy of the License at
|
| 9 |
+
#
|
| 10 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 11 |
+
#
|
| 12 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 13 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 14 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 15 |
+
# See the License for the specific language governing permissions and
|
| 16 |
+
# limitations under the License.
|
| 17 |
+
|
| 18 |
+
import functools
|
| 19 |
+
import sys
|
| 20 |
+
import typing as t
|
| 21 |
+
from asyncio import sleep
|
| 22 |
+
|
| 23 |
+
from pip._vendor.tenacity import AttemptManager
|
| 24 |
+
from pip._vendor.tenacity import BaseRetrying
|
| 25 |
+
from pip._vendor.tenacity import DoAttempt
|
| 26 |
+
from pip._vendor.tenacity import DoSleep
|
| 27 |
+
from pip._vendor.tenacity import RetryCallState
|
| 28 |
+
|
| 29 |
+
WrappedFnReturnT = t.TypeVar("WrappedFnReturnT")
|
| 30 |
+
WrappedFn = t.TypeVar("WrappedFn", bound=t.Callable[..., t.Awaitable[t.Any]])
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class AsyncRetrying(BaseRetrying):
|
| 34 |
+
sleep: t.Callable[[float], t.Awaitable[t.Any]]
|
| 35 |
+
|
| 36 |
+
def __init__(self, sleep: t.Callable[[float], t.Awaitable[t.Any]] = sleep, **kwargs: t.Any) -> None:
|
| 37 |
+
super().__init__(**kwargs)
|
| 38 |
+
self.sleep = sleep
|
| 39 |
+
|
| 40 |
+
async def __call__( # type: ignore[override]
|
| 41 |
+
self, fn: WrappedFn, *args: t.Any, **kwargs: t.Any
|
| 42 |
+
) -> WrappedFnReturnT:
|
| 43 |
+
self.begin()
|
| 44 |
+
|
| 45 |
+
retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
|
| 46 |
+
while True:
|
| 47 |
+
do = self.iter(retry_state=retry_state)
|
| 48 |
+
if isinstance(do, DoAttempt):
|
| 49 |
+
try:
|
| 50 |
+
result = await fn(*args, **kwargs)
|
| 51 |
+
except BaseException: # noqa: B902
|
| 52 |
+
retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
|
| 53 |
+
else:
|
| 54 |
+
retry_state.set_result(result)
|
| 55 |
+
elif isinstance(do, DoSleep):
|
| 56 |
+
retry_state.prepare_for_next_attempt()
|
| 57 |
+
await self.sleep(do)
|
| 58 |
+
else:
|
| 59 |
+
return do # type: ignore[no-any-return]
|
| 60 |
+
|
| 61 |
+
def __iter__(self) -> t.Generator[AttemptManager, None, None]:
|
| 62 |
+
raise TypeError("AsyncRetrying object is not iterable")
|
| 63 |
+
|
| 64 |
+
def __aiter__(self) -> "AsyncRetrying":
|
| 65 |
+
self.begin()
|
| 66 |
+
self._retry_state = RetryCallState(self, fn=None, args=(), kwargs={})
|
| 67 |
+
return self
|
| 68 |
+
|
| 69 |
+
async def __anext__(self) -> AttemptManager:
|
| 70 |
+
while True:
|
| 71 |
+
do = self.iter(retry_state=self._retry_state)
|
| 72 |
+
if do is None:
|
| 73 |
+
raise StopAsyncIteration
|
| 74 |
+
elif isinstance(do, DoAttempt):
|
| 75 |
+
return AttemptManager(retry_state=self._retry_state)
|
| 76 |
+
elif isinstance(do, DoSleep):
|
| 77 |
+
self._retry_state.prepare_for_next_attempt()
|
| 78 |
+
await self.sleep(do)
|
| 79 |
+
else:
|
| 80 |
+
raise StopAsyncIteration
|
| 81 |
+
|
| 82 |
+
def wraps(self, fn: WrappedFn) -> WrappedFn:
|
| 83 |
+
fn = super().wraps(fn)
|
| 84 |
+
# Ensure wrapper is recognized as a coroutine function.
|
| 85 |
+
|
| 86 |
+
@functools.wraps(fn)
|
| 87 |
+
async def async_wrapped(*args: t.Any, **kwargs: t.Any) -> t.Any:
|
| 88 |
+
return await fn(*args, **kwargs)
|
| 89 |
+
|
| 90 |
+
# Preserve attributes
|
| 91 |
+
async_wrapped.retry = fn.retry # type: ignore[attr-defined]
|
| 92 |
+
async_wrapped.retry_with = fn.retry_with # type: ignore[attr-defined]
|
| 93 |
+
|
| 94 |
+
return async_wrapped # type: ignore[return-value]
|
.venv/Lib/site-packages/pip/_vendor/tenacity/_utils.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Julien Danjou
|
| 2 |
+
# Copyright 2016 Joshua Harlow
|
| 3 |
+
# Copyright 2013-2014 Ray Holder
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
|
| 17 |
+
import sys
|
| 18 |
+
import typing
|
| 19 |
+
from datetime import timedelta
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# sys.maxsize:
|
| 23 |
+
# An integer giving the maximum value a variable of type Py_ssize_t can take.
|
| 24 |
+
MAX_WAIT = sys.maxsize / 2
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def find_ordinal(pos_num: int) -> str:
|
| 28 |
+
# See: https://en.wikipedia.org/wiki/English_numerals#Ordinal_numbers
|
| 29 |
+
if pos_num == 0:
|
| 30 |
+
return "th"
|
| 31 |
+
elif pos_num == 1:
|
| 32 |
+
return "st"
|
| 33 |
+
elif pos_num == 2:
|
| 34 |
+
return "nd"
|
| 35 |
+
elif pos_num == 3:
|
| 36 |
+
return "rd"
|
| 37 |
+
elif 4 <= pos_num <= 20:
|
| 38 |
+
return "th"
|
| 39 |
+
else:
|
| 40 |
+
return find_ordinal(pos_num % 10)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def to_ordinal(pos_num: int) -> str:
|
| 44 |
+
return f"{pos_num}{find_ordinal(pos_num)}"
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def get_callback_name(cb: typing.Callable[..., typing.Any]) -> str:
|
| 48 |
+
"""Get a callback fully-qualified name.
|
| 49 |
+
|
| 50 |
+
If no name can be produced ``repr(cb)`` is called and returned.
|
| 51 |
+
"""
|
| 52 |
+
segments = []
|
| 53 |
+
try:
|
| 54 |
+
segments.append(cb.__qualname__)
|
| 55 |
+
except AttributeError:
|
| 56 |
+
try:
|
| 57 |
+
segments.append(cb.__name__)
|
| 58 |
+
except AttributeError:
|
| 59 |
+
pass
|
| 60 |
+
if not segments:
|
| 61 |
+
return repr(cb)
|
| 62 |
+
else:
|
| 63 |
+
try:
|
| 64 |
+
# When running under sphinx it appears this can be none?
|
| 65 |
+
if cb.__module__:
|
| 66 |
+
segments.insert(0, cb.__module__)
|
| 67 |
+
except AttributeError:
|
| 68 |
+
pass
|
| 69 |
+
return ".".join(segments)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
time_unit_type = typing.Union[int, float, timedelta]
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def to_seconds(time_unit: time_unit_type) -> float:
|
| 76 |
+
return float(time_unit.total_seconds() if isinstance(time_unit, timedelta) else time_unit)
|
.venv/Lib/site-packages/pip/_vendor/tenacity/after.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Julien Danjou
|
| 2 |
+
# Copyright 2016 Joshua Harlow
|
| 3 |
+
# Copyright 2013-2014 Ray Holder
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
|
| 17 |
+
import typing
|
| 18 |
+
|
| 19 |
+
from pip._vendor.tenacity import _utils
|
| 20 |
+
|
| 21 |
+
if typing.TYPE_CHECKING:
|
| 22 |
+
import logging
|
| 23 |
+
|
| 24 |
+
from pip._vendor.tenacity import RetryCallState
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def after_nothing(retry_state: "RetryCallState") -> None:
|
| 28 |
+
"""After call strategy that does nothing."""
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def after_log(
|
| 32 |
+
logger: "logging.Logger",
|
| 33 |
+
log_level: int,
|
| 34 |
+
sec_format: str = "%0.3f",
|
| 35 |
+
) -> typing.Callable[["RetryCallState"], None]:
|
| 36 |
+
"""After call strategy that logs to some logger the finished attempt."""
|
| 37 |
+
|
| 38 |
+
def log_it(retry_state: "RetryCallState") -> None:
|
| 39 |
+
if retry_state.fn is None:
|
| 40 |
+
# NOTE(sileht): can't really happen, but we must please mypy
|
| 41 |
+
fn_name = "<unknown>"
|
| 42 |
+
else:
|
| 43 |
+
fn_name = _utils.get_callback_name(retry_state.fn)
|
| 44 |
+
logger.log(
|
| 45 |
+
log_level,
|
| 46 |
+
f"Finished call to '{fn_name}' "
|
| 47 |
+
f"after {sec_format % retry_state.seconds_since_start}(s), "
|
| 48 |
+
f"this was the {_utils.to_ordinal(retry_state.attempt_number)} time calling it.",
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
return log_it
|
.venv/Lib/site-packages/pip/_vendor/tenacity/before.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Julien Danjou
|
| 2 |
+
# Copyright 2016 Joshua Harlow
|
| 3 |
+
# Copyright 2013-2014 Ray Holder
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
|
| 17 |
+
import typing
|
| 18 |
+
|
| 19 |
+
from pip._vendor.tenacity import _utils
|
| 20 |
+
|
| 21 |
+
if typing.TYPE_CHECKING:
|
| 22 |
+
import logging
|
| 23 |
+
|
| 24 |
+
from pip._vendor.tenacity import RetryCallState
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def before_nothing(retry_state: "RetryCallState") -> None:
|
| 28 |
+
"""Before call strategy that does nothing."""
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def before_log(logger: "logging.Logger", log_level: int) -> typing.Callable[["RetryCallState"], None]:
|
| 32 |
+
"""Before call strategy that logs to some logger the attempt."""
|
| 33 |
+
|
| 34 |
+
def log_it(retry_state: "RetryCallState") -> None:
|
| 35 |
+
if retry_state.fn is None:
|
| 36 |
+
# NOTE(sileht): can't really happen, but we must please mypy
|
| 37 |
+
fn_name = "<unknown>"
|
| 38 |
+
else:
|
| 39 |
+
fn_name = _utils.get_callback_name(retry_state.fn)
|
| 40 |
+
logger.log(
|
| 41 |
+
log_level,
|
| 42 |
+
f"Starting call to '{fn_name}', "
|
| 43 |
+
f"this is the {_utils.to_ordinal(retry_state.attempt_number)} time calling it.",
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
return log_it
|
.venv/Lib/site-packages/pip/_vendor/tenacity/before_sleep.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Julien Danjou
|
| 2 |
+
# Copyright 2016 Joshua Harlow
|
| 3 |
+
# Copyright 2013-2014 Ray Holder
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
|
| 17 |
+
import typing
|
| 18 |
+
|
| 19 |
+
from pip._vendor.tenacity import _utils
|
| 20 |
+
|
| 21 |
+
if typing.TYPE_CHECKING:
|
| 22 |
+
import logging
|
| 23 |
+
|
| 24 |
+
from pip._vendor.tenacity import RetryCallState
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def before_sleep_nothing(retry_state: "RetryCallState") -> None:
|
| 28 |
+
"""Before call strategy that does nothing."""
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def before_sleep_log(
|
| 32 |
+
logger: "logging.Logger",
|
| 33 |
+
log_level: int,
|
| 34 |
+
exc_info: bool = False,
|
| 35 |
+
) -> typing.Callable[["RetryCallState"], None]:
|
| 36 |
+
"""Before call strategy that logs to some logger the attempt."""
|
| 37 |
+
|
| 38 |
+
def log_it(retry_state: "RetryCallState") -> None:
|
| 39 |
+
local_exc_info: BaseException | bool | None
|
| 40 |
+
|
| 41 |
+
if retry_state.outcome is None:
|
| 42 |
+
raise RuntimeError("log_it() called before outcome was set")
|
| 43 |
+
|
| 44 |
+
if retry_state.next_action is None:
|
| 45 |
+
raise RuntimeError("log_it() called before next_action was set")
|
| 46 |
+
|
| 47 |
+
if retry_state.outcome.failed:
|
| 48 |
+
ex = retry_state.outcome.exception()
|
| 49 |
+
verb, value = "raised", f"{ex.__class__.__name__}: {ex}"
|
| 50 |
+
|
| 51 |
+
if exc_info:
|
| 52 |
+
local_exc_info = retry_state.outcome.exception()
|
| 53 |
+
else:
|
| 54 |
+
local_exc_info = False
|
| 55 |
+
else:
|
| 56 |
+
verb, value = "returned", retry_state.outcome.result()
|
| 57 |
+
local_exc_info = False # exc_info does not apply when no exception
|
| 58 |
+
|
| 59 |
+
if retry_state.fn is None:
|
| 60 |
+
# NOTE(sileht): can't really happen, but we must please mypy
|
| 61 |
+
fn_name = "<unknown>"
|
| 62 |
+
else:
|
| 63 |
+
fn_name = _utils.get_callback_name(retry_state.fn)
|
| 64 |
+
|
| 65 |
+
logger.log(
|
| 66 |
+
log_level,
|
| 67 |
+
f"Retrying {fn_name} " f"in {retry_state.next_action.sleep} seconds as it {verb} {value}.",
|
| 68 |
+
exc_info=local_exc_info,
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
return log_it
|
.venv/Lib/site-packages/pip/_vendor/tenacity/nap.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Étienne Bersac
|
| 2 |
+
# Copyright 2016 Julien Danjou
|
| 3 |
+
# Copyright 2016 Joshua Harlow
|
| 4 |
+
# Copyright 2013-2014 Ray Holder
|
| 5 |
+
#
|
| 6 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 7 |
+
# you may not use this file except in compliance with the License.
|
| 8 |
+
# You may obtain a copy of the License at
|
| 9 |
+
#
|
| 10 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 11 |
+
#
|
| 12 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 13 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 14 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 15 |
+
# See the License for the specific language governing permissions and
|
| 16 |
+
# limitations under the License.
|
| 17 |
+
|
| 18 |
+
import time
|
| 19 |
+
import typing
|
| 20 |
+
|
| 21 |
+
if typing.TYPE_CHECKING:
|
| 22 |
+
import threading
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def sleep(seconds: float) -> None:
|
| 26 |
+
"""
|
| 27 |
+
Sleep strategy that delays execution for a given number of seconds.
|
| 28 |
+
|
| 29 |
+
This is the default strategy, and may be mocked out for unit testing.
|
| 30 |
+
"""
|
| 31 |
+
time.sleep(seconds)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class sleep_using_event:
|
| 35 |
+
"""Sleep strategy that waits on an event to be set."""
|
| 36 |
+
|
| 37 |
+
def __init__(self, event: "threading.Event") -> None:
|
| 38 |
+
self.event = event
|
| 39 |
+
|
| 40 |
+
def __call__(self, timeout: typing.Optional[float]) -> None:
|
| 41 |
+
# NOTE(harlowja): this may *not* actually wait for timeout
|
| 42 |
+
# seconds if the event is set (ie this may e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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016–2021 Julien Danjou
|
| 2 |
+
# Copyright 2016 Joshua Harlow
|
| 3 |
+
# Copyright 2013-2014 Ray Holder
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
|
| 17 |
+
import abc
|
| 18 |
+
import re
|
| 19 |
+
import typing
|
| 20 |
+
|
| 21 |
+
if typing.TYPE_CHECKING:
|
| 22 |
+
from pip._vendor.tenacity import RetryCallState
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class retry_base(abc.ABC):
|
| 26 |
+
"""Abstract base class for retry strategies."""
|
| 27 |
+
|
| 28 |
+
@abc.abstractmethod
|
| 29 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 30 |
+
pass
|
| 31 |
+
|
| 32 |
+
def __and__(self, other: "retry_base") -> "retry_all":
|
| 33 |
+
return retry_all(self, other)
|
| 34 |
+
|
| 35 |
+
def __or__(self, other: "retry_base") -> "retry_any":
|
| 36 |
+
return retry_any(self, other)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
RetryBaseT = typing.Union[retry_base, typing.Callable[["RetryCallState"], bool]]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class _retry_never(retry_base):
|
| 43 |
+
"""Retry strategy that never rejects any result."""
|
| 44 |
+
|
| 45 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 46 |
+
return False
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
retry_never = _retry_never()
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class _retry_always(retry_base):
|
| 53 |
+
"""Retry strategy that always rejects any result."""
|
| 54 |
+
|
| 55 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 56 |
+
return True
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
retry_always = _retry_always()
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class retry_if_exception(retry_base):
|
| 63 |
+
"""Retry strategy that retries if an exception verifies a predicate."""
|
| 64 |
+
|
| 65 |
+
def __init__(self, predicate: typing.Callable[[BaseException], bool]) -> None:
|
| 66 |
+
self.predicate = predicate
|
| 67 |
+
|
| 68 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 69 |
+
if retry_state.outcome is None:
|
| 70 |
+
raise RuntimeError("__call__() called before outcome was set")
|
| 71 |
+
|
| 72 |
+
if retry_state.outcome.failed:
|
| 73 |
+
exception = retry_state.outcome.exception()
|
| 74 |
+
if exception is None:
|
| 75 |
+
raise RuntimeError("outcome failed but the exception is None")
|
| 76 |
+
return self.predicate(exception)
|
| 77 |
+
else:
|
| 78 |
+
return False
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class retry_if_exception_type(retry_if_exception):
|
| 82 |
+
"""Retries if an exception has been raised of one or more types."""
|
| 83 |
+
|
| 84 |
+
def __init__(
|
| 85 |
+
self,
|
| 86 |
+
exception_types: typing.Union[
|
| 87 |
+
typing.Type[BaseException],
|
| 88 |
+
typing.Tuple[typing.Type[BaseException], ...],
|
| 89 |
+
] = Exception,
|
| 90 |
+
) -> None:
|
| 91 |
+
self.exception_types = exception_types
|
| 92 |
+
super().__init__(lambda e: isinstance(e, exception_types))
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
class retry_if_not_exception_type(retry_if_exception):
|
| 96 |
+
"""Retries except an exception has been raised of one or more types."""
|
| 97 |
+
|
| 98 |
+
def __init__(
|
| 99 |
+
self,
|
| 100 |
+
exception_types: typing.Union[
|
| 101 |
+
typing.Type[BaseException],
|
| 102 |
+
typing.Tuple[typing.Type[BaseException], ...],
|
| 103 |
+
] = Exception,
|
| 104 |
+
) -> None:
|
| 105 |
+
self.exception_types = exception_types
|
| 106 |
+
super().__init__(lambda e: not isinstance(e, exception_types))
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class retry_unless_exception_type(retry_if_exception):
|
| 110 |
+
"""Retries until an exception is raised of one or more types."""
|
| 111 |
+
|
| 112 |
+
def __init__(
|
| 113 |
+
self,
|
| 114 |
+
exception_types: typing.Union[
|
| 115 |
+
typing.Type[BaseException],
|
| 116 |
+
typing.Tuple[typing.Type[BaseException], ...],
|
| 117 |
+
] = Exception,
|
| 118 |
+
) -> None:
|
| 119 |
+
self.exception_types = exception_types
|
| 120 |
+
super().__init__(lambda e: not isinstance(e, exception_types))
|
| 121 |
+
|
| 122 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 123 |
+
if retry_state.outcome is None:
|
| 124 |
+
raise RuntimeError("__call__() called before outcome was set")
|
| 125 |
+
|
| 126 |
+
# always retry if no exception was raised
|
| 127 |
+
if not retry_state.outcome.failed:
|
| 128 |
+
return True
|
| 129 |
+
|
| 130 |
+
exception = retry_state.outcome.exception()
|
| 131 |
+
if exception is None:
|
| 132 |
+
raise RuntimeError("outcome failed but the exception is None")
|
| 133 |
+
return self.predicate(exception)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class retry_if_exception_cause_type(retry_base):
|
| 137 |
+
"""Retries if any of the causes of the raised exception is of one or more types.
|
| 138 |
+
|
| 139 |
+
The check on the type of the cause of the exception is done recursively (until finding
|
| 140 |
+
an exception in the chain that has no `__cause__`)
|
| 141 |
+
"""
|
| 142 |
+
|
| 143 |
+
def __init__(
|
| 144 |
+
self,
|
| 145 |
+
exception_types: typing.Union[
|
| 146 |
+
typing.Type[BaseException],
|
| 147 |
+
typing.Tuple[typing.Type[BaseException], ...],
|
| 148 |
+
] = Exception,
|
| 149 |
+
) -> None:
|
| 150 |
+
self.exception_cause_types = exception_types
|
| 151 |
+
|
| 152 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 153 |
+
if retry_state.outcome is None:
|
| 154 |
+
raise RuntimeError("__call__ called before outcome was set")
|
| 155 |
+
|
| 156 |
+
if retry_state.outcome.failed:
|
| 157 |
+
exc = retry_state.outcome.exception()
|
| 158 |
+
while exc is not None:
|
| 159 |
+
if isinstance(exc.__cause__, self.exception_cause_types):
|
| 160 |
+
return True
|
| 161 |
+
exc = exc.__cause__
|
| 162 |
+
|
| 163 |
+
return False
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
class retry_if_result(retry_base):
|
| 167 |
+
"""Retries if the result verifies a predicate."""
|
| 168 |
+
|
| 169 |
+
def __init__(self, predicate: typing.Callable[[typing.Any], bool]) -> None:
|
| 170 |
+
self.predicate = predicate
|
| 171 |
+
|
| 172 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 173 |
+
if retry_state.outcome is None:
|
| 174 |
+
raise RuntimeError("__call__() called before outcome was set")
|
| 175 |
+
|
| 176 |
+
if not retry_state.outcome.failed:
|
| 177 |
+
return self.predicate(retry_state.outcome.result())
|
| 178 |
+
else:
|
| 179 |
+
return False
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
class retry_if_not_result(retry_base):
|
| 183 |
+
"""Retries if the result refutes a predicate."""
|
| 184 |
+
|
| 185 |
+
def __init__(self, predicate: typing.Callable[[typing.Any], bool]) -> None:
|
| 186 |
+
self.predicate = predicate
|
| 187 |
+
|
| 188 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 189 |
+
if retry_state.outcome is None:
|
| 190 |
+
raise RuntimeError("__call__() called before outcome was set")
|
| 191 |
+
|
| 192 |
+
if not retry_state.outcome.failed:
|
| 193 |
+
return not self.predicate(retry_state.outcome.result())
|
| 194 |
+
else:
|
| 195 |
+
return False
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
class retry_if_exception_message(retry_if_exception):
|
| 199 |
+
"""Retries if an exception message equals or matches."""
|
| 200 |
+
|
| 201 |
+
def __init__(
|
| 202 |
+
self,
|
| 203 |
+
message: typing.Optional[str] = None,
|
| 204 |
+
match: typing.Optional[str] = None,
|
| 205 |
+
) -> None:
|
| 206 |
+
if message and match:
|
| 207 |
+
raise TypeError(f"{self.__class__.__name__}() takes either 'message' or 'match', not both")
|
| 208 |
+
|
| 209 |
+
# set predicate
|
| 210 |
+
if message:
|
| 211 |
+
|
| 212 |
+
def message_fnc(exception: BaseException) -> bool:
|
| 213 |
+
return message == str(exception)
|
| 214 |
+
|
| 215 |
+
predicate = message_fnc
|
| 216 |
+
elif match:
|
| 217 |
+
prog = re.compile(match)
|
| 218 |
+
|
| 219 |
+
def match_fnc(exception: BaseException) -> bool:
|
| 220 |
+
return bool(prog.match(str(exception)))
|
| 221 |
+
|
| 222 |
+
predicate = match_fnc
|
| 223 |
+
else:
|
| 224 |
+
raise TypeError(f"{self.__class__.__name__}() missing 1 required argument 'message' or 'match'")
|
| 225 |
+
|
| 226 |
+
super().__init__(predicate)
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
class retry_if_not_exception_message(retry_if_exception_message):
|
| 230 |
+
"""Retries until an exception message equals or matches."""
|
| 231 |
+
|
| 232 |
+
def __init__(
|
| 233 |
+
self,
|
| 234 |
+
message: typing.Optional[str] = None,
|
| 235 |
+
match: typing.Optional[str] = None,
|
| 236 |
+
) -> None:
|
| 237 |
+
super().__init__(message, match)
|
| 238 |
+
# invert predicate
|
| 239 |
+
if_predicate = self.predicate
|
| 240 |
+
self.predicate = lambda *args_, **kwargs_: not if_predicate(*args_, **kwargs_)
|
| 241 |
+
|
| 242 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 243 |
+
if retry_state.outcome is None:
|
| 244 |
+
raise RuntimeError("__call__() called before outcome was set")
|
| 245 |
+
|
| 246 |
+
if not retry_state.outcome.failed:
|
| 247 |
+
return True
|
| 248 |
+
|
| 249 |
+
exception = retry_state.outcome.exception()
|
| 250 |
+
if exception is None:
|
| 251 |
+
raise RuntimeError("outcome failed but the exception is None")
|
| 252 |
+
return self.predicate(exception)
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
class retry_any(retry_base):
|
| 256 |
+
"""Retries if any of the retries condition is valid."""
|
| 257 |
+
|
| 258 |
+
def __init__(self, *retries: retry_base) -> None:
|
| 259 |
+
self.retries = retries
|
| 260 |
+
|
| 261 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 262 |
+
return any(r(retry_state) for r in self.retries)
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
class retry_all(retry_base):
|
| 266 |
+
"""Retries if all the retries condition are valid."""
|
| 267 |
+
|
| 268 |
+
def __init__(self, *retries: retry_base) -> None:
|
| 269 |
+
self.retries = retries
|
| 270 |
+
|
| 271 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 272 |
+
return all(r(retry_state) for r in self.retries)
|
.venv/Lib/site-packages/pip/_vendor/tenacity/stop.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016–2021 Julien Danjou
|
| 2 |
+
# Copyright 2016 Joshua Harlow
|
| 3 |
+
# Copyright 2013-2014 Ray Holder
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
import abc
|
| 17 |
+
import typing
|
| 18 |
+
|
| 19 |
+
from pip._vendor.tenacity import _utils
|
| 20 |
+
|
| 21 |
+
if typing.TYPE_CHECKING:
|
| 22 |
+
import threading
|
| 23 |
+
|
| 24 |
+
from pip._vendor.tenacity import RetryCallState
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class stop_base(abc.ABC):
|
| 28 |
+
"""Abstract base class for stop strategies."""
|
| 29 |
+
|
| 30 |
+
@abc.abstractmethod
|
| 31 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 32 |
+
pass
|
| 33 |
+
|
| 34 |
+
def __and__(self, other: "stop_base") -> "stop_all":
|
| 35 |
+
return stop_all(self, other)
|
| 36 |
+
|
| 37 |
+
def __or__(self, other: "stop_base") -> "stop_any":
|
| 38 |
+
return stop_any(self, other)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
StopBaseT = typing.Union[stop_base, typing.Callable[["RetryCallState"], bool]]
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class stop_any(stop_base):
|
| 45 |
+
"""Stop if any of the stop condition is valid."""
|
| 46 |
+
|
| 47 |
+
def __init__(self, *stops: stop_base) -> None:
|
| 48 |
+
self.stops = stops
|
| 49 |
+
|
| 50 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 51 |
+
return any(x(retry_state) for x in self.stops)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class stop_all(stop_base):
|
| 55 |
+
"""Stop if all the stop conditions are valid."""
|
| 56 |
+
|
| 57 |
+
def __init__(self, *stops: stop_base) -> None:
|
| 58 |
+
self.stops = stops
|
| 59 |
+
|
| 60 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 61 |
+
return all(x(retry_state) for x in self.stops)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class _stop_never(stop_base):
|
| 65 |
+
"""Never stop."""
|
| 66 |
+
|
| 67 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 68 |
+
return False
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
stop_never = _stop_never()
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class stop_when_event_set(stop_base):
|
| 75 |
+
"""Stop when the given event is set."""
|
| 76 |
+
|
| 77 |
+
def __init__(self, event: "threading.Event") -> None:
|
| 78 |
+
self.event = event
|
| 79 |
+
|
| 80 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 81 |
+
return self.event.is_set()
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class stop_after_attempt(stop_base):
|
| 85 |
+
"""Stop when the previous attempt >= max_attempt."""
|
| 86 |
+
|
| 87 |
+
def __init__(self, max_attempt_number: int) -> None:
|
| 88 |
+
self.max_attempt_number = max_attempt_number
|
| 89 |
+
|
| 90 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 91 |
+
return retry_state.attempt_number >= self.max_attempt_number
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class stop_after_delay(stop_base):
|
| 95 |
+
"""Stop when the time from the first attempt >= limit."""
|
| 96 |
+
|
| 97 |
+
def __init__(self, max_delay: _utils.time_unit_type) -> None:
|
| 98 |
+
self.max_delay = _utils.to_seconds(max_delay)
|
| 99 |
+
|
| 100 |
+
def __call__(self, retry_state: "RetryCallState") -> bool:
|
| 101 |
+
if retry_state.seconds_since_start is None:
|
| 102 |
+
raise RuntimeError("__call__() called but seconds_since_start is not set")
|
| 103 |
+
return retry_state.seconds_since_start >= self.max_delay
|
.venv/Lib/site-packages/pip/_vendor/tenacity/tornadoweb.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017 Elisey Zanko
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import sys
|
| 16 |
+
import typing
|
| 17 |
+
|
| 18 |
+
from pip._vendor.tenacity import BaseRetrying
|
| 19 |
+
from pip._vendor.tenacity import DoAttempt
|
| 20 |
+
from pip._vendor.tenacity import DoSleep
|
| 21 |
+
from pip._vendor.tenacity import RetryCallState
|
| 22 |
+
|
| 23 |
+
from tornado import gen
|
| 24 |
+
|
| 25 |
+
if typing.TYPE_CHECKING:
|
| 26 |
+
from tornado.concurrent import Future
|
| 27 |
+
|
| 28 |
+
_RetValT = typing.TypeVar("_RetValT")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class TornadoRetrying(BaseRetrying):
|
| 32 |
+
def __init__(self, sleep: "typing.Callable[[float], Future[None]]" = gen.sleep, **kwargs: typing.Any) -> None:
|
| 33 |
+
super().__init__(**kwargs)
|
| 34 |
+
self.sleep = sleep
|
| 35 |
+
|
| 36 |
+
@gen.coroutine # type: ignore[misc]
|
| 37 |
+
def __call__(
|
| 38 |
+
self,
|
| 39 |
+
fn: "typing.Callable[..., typing.Union[typing.Generator[typing.Any, typing.Any, _RetValT], Future[_RetValT]]]",
|
| 40 |
+
*args: typing.Any,
|
| 41 |
+
**kwargs: typing.Any,
|
| 42 |
+
) -> "typing.Generator[typing.Any, typing.Any, _RetValT]":
|
| 43 |
+
self.begin()
|
| 44 |
+
|
| 45 |
+
retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
|
| 46 |
+
while True:
|
| 47 |
+
do = self.iter(retry_state=retry_state)
|
| 48 |
+
if isinstance(do, DoAttempt):
|
| 49 |
+
try:
|
| 50 |
+
result = yield fn(*args, **kwargs)
|
| 51 |
+
except BaseException: # noqa: B902
|
| 52 |
+
retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
|
| 53 |
+
else:
|
| 54 |
+
retry_state.set_result(result)
|
| 55 |
+
elif isinstance(do, DoSleep):
|
| 56 |
+
retry_state.prepare_for_next_attempt()
|
| 57 |
+
yield self.sleep(do)
|
| 58 |
+
else:
|
| 59 |
+
raise gen.Return(do)
|
.venv/Lib/site-packages/pip/_vendor/tenacity/wait.py
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016–2021 Julien Danjou
|
| 2 |
+
# Copyright 2016 Joshua Harlow
|
| 3 |
+
# Copyright 2013-2014 Ray Holder
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
|
| 17 |
+
import abc
|
| 18 |
+
import random
|
| 19 |
+
import typing
|
| 20 |
+
|
| 21 |
+
from pip._vendor.tenacity import _utils
|
| 22 |
+
|
| 23 |
+
if typing.TYPE_CHECKING:
|
| 24 |
+
from pip._vendor.tenacity import RetryCallState
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class wait_base(abc.ABC):
|
| 28 |
+
"""Abstract base class for wait strategies."""
|
| 29 |
+
|
| 30 |
+
@abc.abstractmethod
|
| 31 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 32 |
+
pass
|
| 33 |
+
|
| 34 |
+
def __add__(self, other: "wait_base") -> "wait_combine":
|
| 35 |
+
return wait_combine(self, other)
|
| 36 |
+
|
| 37 |
+
def __radd__(self, other: "wait_base") -> typing.Union["wait_combine", "wait_base"]:
|
| 38 |
+
# make it possible to use multiple waits with the built-in sum function
|
| 39 |
+
if other == 0: # type: ignore[comparison-overlap]
|
| 40 |
+
return self
|
| 41 |
+
return self.__add__(other)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
WaitBaseT = typing.Union[wait_base, typing.Callable[["RetryCallState"], typing.Union[float, int]]]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class wait_fixed(wait_base):
|
| 48 |
+
"""Wait strategy that waits a fixed amount of time between each retry."""
|
| 49 |
+
|
| 50 |
+
def __init__(self, wait: _utils.time_unit_type) -> None:
|
| 51 |
+
self.wait_fixed = _utils.to_seconds(wait)
|
| 52 |
+
|
| 53 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 54 |
+
return self.wait_fixed
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class wait_none(wait_fixed):
|
| 58 |
+
"""Wait strategy that doesn't wait at all before retrying."""
|
| 59 |
+
|
| 60 |
+
def __init__(self) -> None:
|
| 61 |
+
super().__init__(0)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class wait_random(wait_base):
|
| 65 |
+
"""Wait strategy that waits a random amount of time between min/max."""
|
| 66 |
+
|
| 67 |
+
def __init__(self, min: _utils.time_unit_type = 0, max: _utils.time_unit_type = 1) -> None: # noqa
|
| 68 |
+
self.wait_random_min = _utils.to_seconds(min)
|
| 69 |
+
self.wait_random_max = _utils.to_seconds(max)
|
| 70 |
+
|
| 71 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 72 |
+
return self.wait_random_min + (random.random() * (self.wait_random_max - self.wait_random_min))
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class wait_combine(wait_base):
|
| 76 |
+
"""Combine several waiting strategies."""
|
| 77 |
+
|
| 78 |
+
def __init__(self, *strategies: wait_base) -> None:
|
| 79 |
+
self.wait_funcs = strategies
|
| 80 |
+
|
| 81 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 82 |
+
return sum(x(retry_state=retry_state) for x in self.wait_funcs)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
class wait_chain(wait_base):
|
| 86 |
+
"""Chain two or more waiting strategies.
|
| 87 |
+
|
| 88 |
+
If all strategies are exhausted, the very last strategy is used
|
| 89 |
+
thereafter.
|
| 90 |
+
|
| 91 |
+
For example::
|
| 92 |
+
|
| 93 |
+
@retry(wait=wait_chain(*[wait_fixed(1) for i in range(3)] +
|
| 94 |
+
[wait_fixed(2) for j in range(5)] +
|
| 95 |
+
[wait_fixed(5) for k in range(4)))
|
| 96 |
+
def wait_chained():
|
| 97 |
+
print("Wait 1s for 3 attempts, 2s for 5 attempts and 5s
|
| 98 |
+
thereafter.")
|
| 99 |
+
"""
|
| 100 |
+
|
| 101 |
+
def __init__(self, *strategies: wait_base) -> None:
|
| 102 |
+
self.strategies = strategies
|
| 103 |
+
|
| 104 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 105 |
+
wait_func_no = min(max(retry_state.attempt_number, 1), len(self.strategies))
|
| 106 |
+
wait_func = self.strategies[wait_func_no - 1]
|
| 107 |
+
return wait_func(retry_state=retry_state)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
class wait_incrementing(wait_base):
|
| 111 |
+
"""Wait an incremental amount of time after each attempt.
|
| 112 |
+
|
| 113 |
+
Starting at a starting value and incrementing by a value for each attempt
|
| 114 |
+
(and restricting the upper limit to some maximum value).
|
| 115 |
+
"""
|
| 116 |
+
|
| 117 |
+
def __init__(
|
| 118 |
+
self,
|
| 119 |
+
start: _utils.time_unit_type = 0,
|
| 120 |
+
increment: _utils.time_unit_type = 100,
|
| 121 |
+
max: _utils.time_unit_type = _utils.MAX_WAIT, # noqa
|
| 122 |
+
) -> None:
|
| 123 |
+
self.start = _utils.to_seconds(start)
|
| 124 |
+
self.increment = _utils.to_seconds(increment)
|
| 125 |
+
self.max = _utils.to_seconds(max)
|
| 126 |
+
|
| 127 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 128 |
+
result = self.start + (self.increment * (retry_state.attempt_number - 1))
|
| 129 |
+
return max(0, min(result, self.max))
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
class wait_exponential(wait_base):
|
| 133 |
+
"""Wait strategy that applies exponential backoff.
|
| 134 |
+
|
| 135 |
+
It allows for a customized multiplier and an ability to restrict the
|
| 136 |
+
upper and lower limits to some maximum and minimum value.
|
| 137 |
+
|
| 138 |
+
The intervals are fixed (i.e. there is no jitter), so this strategy is
|
| 139 |
+
suitable for balancing retries against latency when a required resource is
|
| 140 |
+
unavailable for an unknown duration, but *not* suitable for resolving
|
| 141 |
+
contention between multiple processes for a shared resource. Use
|
| 142 |
+
wait_random_exponential for the latter case.
|
| 143 |
+
"""
|
| 144 |
+
|
| 145 |
+
def __init__(
|
| 146 |
+
self,
|
| 147 |
+
multiplier: typing.Union[int, float] = 1,
|
| 148 |
+
max: _utils.time_unit_type = _utils.MAX_WAIT, # noqa
|
| 149 |
+
exp_base: typing.Union[int, float] = 2,
|
| 150 |
+
min: _utils.time_unit_type = 0, # noqa
|
| 151 |
+
) -> None:
|
| 152 |
+
self.multiplier = multiplier
|
| 153 |
+
self.min = _utils.to_seconds(min)
|
| 154 |
+
self.max = _utils.to_seconds(max)
|
| 155 |
+
self.exp_base = exp_base
|
| 156 |
+
|
| 157 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 158 |
+
try:
|
| 159 |
+
exp = self.exp_base ** (retry_state.attempt_number - 1)
|
| 160 |
+
result = self.multiplier * exp
|
| 161 |
+
except OverflowError:
|
| 162 |
+
return self.max
|
| 163 |
+
return max(max(0, self.min), min(result, self.max))
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
class wait_random_exponential(wait_exponential):
|
| 167 |
+
"""Random wait with exponentially widening window.
|
| 168 |
+
|
| 169 |
+
An exponential backoff strategy used to mediate contention between multiple
|
| 170 |
+
uncoordinated processes for a shared resource in distributed systems. This
|
| 171 |
+
is the sense in which "exponential backoff" is meant in e.g. Ethernet
|
| 172 |
+
networking, and corresponds to the "Full Jitter" algorithm described in
|
| 173 |
+
this blog post:
|
| 174 |
+
|
| 175 |
+
https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
| 176 |
+
|
| 177 |
+
Each retry occurs at a random time in a geometrically expanding interval.
|
| 178 |
+
It allows for a custom multiplier and an ability to restrict the upper
|
| 179 |
+
limit of the random interval to some maximum value.
|
| 180 |
+
|
| 181 |
+
Example::
|
| 182 |
+
|
| 183 |
+
wait_random_exponential(multiplier=0.5, # initial window 0.5s
|
| 184 |
+
max=60) # max 60s timeout
|
| 185 |
+
|
| 186 |
+
When waiting for an unavailable resource to become available again, as
|
| 187 |
+
opposed to trying to resolve contention for a shared resource, the
|
| 188 |
+
wait_exponential strategy (which uses a fixed interval) may be preferable.
|
| 189 |
+
|
| 190 |
+
"""
|
| 191 |
+
|
| 192 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 193 |
+
high = super().__call__(retry_state=retry_state)
|
| 194 |
+
return random.uniform(0, high)
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
class wait_exponential_jitter(wait_base):
|
| 198 |
+
"""Wait strategy that applies exponential backoff and jitter.
|
| 199 |
+
|
| 200 |
+
It allows for a customized initial wait, maximum wait and jitter.
|
| 201 |
+
|
| 202 |
+
This implements the strategy described here:
|
| 203 |
+
https://cloud.google.com/storage/docs/retry-strategy
|
| 204 |
+
|
| 205 |
+
The wait time is min(initial * 2**n + random.uniform(0, jitter), maximum)
|
| 206 |
+
where n is the retry count.
|
| 207 |
+
"""
|
| 208 |
+
|
| 209 |
+
def __init__(
|
| 210 |
+
self,
|
| 211 |
+
initial: float = 1,
|
| 212 |
+
max: float = _utils.MAX_WAIT, # noqa
|
| 213 |
+
exp_base: float = 2,
|
| 214 |
+
jitter: float = 1,
|
| 215 |
+
) -> None:
|
| 216 |
+
self.initial = initial
|
| 217 |
+
self.max = max
|
| 218 |
+
self.exp_base = exp_base
|
| 219 |
+
self.jitter = jitter
|
| 220 |
+
|
| 221 |
+
def __call__(self, retry_state: "RetryCallState") -> float:
|
| 222 |
+
jitter = random.uniform(0, self.jitter)
|
| 223 |
+
try:
|
| 224 |
+
exp = self.exp_base ** (retry_state.attempt_number - 1)
|
| 225 |
+
result = self.initial * exp + jitter
|
| 226 |
+
except OverflowError:
|
| 227 |
+
result = self.max
|
| 228 |
+
return max(0, min(result, self.max))
|
.venv/Lib/site-packages/pip/_vendor/tomli/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: MIT
|
| 2 |
+
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
|
| 3 |
+
# Licensed to PSF under a Contributor Agreement.
|
| 4 |
+
|
| 5 |
+
__all__ = ("loads", "load", "TOMLDecodeError")
|
| 6 |
+
__version__ = "2.0.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
|
| 7 |
+
|
| 8 |
+
from ._parser import TOMLDecodeError, load, loads
|
| 9 |
+
|
| 10 |
+
# Pretend this exception was created here.
|
| 11 |
+
TOMLDecodeError.__module__ = __name__
|
.venv/Lib/site-packages/pip/_vendor/tomli/_parser.py
ADDED
|
@@ -0,0 +1,691 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: MIT
|
| 2 |
+
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
|
| 3 |
+
# Licensed to PSF under a Contributor Agreement.
|
| 4 |
+
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
|
| 7 |
+
from collections.abc import Iterable
|
| 8 |
+
import string
|
| 9 |
+
from types import MappingProxyType
|
| 10 |
+
from typing import Any, BinaryIO, NamedTuple
|
| 11 |
+
|
| 12 |
+
from ._re import (
|
| 13 |
+
RE_DATETIME,
|
| 14 |
+
RE_LOCALTIME,
|
| 15 |
+
RE_NUMBER,
|
| 16 |
+
match_to_datetime,
|
| 17 |
+
match_to_localtime,
|
| 18 |
+
match_to_number,
|
| 19 |
+
)
|
| 20 |
+
from ._types import Key, ParseFloat, Pos
|
| 21 |
+
|
| 22 |
+
ASCII_CTRL = frozenset(chr(i) for i in range(32)) | frozenset(chr(127))
|
| 23 |
+
|
| 24 |
+
# Neither of these sets include quotation mark or backslash. They are
|
| 25 |
+
# currently handled as separate cases in the parser functions.
|
| 26 |
+
ILLEGAL_BASIC_STR_CHARS = ASCII_CTRL - frozenset("\t")
|
| 27 |
+
ILLEGAL_MULTILINE_BASIC_STR_CHARS = ASCII_CTRL - frozenset("\t\n")
|
| 28 |
+
|
| 29 |
+
ILLEGAL_LITERAL_STR_CHARS = ILLEGAL_BASIC_STR_CHARS
|
| 30 |
+
ILLEGAL_MULTILINE_LITERAL_STR_CHARS = ILLEGAL_MULTILINE_BASIC_STR_CHARS
|
| 31 |
+
|
| 32 |
+
ILLEGAL_COMMENT_CHARS = ILLEGAL_BASIC_STR_CHARS
|
| 33 |
+
|
| 34 |
+
TOML_WS = frozenset(" \t")
|
| 35 |
+
TOML_WS_AND_NEWLINE = TOML_WS | frozenset("\n")
|
| 36 |
+
BARE_KEY_CHARS = frozenset(string.ascii_letters + string.digits + "-_")
|
| 37 |
+
KEY_INITIAL_CHARS = BARE_KEY_CHARS | frozenset("\"'")
|
| 38 |
+
HEXDIGIT_CHARS = frozenset(string.hexdigits)
|
| 39 |
+
|
| 40 |
+
BASIC_STR_ESCAPE_REPLACEMENTS = MappingProxyType(
|
| 41 |
+
{
|
| 42 |
+
"\\b": "\u0008", # backspace
|
| 43 |
+
"\\t": "\u0009", # tab
|
| 44 |
+
"\\n": "\u000A", # linefeed
|
| 45 |
+
"\\f": "\u000C", # form feed
|
| 46 |
+
"\\r": "\u000D", # carriage return
|
| 47 |
+
'\\"': "\u0022", # quote
|
| 48 |
+
"\\\\": "\u005C", # backslash
|
| 49 |
+
}
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
class TOMLDecodeError(ValueError):
|
| 54 |
+
"""An error raised if a document is not valid TOML."""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def load(__fp: BinaryIO, *, parse_float: ParseFloat = float) -> dict[str, Any]:
|
| 58 |
+
"""Parse TOML from a binary file object."""
|
| 59 |
+
b = __fp.read()
|
| 60 |
+
try:
|
| 61 |
+
s = b.decode()
|
| 62 |
+
except AttributeError:
|
| 63 |
+
raise TypeError(
|
| 64 |
+
"File must be opened in binary mode, e.g. use `open('foo.toml', 'rb')`"
|
| 65 |
+
) from None
|
| 66 |
+
return loads(s, parse_float=parse_float)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def loads(__s: str, *, parse_float: ParseFloat = float) -> dict[str, Any]: # noqa: C901
|
| 70 |
+
"""Parse TOML from a string."""
|
| 71 |
+
|
| 72 |
+
# The spec allows converting "\r\n" to "\n", even in string
|
| 73 |
+
# literals. Let's do so to simplify parsing.
|
| 74 |
+
src = __s.replace("\r\n", "\n")
|
| 75 |
+
pos = 0
|
| 76 |
+
out = Output(NestedDict(), Flags())
|
| 77 |
+
header: Key = ()
|
| 78 |
+
parse_float = make_safe_parse_float(parse_float)
|
| 79 |
+
|
| 80 |
+
# Parse one statement at a time
|
| 81 |
+
# (typically means one line in TOML source)
|
| 82 |
+
while True:
|
| 83 |
+
# 1. Skip line leading whitespace
|
| 84 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 85 |
+
|
| 86 |
+
# 2. Parse rules. Expect one of the following:
|
| 87 |
+
# - end of file
|
| 88 |
+
# - end of line
|
| 89 |
+
# - comment
|
| 90 |
+
# - key/value pair
|
| 91 |
+
# - append dict to list (and move to its namespace)
|
| 92 |
+
# - create dict (and move to its namespace)
|
| 93 |
+
# Skip trailing whitespace when applicable.
|
| 94 |
+
try:
|
| 95 |
+
char = src[pos]
|
| 96 |
+
except IndexError:
|
| 97 |
+
break
|
| 98 |
+
if char == "\n":
|
| 99 |
+
pos += 1
|
| 100 |
+
continue
|
| 101 |
+
if char in KEY_INITIAL_CHARS:
|
| 102 |
+
pos = key_value_rule(src, pos, out, header, parse_float)
|
| 103 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 104 |
+
elif char == "[":
|
| 105 |
+
try:
|
| 106 |
+
second_char: str | None = src[pos + 1]
|
| 107 |
+
except IndexError:
|
| 108 |
+
second_char = None
|
| 109 |
+
out.flags.finalize_pending()
|
| 110 |
+
if second_char == "[":
|
| 111 |
+
pos, header = create_list_rule(src, pos, out)
|
| 112 |
+
else:
|
| 113 |
+
pos, header = create_dict_rule(src, pos, out)
|
| 114 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 115 |
+
elif char != "#":
|
| 116 |
+
raise suffixed_err(src, pos, "Invalid statement")
|
| 117 |
+
|
| 118 |
+
# 3. Skip comment
|
| 119 |
+
pos = skip_comment(src, pos)
|
| 120 |
+
|
| 121 |
+
# 4. Expect end of line or end of file
|
| 122 |
+
try:
|
| 123 |
+
char = src[pos]
|
| 124 |
+
except IndexError:
|
| 125 |
+
break
|
| 126 |
+
if char != "\n":
|
| 127 |
+
raise suffixed_err(
|
| 128 |
+
src, pos, "Expected newline or end of document after a statement"
|
| 129 |
+
)
|
| 130 |
+
pos += 1
|
| 131 |
+
|
| 132 |
+
return out.data.dict
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class Flags:
|
| 136 |
+
"""Flags that map to parsed keys/namespaces."""
|
| 137 |
+
|
| 138 |
+
# Marks an immutable namespace (inline array or inline table).
|
| 139 |
+
FROZEN = 0
|
| 140 |
+
# Marks a nest that has been explicitly created and can no longer
|
| 141 |
+
# be opened using the "[table]" syntax.
|
| 142 |
+
EXPLICIT_NEST = 1
|
| 143 |
+
|
| 144 |
+
def __init__(self) -> None:
|
| 145 |
+
self._flags: dict[str, dict] = {}
|
| 146 |
+
self._pending_flags: set[tuple[Key, int]] = set()
|
| 147 |
+
|
| 148 |
+
def add_pending(self, key: Key, flag: int) -> None:
|
| 149 |
+
self._pending_flags.add((key, flag))
|
| 150 |
+
|
| 151 |
+
def finalize_pending(self) -> None:
|
| 152 |
+
for key, flag in self._pending_flags:
|
| 153 |
+
self.set(key, flag, recursive=False)
|
| 154 |
+
self._pending_flags.clear()
|
| 155 |
+
|
| 156 |
+
def unset_all(self, key: Key) -> None:
|
| 157 |
+
cont = self._flags
|
| 158 |
+
for k in key[:-1]:
|
| 159 |
+
if k not in cont:
|
| 160 |
+
return
|
| 161 |
+
cont = cont[k]["nested"]
|
| 162 |
+
cont.pop(key[-1], None)
|
| 163 |
+
|
| 164 |
+
def set(self, key: Key, flag: int, *, recursive: bool) -> None: # noqa: A003
|
| 165 |
+
cont = self._flags
|
| 166 |
+
key_parent, key_stem = key[:-1], key[-1]
|
| 167 |
+
for k in key_parent:
|
| 168 |
+
if k not in cont:
|
| 169 |
+
cont[k] = {"flags": set(), "recursive_flags": set(), "nested": {}}
|
| 170 |
+
cont = cont[k]["nested"]
|
| 171 |
+
if key_stem not in cont:
|
| 172 |
+
cont[key_stem] = {"flags": set(), "recursive_flags": set(), "nested": {}}
|
| 173 |
+
cont[key_stem]["recursive_flags" if recursive else "flags"].add(flag)
|
| 174 |
+
|
| 175 |
+
def is_(self, key: Key, flag: int) -> bool:
|
| 176 |
+
if not key:
|
| 177 |
+
return False # document root has no flags
|
| 178 |
+
cont = self._flags
|
| 179 |
+
for k in key[:-1]:
|
| 180 |
+
if k not in cont:
|
| 181 |
+
return False
|
| 182 |
+
inner_cont = cont[k]
|
| 183 |
+
if flag in inner_cont["recursive_flags"]:
|
| 184 |
+
return True
|
| 185 |
+
cont = inner_cont["nested"]
|
| 186 |
+
key_stem = key[-1]
|
| 187 |
+
if key_stem in cont:
|
| 188 |
+
cont = cont[key_stem]
|
| 189 |
+
return flag in cont["flags"] or flag in cont["recursive_flags"]
|
| 190 |
+
return False
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
class NestedDict:
|
| 194 |
+
def __init__(self) -> None:
|
| 195 |
+
# The parsed content of the TOML document
|
| 196 |
+
self.dict: dict[str, Any] = {}
|
| 197 |
+
|
| 198 |
+
def get_or_create_nest(
|
| 199 |
+
self,
|
| 200 |
+
key: Key,
|
| 201 |
+
*,
|
| 202 |
+
access_lists: bool = True,
|
| 203 |
+
) -> dict:
|
| 204 |
+
cont: Any = self.dict
|
| 205 |
+
for k in key:
|
| 206 |
+
if k not in cont:
|
| 207 |
+
cont[k] = {}
|
| 208 |
+
cont = cont[k]
|
| 209 |
+
if access_lists and isinstance(cont, list):
|
| 210 |
+
cont = cont[-1]
|
| 211 |
+
if not isinstance(cont, dict):
|
| 212 |
+
raise KeyError("There is no nest behind this key")
|
| 213 |
+
return cont
|
| 214 |
+
|
| 215 |
+
def append_nest_to_list(self, key: Key) -> None:
|
| 216 |
+
cont = self.get_or_create_nest(key[:-1])
|
| 217 |
+
last_key = key[-1]
|
| 218 |
+
if last_key in cont:
|
| 219 |
+
list_ = cont[last_key]
|
| 220 |
+
if not isinstance(list_, list):
|
| 221 |
+
raise KeyError("An object other than list found behind this key")
|
| 222 |
+
list_.append({})
|
| 223 |
+
else:
|
| 224 |
+
cont[last_key] = [{}]
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
class Output(NamedTuple):
|
| 228 |
+
data: NestedDict
|
| 229 |
+
flags: Flags
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def skip_chars(src: str, pos: Pos, chars: Iterable[str]) -> Pos:
|
| 233 |
+
try:
|
| 234 |
+
while src[pos] in chars:
|
| 235 |
+
pos += 1
|
| 236 |
+
except IndexError:
|
| 237 |
+
pass
|
| 238 |
+
return pos
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def skip_until(
|
| 242 |
+
src: str,
|
| 243 |
+
pos: Pos,
|
| 244 |
+
expect: str,
|
| 245 |
+
*,
|
| 246 |
+
error_on: frozenset[str],
|
| 247 |
+
error_on_eof: bool,
|
| 248 |
+
) -> Pos:
|
| 249 |
+
try:
|
| 250 |
+
new_pos = src.index(expect, pos)
|
| 251 |
+
except ValueError:
|
| 252 |
+
new_pos = len(src)
|
| 253 |
+
if error_on_eof:
|
| 254 |
+
raise suffixed_err(src, new_pos, f"Expected {expect!r}") from None
|
| 255 |
+
|
| 256 |
+
if not error_on.isdisjoint(src[pos:new_pos]):
|
| 257 |
+
while src[pos] not in error_on:
|
| 258 |
+
pos += 1
|
| 259 |
+
raise suffixed_err(src, pos, f"Found invalid character {src[pos]!r}")
|
| 260 |
+
return new_pos
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def skip_comment(src: str, pos: Pos) -> Pos:
|
| 264 |
+
try:
|
| 265 |
+
char: str | None = src[pos]
|
| 266 |
+
except IndexError:
|
| 267 |
+
char = None
|
| 268 |
+
if char == "#":
|
| 269 |
+
return skip_until(
|
| 270 |
+
src, pos + 1, "\n", error_on=ILLEGAL_COMMENT_CHARS, error_on_eof=False
|
| 271 |
+
)
|
| 272 |
+
return pos
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def skip_comments_and_array_ws(src: str, pos: Pos) -> Pos:
|
| 276 |
+
while True:
|
| 277 |
+
pos_before_skip = pos
|
| 278 |
+
pos = skip_chars(src, pos, TOML_WS_AND_NEWLINE)
|
| 279 |
+
pos = skip_comment(src, pos)
|
| 280 |
+
if pos == pos_before_skip:
|
| 281 |
+
return pos
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def create_dict_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:
|
| 285 |
+
pos += 1 # Skip "["
|
| 286 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 287 |
+
pos, key = parse_key(src, pos)
|
| 288 |
+
|
| 289 |
+
if out.flags.is_(key, Flags.EXPLICIT_NEST) or out.flags.is_(key, Flags.FROZEN):
|
| 290 |
+
raise suffixed_err(src, pos, f"Cannot declare {key} twice")
|
| 291 |
+
out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False)
|
| 292 |
+
try:
|
| 293 |
+
out.data.get_or_create_nest(key)
|
| 294 |
+
except KeyError:
|
| 295 |
+
raise suffixed_err(src, pos, "Cannot overwrite a value") from None
|
| 296 |
+
|
| 297 |
+
if not src.startswith("]", pos):
|
| 298 |
+
raise suffixed_err(src, pos, "Expected ']' at the end of a table declaration")
|
| 299 |
+
return pos + 1, key
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:
|
| 303 |
+
pos += 2 # Skip "[["
|
| 304 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 305 |
+
pos, key = parse_key(src, pos)
|
| 306 |
+
|
| 307 |
+
if out.flags.is_(key, Flags.FROZEN):
|
| 308 |
+
raise suffixed_err(src, pos, f"Cannot mutate immutable namespace {key}")
|
| 309 |
+
# Free the namespace now that it points to another empty list item...
|
| 310 |
+
out.flags.unset_all(key)
|
| 311 |
+
# ...but this key precisely is still prohibited from table declaration
|
| 312 |
+
out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False)
|
| 313 |
+
try:
|
| 314 |
+
out.data.append_nest_to_list(key)
|
| 315 |
+
except KeyError:
|
| 316 |
+
raise suffixed_err(src, pos, "Cannot overwrite a value") from None
|
| 317 |
+
|
| 318 |
+
if not src.startswith("]]", pos):
|
| 319 |
+
raise suffixed_err(src, pos, "Expected ']]' at the end of an array declaration")
|
| 320 |
+
return pos + 2, key
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def key_value_rule(
|
| 324 |
+
src: str, pos: Pos, out: Output, header: Key, parse_float: ParseFloat
|
| 325 |
+
) -> Pos:
|
| 326 |
+
pos, key, value = parse_key_value_pair(src, pos, parse_float)
|
| 327 |
+
key_parent, key_stem = key[:-1], key[-1]
|
| 328 |
+
abs_key_parent = header + key_parent
|
| 329 |
+
|
| 330 |
+
relative_path_cont_keys = (header + key[:i] for i in range(1, len(key)))
|
| 331 |
+
for cont_key in relative_path_cont_keys:
|
| 332 |
+
# Check that dotted key syntax does not redefine an existing table
|
| 333 |
+
if out.flags.is_(cont_key, Flags.EXPLICIT_NEST):
|
| 334 |
+
raise suffixed_err(src, pos, f"Cannot redefine namespace {cont_key}")
|
| 335 |
+
# Containers in the relative path can't be opened with the table syntax or
|
| 336 |
+
# dotted key/value syntax in following table sections.
|
| 337 |
+
out.flags.add_pending(cont_key, Flags.EXPLICIT_NEST)
|
| 338 |
+
|
| 339 |
+
if out.flags.is_(abs_key_parent, Flags.FROZEN):
|
| 340 |
+
raise suffixed_err(
|
| 341 |
+
src, pos, f"Cannot mutate immutable namespace {abs_key_parent}"
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
try:
|
| 345 |
+
nest = out.data.get_or_create_nest(abs_key_parent)
|
| 346 |
+
except KeyError:
|
| 347 |
+
raise suffixed_err(src, pos, "Cannot overwrite a value") from None
|
| 348 |
+
if key_stem in nest:
|
| 349 |
+
raise suffixed_err(src, pos, "Cannot overwrite a value")
|
| 350 |
+
# Mark inline table and array namespaces recursively immutable
|
| 351 |
+
if isinstance(value, (dict, list)):
|
| 352 |
+
out.flags.set(header + key, Flags.FROZEN, recursive=True)
|
| 353 |
+
nest[key_stem] = value
|
| 354 |
+
return pos
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
def parse_key_value_pair(
|
| 358 |
+
src: str, pos: Pos, parse_float: ParseFloat
|
| 359 |
+
) -> tuple[Pos, Key, Any]:
|
| 360 |
+
pos, key = parse_key(src, pos)
|
| 361 |
+
try:
|
| 362 |
+
char: str | None = src[pos]
|
| 363 |
+
except IndexError:
|
| 364 |
+
char = None
|
| 365 |
+
if char != "=":
|
| 366 |
+
raise suffixed_err(src, pos, "Expected '=' after a key in a key/value pair")
|
| 367 |
+
pos += 1
|
| 368 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 369 |
+
pos, value = parse_value(src, pos, parse_float)
|
| 370 |
+
return pos, key, value
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
def parse_key(src: str, pos: Pos) -> tuple[Pos, Key]:
|
| 374 |
+
pos, key_part = parse_key_part(src, pos)
|
| 375 |
+
key: Key = (key_part,)
|
| 376 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 377 |
+
while True:
|
| 378 |
+
try:
|
| 379 |
+
char: str | None = src[pos]
|
| 380 |
+
except IndexError:
|
| 381 |
+
char = None
|
| 382 |
+
if char != ".":
|
| 383 |
+
return pos, key
|
| 384 |
+
pos += 1
|
| 385 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 386 |
+
pos, key_part = parse_key_part(src, pos)
|
| 387 |
+
key += (key_part,)
|
| 388 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
def parse_key_part(src: str, pos: Pos) -> tuple[Pos, str]:
|
| 392 |
+
try:
|
| 393 |
+
char: str | None = src[pos]
|
| 394 |
+
except IndexError:
|
| 395 |
+
char = None
|
| 396 |
+
if char in BARE_KEY_CHARS:
|
| 397 |
+
start_pos = pos
|
| 398 |
+
pos = skip_chars(src, pos, BARE_KEY_CHARS)
|
| 399 |
+
return pos, src[start_pos:pos]
|
| 400 |
+
if char == "'":
|
| 401 |
+
return parse_literal_str(src, pos)
|
| 402 |
+
if char == '"':
|
| 403 |
+
return parse_one_line_basic_str(src, pos)
|
| 404 |
+
raise suffixed_err(src, pos, "Invalid initial character for a key part")
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
def parse_one_line_basic_str(src: str, pos: Pos) -> tuple[Pos, str]:
|
| 408 |
+
pos += 1
|
| 409 |
+
return parse_basic_str(src, pos, multiline=False)
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
def parse_array(src: str, pos: Pos, parse_float: ParseFloat) -> tuple[Pos, list]:
|
| 413 |
+
pos += 1
|
| 414 |
+
array: list = []
|
| 415 |
+
|
| 416 |
+
pos = skip_comments_and_array_ws(src, pos)
|
| 417 |
+
if src.startswith("]", pos):
|
| 418 |
+
return pos + 1, array
|
| 419 |
+
while True:
|
| 420 |
+
pos, val = parse_value(src, pos, parse_float)
|
| 421 |
+
array.append(val)
|
| 422 |
+
pos = skip_comments_and_array_ws(src, pos)
|
| 423 |
+
|
| 424 |
+
c = src[pos : pos + 1]
|
| 425 |
+
if c == "]":
|
| 426 |
+
return pos + 1, array
|
| 427 |
+
if c != ",":
|
| 428 |
+
raise suffixed_err(src, pos, "Unclosed array")
|
| 429 |
+
pos += 1
|
| 430 |
+
|
| 431 |
+
pos = skip_comments_and_array_ws(src, pos)
|
| 432 |
+
if src.startswith("]", pos):
|
| 433 |
+
return pos + 1, array
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
def parse_inline_table(src: str, pos: Pos, parse_float: ParseFloat) -> tuple[Pos, dict]:
|
| 437 |
+
pos += 1
|
| 438 |
+
nested_dict = NestedDict()
|
| 439 |
+
flags = Flags()
|
| 440 |
+
|
| 441 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 442 |
+
if src.startswith("}", pos):
|
| 443 |
+
return pos + 1, nested_dict.dict
|
| 444 |
+
while True:
|
| 445 |
+
pos, key, value = parse_key_value_pair(src, pos, parse_float)
|
| 446 |
+
key_parent, key_stem = key[:-1], key[-1]
|
| 447 |
+
if flags.is_(key, Flags.FROZEN):
|
| 448 |
+
raise suffixed_err(src, pos, f"Cannot mutate immutable namespace {key}")
|
| 449 |
+
try:
|
| 450 |
+
nest = nested_dict.get_or_create_nest(key_parent, access_lists=False)
|
| 451 |
+
except KeyError:
|
| 452 |
+
raise suffixed_err(src, pos, "Cannot overwrite a value") from None
|
| 453 |
+
if key_stem in nest:
|
| 454 |
+
raise suffixed_err(src, pos, f"Duplicate inline table key {key_stem!r}")
|
| 455 |
+
nest[key_stem] = value
|
| 456 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 457 |
+
c = src[pos : pos + 1]
|
| 458 |
+
if c == "}":
|
| 459 |
+
return pos + 1, nested_dict.dict
|
| 460 |
+
if c != ",":
|
| 461 |
+
raise suffixed_err(src, pos, "Unclosed inline table")
|
| 462 |
+
if isinstance(value, (dict, list)):
|
| 463 |
+
flags.set(key, Flags.FROZEN, recursive=True)
|
| 464 |
+
pos += 1
|
| 465 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 466 |
+
|
| 467 |
+
|
| 468 |
+
def parse_basic_str_escape(
|
| 469 |
+
src: str, pos: Pos, *, multiline: bool = False
|
| 470 |
+
) -> tuple[Pos, str]:
|
| 471 |
+
escape_id = src[pos : pos + 2]
|
| 472 |
+
pos += 2
|
| 473 |
+
if multiline and escape_id in {"\\ ", "\\\t", "\\\n"}:
|
| 474 |
+
# Skip whitespace until next non-whitespace character or end of
|
| 475 |
+
# the doc. Error if non-whitespace is found before newline.
|
| 476 |
+
if escape_id != "\\\n":
|
| 477 |
+
pos = skip_chars(src, pos, TOML_WS)
|
| 478 |
+
try:
|
| 479 |
+
char = src[pos]
|
| 480 |
+
except IndexError:
|
| 481 |
+
return pos, ""
|
| 482 |
+
if char != "\n":
|
| 483 |
+
raise suffixed_err(src, pos, "Unescaped '\\' in a string")
|
| 484 |
+
pos += 1
|
| 485 |
+
pos = skip_chars(src, pos, TOML_WS_AND_NEWLINE)
|
| 486 |
+
return pos, ""
|
| 487 |
+
if escape_id == "\\u":
|
| 488 |
+
return parse_hex_char(src, pos, 4)
|
| 489 |
+
if escape_id == "\\U":
|
| 490 |
+
return parse_hex_char(src, pos, 8)
|
| 491 |
+
try:
|
| 492 |
+
return pos, BASIC_STR_ESCAPE_REPLACEMENTS[escape_id]
|
| 493 |
+
except KeyError:
|
| 494 |
+
raise suffixed_err(src, pos, "Unescaped '\\' in a string") from None
|
| 495 |
+
|
| 496 |
+
|
| 497 |
+
def parse_basic_str_escape_multiline(src: str, pos: Pos) -> tuple[Pos, str]:
|
| 498 |
+
return parse_basic_str_escape(src, pos, multiline=True)
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
def parse_hex_char(src: str, pos: Pos, hex_len: int) -> tuple[Pos, str]:
|
| 502 |
+
hex_str = src[pos : pos + hex_len]
|
| 503 |
+
if len(hex_str) != hex_len or not HEXDIGIT_CHARS.issuperset(hex_str):
|
| 504 |
+
raise suffixed_err(src, pos, "Invalid hex value")
|
| 505 |
+
pos += hex_len
|
| 506 |
+
hex_int = int(hex_str, 16)
|
| 507 |
+
if not is_unicode_scalar_value(hex_int):
|
| 508 |
+
raise suffixed_err(src, pos, "Escaped character is not a Unicode scalar value")
|
| 509 |
+
return pos, chr(hex_int)
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
def parse_literal_str(src: str, pos: Pos) -> tuple[Pos, str]:
|
| 513 |
+
pos += 1 # Skip starting apostrophe
|
| 514 |
+
start_pos = pos
|
| 515 |
+
pos = skip_until(
|
| 516 |
+
src, pos, "'", error_on=ILLEGAL_LITERAL_STR_CHARS, error_on_eof=True
|
| 517 |
+
)
|
| 518 |
+
return pos + 1, src[start_pos:pos] # Skip ending apostrophe
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
def parse_multiline_str(src: str, pos: Pos, *, literal: bool) -> tuple[Pos, str]:
|
| 522 |
+
pos += 3
|
| 523 |
+
if src.startswith("\n", pos):
|
| 524 |
+
pos += 1
|
| 525 |
+
|
| 526 |
+
if literal:
|
| 527 |
+
delim = "'"
|
| 528 |
+
end_pos = skip_until(
|
| 529 |
+
src,
|
| 530 |
+
pos,
|
| 531 |
+
"'''",
|
| 532 |
+
error_on=ILLEGAL_MULTILINE_LITERAL_STR_CHARS,
|
| 533 |
+
error_on_eof=True,
|
| 534 |
+
)
|
| 535 |
+
result = src[pos:end_pos]
|
| 536 |
+
pos = end_pos + 3
|
| 537 |
+
else:
|
| 538 |
+
delim = '"'
|
| 539 |
+
pos, result = parse_basic_str(src, pos, multiline=True)
|
| 540 |
+
|
| 541 |
+
# Add at maximum two extra apostrophes/quotes if the end sequence
|
| 542 |
+
# is 4 or 5 chars long instead of just 3.
|
| 543 |
+
if not src.startswith(delim, pos):
|
| 544 |
+
return pos, result
|
| 545 |
+
pos += 1
|
| 546 |
+
if not src.startswith(delim, pos):
|
| 547 |
+
return pos, result + delim
|
| 548 |
+
pos += 1
|
| 549 |
+
return pos, result + (delim * 2)
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
def parse_basic_str(src: str, pos: Pos, *, multiline: bool) -> tuple[Pos, str]:
|
| 553 |
+
if multiline:
|
| 554 |
+
error_on = ILLEGAL_MULTILINE_BASIC_STR_CHARS
|
| 555 |
+
parse_escapes = parse_basic_str_escape_multiline
|
| 556 |
+
else:
|
| 557 |
+
error_on = ILLEGAL_BASIC_STR_CHARS
|
| 558 |
+
parse_escapes = parse_basic_str_escape
|
| 559 |
+
result = ""
|
| 560 |
+
start_pos = pos
|
| 561 |
+
while True:
|
| 562 |
+
try:
|
| 563 |
+
char = src[pos]
|
| 564 |
+
except IndexError:
|
| 565 |
+
raise suffixed_err(src, pos, "Unterminated string") from None
|
| 566 |
+
if char == '"':
|
| 567 |
+
if not multiline:
|
| 568 |
+
return pos + 1, result + src[start_pos:pos]
|
| 569 |
+
if src.startswith('"""', pos):
|
| 570 |
+
return pos + 3, result + src[start_pos:pos]
|
| 571 |
+
pos += 1
|
| 572 |
+
continue
|
| 573 |
+
if char == "\\":
|
| 574 |
+
result += src[start_pos:pos]
|
| 575 |
+
pos, parsed_escape = parse_escapes(src, pos)
|
| 576 |
+
result += parsed_escape
|
| 577 |
+
start_pos = pos
|
| 578 |
+
continue
|
| 579 |
+
if char in error_on:
|
| 580 |
+
raise suffixed_err(src, pos, f"Illegal character {char!r}")
|
| 581 |
+
pos += 1
|
| 582 |
+
|
| 583 |
+
|
| 584 |
+
def parse_value( # noqa: C901
|
| 585 |
+
src: str, pos: Pos, parse_float: ParseFloat
|
| 586 |
+
) -> tuple[Pos, Any]:
|
| 587 |
+
try:
|
| 588 |
+
char: str | None = src[pos]
|
| 589 |
+
except IndexError:
|
| 590 |
+
char = None
|
| 591 |
+
|
| 592 |
+
# IMPORTANT: order conditions based on speed of checking and likelihood
|
| 593 |
+
|
| 594 |
+
# Basic strings
|
| 595 |
+
if char == '"':
|
| 596 |
+
if src.startswith('"""', pos):
|
| 597 |
+
return parse_multiline_str(src, pos, literal=False)
|
| 598 |
+
return parse_one_line_basic_str(src, pos)
|
| 599 |
+
|
| 600 |
+
# Literal strings
|
| 601 |
+
if char == "'":
|
| 602 |
+
if src.startswith("'''", pos):
|
| 603 |
+
return parse_multiline_str(src, pos, literal=True)
|
| 604 |
+
return parse_literal_str(src, pos)
|
| 605 |
+
|
| 606 |
+
# Booleans
|
| 607 |
+
if char == "t":
|
| 608 |
+
if src.startswith("true", pos):
|
| 609 |
+
return pos + 4, True
|
| 610 |
+
if char == "f":
|
| 611 |
+
if src.startswith("false", pos):
|
| 612 |
+
return pos + 5, False
|
| 613 |
+
|
| 614 |
+
# Arrays
|
| 615 |
+
if char == "[":
|
| 616 |
+
return parse_array(src, pos, parse_float)
|
| 617 |
+
|
| 618 |
+
# Inline tables
|
| 619 |
+
if char == "{":
|
| 620 |
+
return parse_inline_table(src, pos, parse_float)
|
| 621 |
+
|
| 622 |
+
# Dates and times
|
| 623 |
+
datetime_match = RE_DATETIME.match(src, pos)
|
| 624 |
+
if datetime_match:
|
| 625 |
+
try:
|
| 626 |
+
datetime_obj = match_to_datetime(datetime_match)
|
| 627 |
+
except ValueError as e:
|
| 628 |
+
raise suffixed_err(src, pos, "Invalid date or datetime") from e
|
| 629 |
+
return datetime_match.end(), datetime_obj
|
| 630 |
+
localtime_match = RE_LOCALTIME.match(src, pos)
|
| 631 |
+
if localtime_match:
|
| 632 |
+
return localtime_match.end(), match_to_localtime(localtime_match)
|
| 633 |
+
|
| 634 |
+
# Integers and "normal" floats.
|
| 635 |
+
# The regex will greedily match any type starting with a decimal
|
| 636 |
+
# char, so needs to be located after handling of dates and times.
|
| 637 |
+
number_match = RE_NUMBER.match(src, pos)
|
| 638 |
+
if number_match:
|
| 639 |
+
return number_match.end(), match_to_number(number_match, parse_float)
|
| 640 |
+
|
| 641 |
+
# Special floats
|
| 642 |
+
first_three = src[pos : pos + 3]
|
| 643 |
+
if first_three in {"inf", "nan"}:
|
| 644 |
+
return pos + 3, parse_float(first_three)
|
| 645 |
+
first_four = src[pos : pos + 4]
|
| 646 |
+
if first_four in {"-inf", "+inf", "-nan", "+nan"}:
|
| 647 |
+
return pos + 4, parse_float(first_four)
|
| 648 |
+
|
| 649 |
+
raise suffixed_err(src, pos, "Invalid value")
|
| 650 |
+
|
| 651 |
+
|
| 652 |
+
def suffixed_err(src: str, pos: Pos, msg: str) -> TOMLDecodeError:
|
| 653 |
+
"""Return a `TOMLDecodeError` where error message is suffixed with
|
| 654 |
+
coordinates in source."""
|
| 655 |
+
|
| 656 |
+
def coord_repr(src: str, pos: Pos) -> str:
|
| 657 |
+
if pos >= len(src):
|
| 658 |
+
return "end of document"
|
| 659 |
+
line = src.count("\n", 0, pos) + 1
|
| 660 |
+
if line == 1:
|
| 661 |
+
column = pos + 1
|
| 662 |
+
else:
|
| 663 |
+
column = pos - src.rindex("\n", 0, pos)
|
| 664 |
+
return f"line {line}, column {column}"
|
| 665 |
+
|
| 666 |
+
return TOMLDecodeError(f"{msg} (at {coord_repr(src, pos)})")
|
| 667 |
+
|
| 668 |
+
|
| 669 |
+
def is_unicode_scalar_value(codepoint: int) -> bool:
|
| 670 |
+
return (0 <= codepoint <= 55295) or (57344 <= codepoint <= 1114111)
|
| 671 |
+
|
| 672 |
+
|
| 673 |
+
def make_safe_parse_float(parse_float: ParseFloat) -> ParseFloat:
|
| 674 |
+
"""A decorator to make `parse_float` safe.
|
| 675 |
+
|
| 676 |
+
`parse_float` must not return dicts or lists, because these types
|
| 677 |
+
would be mixed with parsed TOML tables and arrays, thus confusing
|
| 678 |
+
the parser. The returned decorated callable raises `ValueError`
|
| 679 |
+
instead of returning illegal types.
|
| 680 |
+
"""
|
| 681 |
+
# The default `float` callable never returns illegal types. Optimize it.
|
| 682 |
+
if parse_float is float: # type: ignore[comparison-overlap]
|
| 683 |
+
return float
|
| 684 |
+
|
| 685 |
+
def safe_parse_float(float_str: str) -> Any:
|
| 686 |
+
float_value = parse_float(float_str)
|
| 687 |
+
if isinstance(float_value, (dict, list)):
|
| 688 |
+
raise ValueError("parse_float must not return dicts or lists")
|
| 689 |
+
return float_value
|
| 690 |
+
|
| 691 |
+
return safe_parse_float
|
.venv/Lib/site-packages/pip/_vendor/tomli/_re.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: MIT
|
| 2 |
+
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
|
| 3 |
+
# Licensed to PSF under a Contributor Agreement.
|
| 4 |
+
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
|
| 7 |
+
from datetime import date, datetime, time, timedelta, timezone, tzinfo
|
| 8 |
+
from functools import lru_cache
|
| 9 |
+
import re
|
| 10 |
+
from typing import Any
|
| 11 |
+
|
| 12 |
+
from ._types import ParseFloat
|
| 13 |
+
|
| 14 |
+
# E.g.
|
| 15 |
+
# - 00:32:00.999999
|
| 16 |
+
# - 00:32:00
|
| 17 |
+
_TIME_RE_STR = r"([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(?:\.([0-9]{1,6})[0-9]*)?"
|
| 18 |
+
|
| 19 |
+
RE_NUMBER = re.compile(
|
| 20 |
+
r"""
|
| 21 |
+
0
|
| 22 |
+
(?:
|
| 23 |
+
x[0-9A-Fa-f](?:_?[0-9A-Fa-f])* # hex
|
| 24 |
+
|
|
| 25 |
+
b[01](?:_?[01])* # bin
|
| 26 |
+
|
|
| 27 |
+
o[0-7](?:_?[0-7])* # oct
|
| 28 |
+
)
|
| 29 |
+
|
|
| 30 |
+
[+-]?(?:0|[1-9](?:_?[0-9])*) # dec, integer part
|
| 31 |
+
(?P<floatpart>
|
| 32 |
+
(?:\.[0-9](?:_?[0-9])*)? # optional fractional part
|
| 33 |
+
(?:[eE][+-]?[0-9](?:_?[0-9])*)? # optional exponent part
|
| 34 |
+
)
|
| 35 |
+
""",
|
| 36 |
+
flags=re.VERBOSE,
|
| 37 |
+
)
|
| 38 |
+
RE_LOCALTIME = re.compile(_TIME_RE_STR)
|
| 39 |
+
RE_DATETIME = re.compile(
|
| 40 |
+
rf"""
|
| 41 |
+
([0-9]{{4}})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]) # date, e.g. 1988-10-27
|
| 42 |
+
(?:
|
| 43 |
+
[Tt ]
|
| 44 |
+
{_TIME_RE_STR}
|
| 45 |
+
(?:([Zz])|([+-])([01][0-9]|2[0-3]):([0-5][0-9]))? # optional time offset
|
| 46 |
+
)?
|
| 47 |
+
""",
|
| 48 |
+
flags=re.VERBOSE,
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def match_to_datetime(match: re.Match) -> datetime | date:
|
| 53 |
+
"""Convert a `RE_DATETIME` match to `datetime.datetime` or `datetime.date`.
|
| 54 |
+
|
| 55 |
+
Raises ValueError if the match does not correspond to a valid date
|
| 56 |
+
or datetime.
|
| 57 |
+
"""
|
| 58 |
+
(
|
| 59 |
+
year_str,
|
| 60 |
+
month_str,
|
| 61 |
+
day_str,
|
| 62 |
+
hour_str,
|
| 63 |
+
minute_str,
|
| 64 |
+
sec_str,
|
| 65 |
+
micros_str,
|
| 66 |
+
zulu_time,
|
| 67 |
+
offset_sign_str,
|
| 68 |
+
offset_hour_str,
|
| 69 |
+
offset_minute_str,
|
| 70 |
+
) = match.groups()
|
| 71 |
+
year, month, day = int(year_str), int(month_str), int(day_str)
|
| 72 |
+
if hour_str is None:
|
| 73 |
+
return date(year, month, day)
|
| 74 |
+
hour, minute, sec = int(hour_str), int(minute_str), int(sec_str)
|
| 75 |
+
micros = int(micros_str.ljust(6, "0")) if micros_str else 0
|
| 76 |
+
if offset_sign_str:
|
| 77 |
+
tz: tzinfo | None = cached_tz(
|
| 78 |
+
offset_hour_str, offset_minute_str, offset_sign_str
|
| 79 |
+
)
|
| 80 |
+
elif zulu_time:
|
| 81 |
+
tz = timezone.utc
|
| 82 |
+
else: # local date-time
|
| 83 |
+
tz = None
|
| 84 |
+
return datetime(year, month, day, hour, minute, sec, micros, tzinfo=tz)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
@lru_cache(maxsize=None)
|
| 88 |
+
def cached_tz(hour_str: str, minute_str: str, sign_str: str) -> timezone:
|
| 89 |
+
sign = 1 if sign_str == "+" else -1
|
| 90 |
+
return timezone(
|
| 91 |
+
timedelta(
|
| 92 |
+
hours=sign * int(hour_str),
|
| 93 |
+
minutes=sign * int(minute_str),
|
| 94 |
+
)
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def match_to_localtime(match: re.Match) -> time:
|
| 99 |
+
hour_str, minute_str, sec_str, micros_str = match.groups()
|
| 100 |
+
micros = int(micros_str.ljust(6, "0")) if micros_str else 0
|
| 101 |
+
return time(int(hour_str), int(minute_str), int(sec_str), micros)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def match_to_number(match: re.Match, parse_float: ParseFloat) -> Any:
|
| 105 |
+
if match.group("floatpart"):
|
| 106 |
+
return parse_float(match.group())
|
| 107 |
+
return int(match.group(), 0)
|
.venv/Lib/site-packages/pip/_vendor/tomli/_types.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: MIT
|
| 2 |
+
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
|
| 3 |
+
# Licensed to PSF under a Contributor Agreement.
|
| 4 |
+
|
| 5 |
+
from typing import Any, Callable, Tuple
|
| 6 |
+
|
| 7 |
+
# Type annotations
|
| 8 |
+
ParseFloat = Callable[[str], Any]
|
| 9 |
+
Key = Tuple[str, ...]
|
| 10 |
+
Pos = int
|
.venv/Lib/site-packages/pip/_vendor/urllib3/__init__.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more
|
| 3 |
+
"""
|
| 4 |
+
from __future__ import absolute_import
|
| 5 |
+
|
| 6 |
+
# Set default logging handler to avoid "No handler found" warnings.
|
| 7 |
+
import logging
|
| 8 |
+
import warnings
|
| 9 |
+
from logging import NullHandler
|
| 10 |
+
|
| 11 |
+
from . import exceptions
|
| 12 |
+
from ._version import __version__
|
| 13 |
+
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
|
| 14 |
+
from .filepost import encode_multipart_formdata
|
| 15 |
+
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
|
| 16 |
+
from .response import HTTPResponse
|
| 17 |
+
from .util.request import make_headers
|
| 18 |
+
from .util.retry import Retry
|
| 19 |
+
from .util.timeout import Timeout
|
| 20 |
+
from .util.url import get_host
|
| 21 |
+
|
| 22 |
+
# === NOTE TO REPACKAGERS AND VENDORS ===
|
| 23 |
+
# Please delete this block, this logic is only
|
| 24 |
+
# for urllib3 being distributed via PyPI.
|
| 25 |
+
# See: https://github.com/urllib3/urllib3/issues/2680
|
| 26 |
+
try:
|
| 27 |
+
import urllib3_secure_extra # type: ignore # noqa: F401
|
| 28 |
+
except ImportError:
|
| 29 |
+
pass
|
| 30 |
+
else:
|
| 31 |
+
warnings.warn(
|
| 32 |
+
"'urllib3[secure]' extra is deprecated and will be removed "
|
| 33 |
+
"in a future release of urllib3 2.x. Read more in this issue: "
|
| 34 |
+
"https://github.com/urllib3/urllib3/issues/2680",
|
| 35 |
+
category=DeprecationWarning,
|
| 36 |
+
stacklevel=2,
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
__author__ = "Andrey Petrov (andrey.petrov@shazow.net)"
|
| 40 |
+
__license__ = "MIT"
|
| 41 |
+
__version__ = __version__
|
| 42 |
+
|
| 43 |
+
__all__ = (
|
| 44 |
+
"HTTPConnectionPool",
|
| 45 |
+
"HTTPSConnectionPool",
|
| 46 |
+
"PoolManager",
|
| 47 |
+
"ProxyManager",
|
| 48 |
+
"HTTPResponse",
|
| 49 |
+
"Retry",
|
| 50 |
+
"Timeout",
|
| 51 |
+
"add_stderr_logger",
|
| 52 |
+
"connection_from_url",
|
| 53 |
+
"disable_warnings",
|
| 54 |
+
"encode_multipart_formdata",
|
| 55 |
+
"get_host",
|
| 56 |
+
"make_headers",
|
| 57 |
+
"proxy_from_url",
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
logging.getLogger(__name__).addHandler(NullHandler())
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def add_stderr_logger(level=logging.DEBUG):
|
| 64 |
+
"""
|
| 65 |
+
Helper for quickly adding a StreamHandler to the logger. Useful for
|
| 66 |
+
debugging.
|
| 67 |
+
|
| 68 |
+
Returns the handler after adding it.
|
| 69 |
+
"""
|
| 70 |
+
# This method needs to be in this __init__.py to get the __name__ correct
|
| 71 |
+
# even if urllib3 is vendored within another package.
|
| 72 |
+
logger = logging.getLogger(__name__)
|
| 73 |
+
handler = logging.StreamHandler()
|
| 74 |
+
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s"))
|
| 75 |
+
logger.addHandler(handler)
|
| 76 |
+
logger.setLevel(level)
|
| 77 |
+
logger.debug("Added a stderr logging handler to logger: %s", __name__)
|
| 78 |
+
return handler
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# ... Clean up.
|
| 82 |
+
del NullHandler
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
# All warning filters *must* be appended unless you're really certain that they
|
| 86 |
+
# shouldn't be: otherwise, it's very hard for users to use most Python
|
| 87 |
+
# mechanisms to silence them.
|
| 88 |
+
# SecurityWarning's always go off by default.
|
| 89 |
+
warnings.simplefilter("always", exceptions.SecurityWarning, append=True)
|
| 90 |
+
# SubjectAltNameWarning's should go off once per host
|
| 91 |
+
warnings.simplefilter("default", exceptions.SubjectAltNameWarning, append=True)
|
| 92 |
+
# InsecurePlatformWarning's don't vary between requests, so we keep it default.
|
| 93 |
+
warnings.simplefilter("default", exceptions.InsecurePlatformWarning, append=True)
|
| 94 |
+
# SNIMissingWarnings should go off only once.
|
| 95 |
+
warnings.simplefilter("default", exceptions.SNIMissingWarning, append=True)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def disable_warnings(category=exceptions.HTTPWarning):
|
| 99 |
+
"""
|
| 100 |
+
Helper for quickly disabling all urllib3 warnings.
|
| 101 |
+
"""
|
| 102 |
+
warnings.simplefilter("ignore", category)
|
.venv/Lib/site-packages/pip/_vendor/urllib3/_collections.py
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import absolute_import
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from collections.abc import Mapping, MutableMapping
|
| 5 |
+
except ImportError:
|
| 6 |
+
from collections import Mapping, MutableMapping
|
| 7 |
+
try:
|
| 8 |
+
from threading import RLock
|
| 9 |
+
except ImportError: # Platform-specific: No threads available
|
| 10 |
+
|
| 11 |
+
class RLock:
|
| 12 |
+
def __enter__(self):
|
| 13 |
+
pass
|
| 14 |
+
|
| 15 |
+
def __exit__(self, exc_type, exc_value, traceback):
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
from collections import OrderedDict
|
| 20 |
+
|
| 21 |
+
from .exceptions import InvalidHeader
|
| 22 |
+
from .packages import six
|
| 23 |
+
from .packages.six import iterkeys, itervalues
|
| 24 |
+
|
| 25 |
+
__all__ = ["RecentlyUsedContainer", "HTTPHeaderDict"]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
_Null = object()
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class RecentlyUsedContainer(MutableMapping):
|
| 32 |
+
"""
|
| 33 |
+
Provides a thread-safe dict-like container which maintains up to
|
| 34 |
+
``maxsize`` keys while throwing away the least-recently-used keys beyond
|
| 35 |
+
``maxsize``.
|
| 36 |
+
|
| 37 |
+
:param maxsize:
|
| 38 |
+
Maximum number of recent elements to retain.
|
| 39 |
+
|
| 40 |
+
:param dispose_func:
|
| 41 |
+
Every time an item is evicted from the container,
|
| 42 |
+
``dispose_func(value)`` is called. Callback which will get called
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
ContainerCls = OrderedDict
|
| 46 |
+
|
| 47 |
+
def __init__(self, maxsize=10, dispose_func=None):
|
| 48 |
+
self._maxsize = maxsize
|
| 49 |
+
self.dispose_func = dispose_func
|
| 50 |
+
|
| 51 |
+
self._container = self.ContainerCls()
|
| 52 |
+
self.lock = RLock()
|
| 53 |
+
|
| 54 |
+
def __getitem__(self, key):
|
| 55 |
+
# Re-insert the item, moving it to the end of the eviction line.
|
| 56 |
+
with self.lock:
|
| 57 |
+
item = self._container.pop(key)
|
| 58 |
+
self._container[key] = item
|
| 59 |
+
return item
|
| 60 |
+
|
| 61 |
+
def __setitem__(self, key, value):
|
| 62 |
+
evicted_value = _Null
|
| 63 |
+
with self.lock:
|
| 64 |
+
# Possibly evict the existing value of 'key'
|
| 65 |
+
evicted_value = self._container.get(key, _Null)
|
| 66 |
+
self._container[key] = value
|
| 67 |
+
|
| 68 |
+
# If we didn't evict an existing value, we might have to evict the
|
| 69 |
+
# least recently used item from the beginning of the container.
|
| 70 |
+
if len(self._container) > self._maxsize:
|
| 71 |
+
_key, evicted_value = self._container.popitem(last=False)
|
| 72 |
+
|
| 73 |
+
if self.dispose_func and evicted_value is not _Null:
|
| 74 |
+
self.dispose_func(evicted_value)
|
| 75 |
+
|
| 76 |
+
def __delitem__(self, key):
|
| 77 |
+
with self.lock:
|
| 78 |
+
value = self._container.pop(key)
|
| 79 |
+
|
| 80 |
+
if self.dispose_func:
|
| 81 |
+
self.dispose_func(value)
|
| 82 |
+
|
| 83 |
+
def __len__(self):
|
| 84 |
+
with self.lock:
|
| 85 |
+
return len(self._container)
|
| 86 |
+
|
| 87 |
+
def __iter__(self):
|
| 88 |
+
raise NotImplementedError(
|
| 89 |
+
"Iteration over this class is unlikely to be threadsafe."
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
def clear(self):
|
| 93 |
+
with self.lock:
|
| 94 |
+
# Copy pointers to all values, then wipe the mapping
|
| 95 |
+
values = list(itervalues(self._container))
|
| 96 |
+
self._container.clear()
|
| 97 |
+
|
| 98 |
+
if self.dispose_func:
|
| 99 |
+
for value in values:
|
| 100 |
+
self.dispose_func(value)
|
| 101 |
+
|
| 102 |
+
def keys(self):
|
| 103 |
+
with self.lock:
|
| 104 |
+
return list(iterkeys(self._container))
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class HTTPHeaderDict(MutableMapping):
|
| 108 |
+
"""
|
| 109 |
+
:param headers:
|
| 110 |
+
An iterable of field-value pairs. Must not contain multiple field names
|
| 111 |
+
when compared case-insensitively.
|
| 112 |
+
|
| 113 |
+
:param kwargs:
|
| 114 |
+
Additional field-value pairs to pass in to ``dict.update``.
|
| 115 |
+
|
| 116 |
+
A ``dict`` like container for storing HTTP Headers.
|
| 117 |
+
|
| 118 |
+
Field names are stored and compared case-insensitively in compliance with
|
| 119 |
+
RFC 7230. Iteration provides the first case-sensitive key seen for each
|
| 120 |
+
case-insensitive pair.
|
| 121 |
+
|
| 122 |
+
Using ``__setitem__`` syntax overwrites fields that compare equal
|
| 123 |
+
case-insensitively in order to maintain ``dict``'s api. For fields that
|
| 124 |
+
compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add``
|
| 125 |
+
in a loop.
|
| 126 |
+
|
| 127 |
+
If multiple fields that are equal case-insensitively are passed to the
|
| 128 |
+
constructor or ``.update``, the behavior is undefined and some will be
|
| 129 |
+
lost.
|
| 130 |
+
|
| 131 |
+
>>> headers = HTTPHeaderDict()
|
| 132 |
+
>>> headers.add('Set-Cookie', 'foo=bar')
|
| 133 |
+
>>> headers.add('set-cookie', 'baz=quxx')
|
| 134 |
+
>>> headers['content-length'] = '7'
|
| 135 |
+
>>> headers['SET-cookie']
|
| 136 |
+
'foo=bar, baz=quxx'
|
| 137 |
+
>>> headers['Content-Length']
|
| 138 |
+
'7'
|
| 139 |
+
"""
|
| 140 |
+
|
| 141 |
+
def __init__(self, headers=None, **kwargs):
|
| 142 |
+
super(HTTPHeaderDict, self).__init__()
|
| 143 |
+
self._container = OrderedDict()
|
| 144 |
+
if headers is not None:
|
| 145 |
+
if isinstance(headers, HTTPHeaderDict):
|
| 146 |
+
self._copy_from(headers)
|
| 147 |
+
else:
|
| 148 |
+
self.extend(headers)
|
| 149 |
+
if kwargs:
|
| 150 |
+
self.extend(kwargs)
|
| 151 |
+
|
| 152 |
+
def __setitem__(self, key, val):
|
| 153 |
+
self._container[key.lower()] = [key, val]
|
| 154 |
+
return self._container[key.lower()]
|
| 155 |
+
|
| 156 |
+
def __getitem__(self, key):
|
| 157 |
+
val = self._container[key.lower()]
|
| 158 |
+
return ", ".join(val[1:])
|
| 159 |
+
|
| 160 |
+
def __delitem__(self, key):
|
| 161 |
+
del self._container[key.lower()]
|
| 162 |
+
|
| 163 |
+
def __contains__(self, key):
|
| 164 |
+
return key.lower() in self._container
|
| 165 |
+
|
| 166 |
+
def __eq__(self, other):
|
| 167 |
+
if not isinstance(other, Mapping) and not hasattr(other, "keys"):
|
| 168 |
+
return False
|
| 169 |
+
if not isinstance(other, type(self)):
|
| 170 |
+
other = type(self)(other)
|
| 171 |
+
return dict((k.lower(), v) for k, v in self.itermerged()) == dict(
|
| 172 |
+
(k.lower(), v) for k, v in other.itermerged()
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
def __ne__(self, other):
|
| 176 |
+
return not self.__eq__(other)
|
| 177 |
+
|
| 178 |
+
if six.PY2: # Python 2
|
| 179 |
+
iterkeys = MutableMapping.iterkeys
|
| 180 |
+
itervalues = MutableMapping.itervalues
|
| 181 |
+
|
| 182 |
+
__marker = object()
|
| 183 |
+
|
| 184 |
+
def __len__(self):
|
| 185 |
+
return len(self._container)
|
| 186 |
+
|
| 187 |
+
def __iter__(self):
|
| 188 |
+
# Only provide the originally cased names
|
| 189 |
+
for vals in self._container.values():
|
| 190 |
+
yield vals[0]
|
| 191 |
+
|
| 192 |
+
def pop(self, key, default=__marker):
|
| 193 |
+
"""D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| 194 |
+
If key is not found, d is returned if given, otherwise KeyError is raised.
|
| 195 |
+
"""
|
| 196 |
+
# Using the MutableMapping function directly fails due to the private marker.
|
| 197 |
+
# Using ordinary dict.pop would expose the internal structures.
|
| 198 |
+
# So let's reinvent the wheel.
|
| 199 |
+
try:
|
| 200 |
+
value = self[key]
|
| 201 |
+
except KeyError:
|
| 202 |
+
if default is self.__marker:
|
| 203 |
+
raise
|
| 204 |
+
return default
|
| 205 |
+
else:
|
| 206 |
+
del self[key]
|
| 207 |
+
return value
|
| 208 |
+
|
| 209 |
+
def discard(self, key):
|
| 210 |
+
try:
|
| 211 |
+
del self[key]
|
| 212 |
+
except KeyError:
|
| 213 |
+
pass
|
| 214 |
+
|
| 215 |
+
def add(self, key, val):
|
| 216 |
+
"""Adds a (name, value) pair, doesn't overwrite the value if it already
|
| 217 |
+
exists.
|
| 218 |
+
|
| 219 |
+
>>> headers = HTTPHeaderDict(foo='bar')
|
| 220 |
+
>>> headers.add('Foo', 'baz')
|
| 221 |
+
>>> headers['foo']
|
| 222 |
+
'bar, baz'
|
| 223 |
+
"""
|
| 224 |
+
key_lower = key.lower()
|
| 225 |
+
new_vals = [key, val]
|
| 226 |
+
# Keep the common case aka no item present as fast as possible
|
| 227 |
+
vals = self._container.setdefault(key_lower, new_vals)
|
| 228 |
+
if new_vals is not vals:
|
| 229 |
+
vals.append(val)
|
| 230 |
+
|
| 231 |
+
def extend(self, *args, **kwargs):
|
| 232 |
+
"""Generic import function for any type of header-like object.
|
| 233 |
+
Adapted version of MutableMapping.update in order to insert items
|
| 234 |
+
with self.add instead of self.__setitem__
|
| 235 |
+
"""
|
| 236 |
+
if len(args) > 1:
|
| 237 |
+
raise TypeError(
|
| 238 |
+
"extend() takes at most 1 positional "
|
| 239 |
+
"arguments ({0} given)".format(len(args))
|
| 240 |
+
)
|
| 241 |
+
other = args[0] if len(args) >= 1 else ()
|
| 242 |
+
|
| 243 |
+
if isinstance(other, HTTPHeaderDict):
|
| 244 |
+
for key, val in other.iteritems():
|
| 245 |
+
self.add(key, val)
|
| 246 |
+
elif isinstance(other, Mapping):
|
| 247 |
+
for key in other:
|
| 248 |
+
self.add(key, other[key])
|
| 249 |
+
elif hasattr(other, "keys"):
|
| 250 |
+
for key in other.keys():
|
| 251 |
+
self.add(key, other[key])
|
| 252 |
+
else:
|
| 253 |
+
for key, value in other:
|
| 254 |
+
self.add(key, value)
|
| 255 |
+
|
| 256 |
+
for key, value in kwargs.items():
|
| 257 |
+
self.add(key, value)
|
| 258 |
+
|
| 259 |
+
def getlist(self, key, default=__marker):
|
| 260 |
+
"""Returns a list of all the values for the named field. Returns an
|
| 261 |
+
empty list if the key doesn't exist."""
|
| 262 |
+
try:
|
| 263 |
+
vals = self._container[key.lower()]
|
| 264 |
+
except KeyError:
|
| 265 |
+
if default is self.__marker:
|
| 266 |
+
return []
|
| 267 |
+
return default
|
| 268 |
+
else:
|
| 269 |
+
return vals[1:]
|
| 270 |
+
|
| 271 |
+
# Backwards compatibility for httplib
|
| 272 |
+
getheaders = getlist
|
| 273 |
+
getallmatchingheaders = getlist
|
| 274 |
+
iget = getlist
|
| 275 |
+
|
| 276 |
+
# Backwards compatibility for http.cookiejar
|
| 277 |
+
get_all = getlist
|
| 278 |
+
|
| 279 |
+
def __repr__(self):
|
| 280 |
+
return "%s(%s)" % (type(self).__name__, dict(self.itermerged()))
|
| 281 |
+
|
| 282 |
+
def _copy_from(self, other):
|
| 283 |
+
for key in other:
|
| 284 |
+
val = other.getlist(key)
|
| 285 |
+
if isinstance(val, list):
|
| 286 |
+
# Don't need to convert tuples
|
| 287 |
+
val = list(val)
|
| 288 |
+
self._container[key.lower()] = [key] + val
|
| 289 |
+
|
| 290 |
+
def copy(self):
|
| 291 |
+
clone = type(self)()
|
| 292 |
+
clone._copy_from(self)
|
| 293 |
+
return clone
|
| 294 |
+
|
| 295 |
+
def iteritems(self):
|
| 296 |
+
"""Iterate over all header lines, including duplicate ones."""
|
| 297 |
+
for key in self:
|
| 298 |
+
vals = self._container[key.lower()]
|
| 299 |
+
for val in vals[1:]:
|
| 300 |
+
yield vals[0], val
|
| 301 |
+
|
| 302 |
+
def itermerged(self):
|
| 303 |
+
"""Iterate over all headers, merging duplicate ones together."""
|
| 304 |
+
for key in self:
|
| 305 |
+
val = self._container[key.lower()]
|
| 306 |
+
yield val[0], ", ".join(val[1:])
|
| 307 |
+
|
| 308 |
+
def items(self):
|
| 309 |
+
return list(self.iteritems())
|
| 310 |
+
|
| 311 |
+
@classmethod
|
| 312 |
+
def from_httplib(cls, message): # Python 2
|
| 313 |
+
"""Read headers from a Python 2 httplib message object."""
|
| 314 |
+
# python2.7 does not expose a proper API for exporting multiheaders
|
| 315 |
+
# efficiently. This function re-reads raw lines from the message
|
| 316 |
+
# object and extracts the multiheaders properly.
|
| 317 |
+
obs_fold_continued_leaders = (" ", "\t")
|
| 318 |
+
headers = []
|
| 319 |
+
|
| 320 |
+
for line in message.headers:
|
| 321 |
+
if line.startswith(obs_fold_continued_leaders):
|
| 322 |
+
if not headers:
|
| 323 |
+
# We received a header line that starts with OWS as described
|
| 324 |
+
# in RFC-7230 S3.2.4. This indicates a multiline header, but
|
| 325 |
+
# there exists no previous header to which we can attach it.
|
| 326 |
+
raise InvalidHeader(
|
| 327 |
+
"Header continuation with no previous header: %s" % line
|
| 328 |
+
)
|
| 329 |
+
else:
|
| 330 |
+
key, value = headers[-1]
|
| 331 |
+
headers[-1] = (key, value + " " + line.strip())
|
| 332 |
+
continue
|
| 333 |
+
|
| 334 |
+
key, value = line.split(":", 1)
|
| 335 |
+
headers.append((key, value.strip()))
|
| 336 |
+
|
| 337 |
+
return cls(headers)
|
.venv/Lib/site-packages/pip/_vendor/urllib3/_version.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is protected via CODEOWNERS
|
| 2 |
+
__version__ = "1.26.16"
|
.venv/Lib/site-packages/pip/_vendor/urllib3/connection.py
ADDED
|
@@ -0,0 +1,572 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import absolute_import
|
| 2 |
+
|
| 3 |
+
import datetime
|
| 4 |
+
import logging
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
import socket
|
| 8 |
+
import warnings
|
| 9 |
+
from socket import error as SocketError
|
| 10 |
+
from socket import timeout as SocketTimeout
|
| 11 |
+
|
| 12 |
+
from .packages import six
|
| 13 |
+
from .packages.six.moves.http_client import HTTPConnection as _HTTPConnection
|
| 14 |
+
from .packages.six.moves.http_client import HTTPException # noqa: F401
|
| 15 |
+
from .util.proxy import create_proxy_ssl_context
|
| 16 |
+
|
| 17 |
+
try: # Compiled with SSL?
|
| 18 |
+
import ssl
|
| 19 |
+
|
| 20 |
+
BaseSSLError = ssl.SSLError
|
| 21 |
+
except (ImportError, AttributeError): # Platform-specific: No SSL.
|
| 22 |
+
ssl = None
|
| 23 |
+
|
| 24 |
+
class BaseSSLError(BaseException):
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
try:
|
| 29 |
+
# Python 3: not a no-op, we're adding this to the namespace so it can be imported.
|
| 30 |
+
ConnectionError = ConnectionError
|
| 31 |
+
except NameError:
|
| 32 |
+
# Python 2
|
| 33 |
+
class ConnectionError(Exception):
|
| 34 |
+
pass
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
try: # Python 3:
|
| 38 |
+
# Not a no-op, we're adding this to the namespace so it can be imported.
|
| 39 |
+
BrokenPipeError = BrokenPipeError
|
| 40 |
+
except NameError: # Python 2:
|
| 41 |
+
|
| 42 |
+
class BrokenPipeError(Exception):
|
| 43 |
+
pass
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
from ._collections import HTTPHeaderDict # noqa (historical, removed in v2)
|
| 47 |
+
from ._version import __version__
|
| 48 |
+
from .exceptions import (
|
| 49 |
+
ConnectTimeoutError,
|
| 50 |
+
NewConnectionError,
|
| 51 |
+
SubjectAltNameWarning,
|
| 52 |
+
SystemTimeWarning,
|
| 53 |
+
)
|
| 54 |
+
from .util import SKIP_HEADER, SKIPPABLE_HEADERS, connection
|
| 55 |
+
from .util.ssl_ import (
|
| 56 |
+
assert_fingerprint,
|
| 57 |
+
create_urllib3_context,
|
| 58 |
+
is_ipaddress,
|
| 59 |
+
resolve_cert_reqs,
|
| 60 |
+
resolve_ssl_version,
|
| 61 |
+
ssl_wrap_socket,
|
| 62 |
+
)
|
| 63 |
+
from .util.ssl_match_hostname import CertificateError, match_hostname
|
| 64 |
+
|
| 65 |
+
log = logging.getLogger(__name__)
|
| 66 |
+
|
| 67 |
+
port_by_scheme = {"http": 80, "https": 443}
|
| 68 |
+
|
| 69 |
+
# When it comes time to update this value as a part of regular maintenance
|
| 70 |
+
# (ie test_recent_date is failing) update it to ~6 months before the current date.
|
| 71 |
+
RECENT_DATE = datetime.date(2022, 1, 1)
|
| 72 |
+
|
| 73 |
+
_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class HTTPConnection(_HTTPConnection, object):
|
| 77 |
+
"""
|
| 78 |
+
Based on :class:`http.client.HTTPConnection` but provides an extra constructor
|
| 79 |
+
backwards-compatibility layer between older and newer Pythons.
|
| 80 |
+
|
| 81 |
+
Additional keyword parameters are used to configure attributes of the connection.
|
| 82 |
+
Accepted parameters include:
|
| 83 |
+
|
| 84 |
+
- ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
|
| 85 |
+
- ``source_address``: Set the source address for the current connection.
|
| 86 |
+
- ``socket_options``: Set specific options on the underlying socket. If not specified, then
|
| 87 |
+
defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
|
| 88 |
+
Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.
|
| 89 |
+
|
| 90 |
+
For example, if you wish to enable TCP Keep Alive in addition to the defaults,
|
| 91 |
+
you might pass:
|
| 92 |
+
|
| 93 |
+
.. code-block:: python
|
| 94 |
+
|
| 95 |
+
HTTPConnection.default_socket_options + [
|
| 96 |
+
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
|
| 97 |
+
]
|
| 98 |
+
|
| 99 |
+
Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
|
| 100 |
+
"""
|
| 101 |
+
|
| 102 |
+
default_port = port_by_scheme["http"]
|
| 103 |
+
|
| 104 |
+
#: Disable Nagle's algorithm by default.
|
| 105 |
+
#: ``[(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]``
|
| 106 |
+
default_socket_options = [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]
|
| 107 |
+
|
| 108 |
+
#: Whether this connection verifies the host's certificate.
|
| 109 |
+
is_verified = False
|
| 110 |
+
|
| 111 |
+
#: Whether this proxy connection (if used) verifies the proxy host's
|
| 112 |
+
#: certificate.
|
| 113 |
+
proxy_is_verified = None
|
| 114 |
+
|
| 115 |
+
def __init__(self, *args, **kw):
|
| 116 |
+
if not six.PY2:
|
| 117 |
+
kw.pop("strict", None)
|
| 118 |
+
|
| 119 |
+
# Pre-set source_address.
|
| 120 |
+
self.source_address = kw.get("source_address")
|
| 121 |
+
|
| 122 |
+
#: The socket options provided by the user. If no options are
|
| 123 |
+
#: provided, we use the default options.
|
| 124 |
+
self.socket_options = kw.pop("socket_options", self.default_socket_options)
|
| 125 |
+
|
| 126 |
+
# Proxy options provided by the user.
|
| 127 |
+
self.proxy = kw.pop("proxy", None)
|
| 128 |
+
self.proxy_config = kw.pop("proxy_config", None)
|
| 129 |
+
|
| 130 |
+
_HTTPConnection.__init__(self, *args, **kw)
|
| 131 |
+
|
| 132 |
+
@property
|
| 133 |
+
def host(self):
|
| 134 |
+
"""
|
| 135 |
+
Getter method to remove any trailing dots that indicate the hostname is an FQDN.
|
| 136 |
+
|
| 137 |
+
In general, SSL certificates don't include the trailing dot indicating a
|
| 138 |
+
fully-qualified domain name, and thus, they don't validate properly when
|
| 139 |
+
checked against a domain name that includes the dot. In addition, some
|
| 140 |
+
servers may not expect to receive the trailing dot when provided.
|
| 141 |
+
|
| 142 |
+
However, the hostname with trailing dot is critical to DNS resolution; doing a
|
| 143 |
+
lookup with the trailing dot will properly only resolve the appropriate FQDN,
|
| 144 |
+
whereas a lookup without a trailing dot will search the system's search domain
|
| 145 |
+
list. Thus, it's important to keep the original host around for use only in
|
| 146 |
+
those cases where it's appropriate (i.e., when doing DNS lookup to establish the
|
| 147 |
+
actual TCP connection across which we're going to send HTTP requests).
|
| 148 |
+
"""
|
| 149 |
+
return self._dns_host.rstrip(".")
|
| 150 |
+
|
| 151 |
+
@host.setter
|
| 152 |
+
def host(self, value):
|
| 153 |
+
"""
|
| 154 |
+
Setter for the `host` property.
|
| 155 |
+
|
| 156 |
+
We assume that only urllib3 uses the _dns_host attribute; httplib itself
|
| 157 |
+
only uses `host`, and it seems reasonable that other libraries follow suit.
|
| 158 |
+
"""
|
| 159 |
+
self._dns_host = value
|
| 160 |
+
|
| 161 |
+
def _new_conn(self):
|
| 162 |
+
"""Establish a socket connection and set nodelay settings on it.
|
| 163 |
+
|
| 164 |
+
:return: New socket connection.
|
| 165 |
+
"""
|
| 166 |
+
extra_kw = {}
|
| 167 |
+
if self.source_address:
|
| 168 |
+
extra_kw["source_address"] = self.source_address
|
| 169 |
+
|
| 170 |
+
if self.socket_options:
|
| 171 |
+
extra_kw["socket_options"] = self.socket_options
|
| 172 |
+
|
| 173 |
+
try:
|
| 174 |
+
conn = connection.create_connection(
|
| 175 |
+
(self._dns_host, self.port), self.timeout, **extra_kw
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
except SocketTimeout:
|
| 179 |
+
raise ConnectTimeoutError(
|
| 180 |
+
self,
|
| 181 |
+
"Connection to %s timed out. (connect timeout=%s)"
|
| 182 |
+
% (self.host, self.timeout),
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
except SocketError as e:
|
| 186 |
+
raise NewConnectionError(
|
| 187 |
+
self, "Failed to establish a new connection: %s" % e
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
+
return conn
|
| 191 |
+
|
| 192 |
+
def _is_using_tunnel(self):
|
| 193 |
+
# Google App Engine's httplib does not define _tunnel_host
|
| 194 |
+
return getattr(self, "_tunnel_host", None)
|
| 195 |
+
|
| 196 |
+
def _prepare_conn(self, conn):
|
| 197 |
+
self.sock = conn
|
| 198 |
+
if self._is_using_tunnel():
|
| 199 |
+
# TODO: Fix tunnel so it doesn't depend on self.sock state.
|
| 200 |
+
self._tunnel()
|
| 201 |
+
# Mark this connection as not reusable
|
| 202 |
+
self.auto_open = 0
|
| 203 |
+
|
| 204 |
+
def connect(self):
|
| 205 |
+
conn = self._new_conn()
|
| 206 |
+
self._prepare_conn(conn)
|
| 207 |
+
|
| 208 |
+
def putrequest(self, method, url, *args, **kwargs):
|
| 209 |
+
""" """
|
| 210 |
+
# Empty docstring because the indentation of CPython's implementation
|
| 211 |
+
# is broken but we don't want this method in our documentation.
|
| 212 |
+
match = _CONTAINS_CONTROL_CHAR_RE.search(method)
|
| 213 |
+
if match:
|
| 214 |
+
raise ValueError(
|
| 215 |
+
"Method cannot contain non-token characters %r (found at least %r)"
|
| 216 |
+
% (method, match.group())
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
|
| 220 |
+
|
| 221 |
+
def putheader(self, header, *values):
|
| 222 |
+
""" """
|
| 223 |
+
if not any(isinstance(v, str) and v == SKIP_HEADER for v in values):
|
| 224 |
+
_HTTPConnection.putheader(self, header, *values)
|
| 225 |
+
elif six.ensure_str(header.lower()) not in SKIPPABLE_HEADERS:
|
| 226 |
+
raise ValueError(
|
| 227 |
+
"urllib3.util.SKIP_HEADER only supports '%s'"
|
| 228 |
+
% ("', '".join(map(str.title, sorted(SKIPPABLE_HEADERS))),)
|
| 229 |
+
)
|
| 230 |
+
|
| 231 |
+
def request(self, method, url, body=None, headers=None):
|
| 232 |
+
# Update the inner socket's timeout value to send the request.
|
| 233 |
+
# This only triggers if the connection is re-used.
|
| 234 |
+
if getattr(self, "sock", None) is not None:
|
| 235 |
+
self.sock.settimeout(self.timeout)
|
| 236 |
+
|
| 237 |
+
if headers is None:
|
| 238 |
+
headers = {}
|
| 239 |
+
else:
|
| 240 |
+
# Avoid modifying the headers passed into .request()
|
| 241 |
+
headers = headers.copy()
|
| 242 |
+
if "user-agent" not in (six.ensure_str(k.lower()) for k in headers):
|
| 243 |
+
headers["User-Agent"] = _get_default_user_agent()
|
| 244 |
+
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
|
| 245 |
+
|
| 246 |
+
def request_chunked(self, method, url, body=None, headers=None):
|
| 247 |
+
"""
|
| 248 |
+
Alternative to the common request method, which sends the
|
| 249 |
+
body with chunked encoding and not as one block
|
| 250 |
+
"""
|
| 251 |
+
headers = headers or {}
|
| 252 |
+
header_keys = set([six.ensure_str(k.lower()) for k in headers])
|
| 253 |
+
skip_accept_encoding = "accept-encoding" in header_keys
|
| 254 |
+
skip_host = "host" in header_keys
|
| 255 |
+
self.putrequest(
|
| 256 |
+
method, url, skip_accept_encoding=skip_accept_encoding, skip_host=skip_host
|
| 257 |
+
)
|
| 258 |
+
if "user-agent" not in header_keys:
|
| 259 |
+
self.putheader("User-Agent", _get_default_user_agent())
|
| 260 |
+
for header, value in headers.items():
|
| 261 |
+
self.putheader(header, value)
|
| 262 |
+
if "transfer-encoding" not in header_keys:
|
| 263 |
+
self.putheader("Transfer-Encoding", "chunked")
|
| 264 |
+
self.endheaders()
|
| 265 |
+
|
| 266 |
+
if body is not None:
|
| 267 |
+
stringish_types = six.string_types + (bytes,)
|
| 268 |
+
if isinstance(body, stringish_types):
|
| 269 |
+
body = (body,)
|
| 270 |
+
for chunk in body:
|
| 271 |
+
if not chunk:
|
| 272 |
+
continue
|
| 273 |
+
if not isinstance(chunk, bytes):
|
| 274 |
+
chunk = chunk.encode("utf8")
|
| 275 |
+
len_str = hex(len(chunk))[2:]
|
| 276 |
+
to_send = bytearray(len_str.encode())
|
| 277 |
+
to_send += b"\r\n"
|
| 278 |
+
to_send += chunk
|
| 279 |
+
to_send += b"\r\n"
|
| 280 |
+
self.send(to_send)
|
| 281 |
+
|
| 282 |
+
# After the if clause, to always have a closed body
|
| 283 |
+
self.send(b"0\r\n\r\n")
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
class HTTPSConnection(HTTPConnection):
|
| 287 |
+
"""
|
| 288 |
+
Many of the parameters to this constructor are passed to the underlying SSL
|
| 289 |
+
socket by means of :py:func:`urllib3.util.ssl_wrap_socket`.
|
| 290 |
+
"""
|
| 291 |
+
|
| 292 |
+
default_port = port_by_scheme["https"]
|
| 293 |
+
|
| 294 |
+
cert_reqs = None
|
| 295 |
+
ca_certs = None
|
| 296 |
+
ca_cert_dir = None
|
| 297 |
+
ca_cert_data = None
|
| 298 |
+
ssl_version = None
|
| 299 |
+
assert_fingerprint = None
|
| 300 |
+
tls_in_tls_required = False
|
| 301 |
+
|
| 302 |
+
def __init__(
|
| 303 |
+
self,
|
| 304 |
+
host,
|
| 305 |
+
port=None,
|
| 306 |
+
key_file=None,
|
| 307 |
+
cert_file=None,
|
| 308 |
+
key_password=None,
|
| 309 |
+
strict=None,
|
| 310 |
+
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
|
| 311 |
+
ssl_context=None,
|
| 312 |
+
server_hostname=None,
|
| 313 |
+
**kw
|
| 314 |
+
):
|
| 315 |
+
|
| 316 |
+
HTTPConnection.__init__(self, host, port, strict=strict, timeout=timeout, **kw)
|
| 317 |
+
|
| 318 |
+
self.key_file = key_file
|
| 319 |
+
self.cert_file = cert_file
|
| 320 |
+
self.key_password = key_password
|
| 321 |
+
self.ssl_context = ssl_context
|
| 322 |
+
self.server_hostname = server_hostname
|
| 323 |
+
|
| 324 |
+
# Required property for Google AppEngine 1.9.0 which otherwise causes
|
| 325 |
+
# HTTPS requests to go out as HTTP. (See Issue #356)
|
| 326 |
+
self._protocol = "https"
|
| 327 |
+
|
| 328 |
+
def set_cert(
|
| 329 |
+
self,
|
| 330 |
+
key_file=None,
|
| 331 |
+
cert_file=None,
|
| 332 |
+
cert_reqs=None,
|
| 333 |
+
key_password=None,
|
| 334 |
+
ca_certs=None,
|
| 335 |
+
assert_hostname=None,
|
| 336 |
+
assert_fingerprint=None,
|
| 337 |
+
ca_cert_dir=None,
|
| 338 |
+
ca_cert_data=None,
|
| 339 |
+
):
|
| 340 |
+
"""
|
| 341 |
+
This method should only be called once, before the connection is used.
|
| 342 |
+
"""
|
| 343 |
+
# If cert_reqs is not provided we'll assume CERT_REQUIRED unless we also
|
| 344 |
+
# have an SSLContext object in which case we'll use its verify_mode.
|
| 345 |
+
if cert_reqs is None:
|
| 346 |
+
if self.ssl_context is not None:
|
| 347 |
+
cert_reqs = self.ssl_context.verify_mode
|
| 348 |
+
else:
|
| 349 |
+
cert_reqs = resolve_cert_reqs(None)
|
| 350 |
+
|
| 351 |
+
self.key_file = key_file
|
| 352 |
+
self.cert_file = cert_file
|
| 353 |
+
self.cert_reqs = cert_reqs
|
| 354 |
+
self.key_password = key_password
|
| 355 |
+
self.assert_hostname = assert_hostname
|
| 356 |
+
self.assert_fingerprint = assert_fingerprint
|
| 357 |
+
self.ca_certs = ca_certs and os.path.expanduser(ca_certs)
|
| 358 |
+
self.ca_cert_dir = ca_cert_dir and os.path.expanduser(ca_cert_dir)
|
| 359 |
+
self.ca_cert_data = ca_cert_data
|
| 360 |
+
|
| 361 |
+
def connect(self):
|
| 362 |
+
# Add certificate verification
|
| 363 |
+
self.sock = conn = self._new_conn()
|
| 364 |
+
hostname = self.host
|
| 365 |
+
tls_in_tls = False
|
| 366 |
+
|
| 367 |
+
if self._is_using_tunnel():
|
| 368 |
+
if self.tls_in_tls_required:
|
| 369 |
+
self.sock = conn = self._connect_tls_proxy(hostname, conn)
|
| 370 |
+
tls_in_tls = True
|
| 371 |
+
|
| 372 |
+
# Calls self._set_hostport(), so self.host is
|
| 373 |
+
# self._tunnel_host below.
|
| 374 |
+
self._tunnel()
|
| 375 |
+
# Mark this connection as not reusable
|
| 376 |
+
self.auto_open = 0
|
| 377 |
+
|
| 378 |
+
# Override the host with the one we're requesting data from.
|
| 379 |
+
hostname = self._tunnel_host
|
| 380 |
+
|
| 381 |
+
server_hostname = hostname
|
| 382 |
+
if self.server_hostname is not None:
|
| 383 |
+
server_hostname = self.server_hostname
|
| 384 |
+
|
| 385 |
+
is_time_off = datetime.date.today() < RECENT_DATE
|
| 386 |
+
if is_time_off:
|
| 387 |
+
warnings.warn(
|
| 388 |
+
(
|
| 389 |
+
"System time is way off (before {0}). This will probably "
|
| 390 |
+
"lead to SSL verification errors"
|
| 391 |
+
).format(RECENT_DATE),
|
| 392 |
+
SystemTimeWarning,
|
| 393 |
+
)
|
| 394 |
+
|
| 395 |
+
# Wrap socket using verification with the root certs in
|
| 396 |
+
# trusted_root_certs
|
| 397 |
+
default_ssl_context = False
|
| 398 |
+
if self.ssl_context is None:
|
| 399 |
+
default_ssl_context = True
|
| 400 |
+
self.ssl_context = create_urllib3_context(
|
| 401 |
+
ssl_version=resolve_ssl_version(self.ssl_version),
|
| 402 |
+
cert_reqs=resolve_cert_reqs(self.cert_reqs),
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
context = self.ssl_context
|
| 406 |
+
context.verify_mode = resolve_cert_reqs(self.cert_reqs)
|
| 407 |
+
|
| 408 |
+
# Try to load OS default certs if none are given.
|
| 409 |
+
# Works well on Windows (requires Python3.4+)
|
| 410 |
+
if (
|
| 411 |
+
not self.ca_certs
|
| 412 |
+
and not self.ca_cert_dir
|
| 413 |
+
and not self.ca_cert_data
|
| 414 |
+
and default_ssl_context
|
| 415 |
+
and hasattr(context, "load_default_certs")
|
| 416 |
+
):
|
| 417 |
+
context.load_default_certs()
|
| 418 |
+
|
| 419 |
+
self.sock = ssl_wrap_socket(
|
| 420 |
+
sock=conn,
|
| 421 |
+
keyfile=self.key_file,
|
| 422 |
+
certfile=self.cert_file,
|
| 423 |
+
key_password=self.key_password,
|
| 424 |
+
ca_certs=self.ca_certs,
|
| 425 |
+
ca_cert_dir=self.ca_cert_dir,
|
| 426 |
+
ca_cert_data=self.ca_cert_data,
|
| 427 |
+
server_hostname=server_hostname,
|
| 428 |
+
ssl_context=context,
|
| 429 |
+
tls_in_tls=tls_in_tls,
|
| 430 |
+
)
|
| 431 |
+
|
| 432 |
+
# If we're using all defaults and the connection
|
| 433 |
+
# is TLSv1 or TLSv1.1 we throw a DeprecationWarning
|
| 434 |
+
# for the host.
|
| 435 |
+
if (
|
| 436 |
+
default_ssl_context
|
| 437 |
+
and self.ssl_version is None
|
| 438 |
+
and hasattr(self.sock, "version")
|
| 439 |
+
and self.sock.version() in {"TLSv1", "TLSv1.1"}
|
| 440 |
+
):
|
| 441 |
+
warnings.warn(
|
| 442 |
+
"Negotiating TLSv1/TLSv1.1 by default is deprecated "
|
| 443 |
+
"and will be disabled in urllib3 v2.0.0. Connecting to "
|
| 444 |
+
"'%s' with '%s' can be enabled by explicitly opting-in "
|
| 445 |
+
"with 'ssl_version'" % (self.host, self.sock.version()),
|
| 446 |
+
DeprecationWarning,
|
| 447 |
+
)
|
| 448 |
+
|
| 449 |
+
if self.assert_fingerprint:
|
| 450 |
+
assert_fingerprint(
|
| 451 |
+
self.sock.getpeercert(binary_form=True), self.assert_fingerprint
|
| 452 |
+
)
|
| 453 |
+
elif (
|
| 454 |
+
context.verify_mode != ssl.CERT_NONE
|
| 455 |
+
and not getattr(context, "check_hostname", False)
|
| 456 |
+
and self.assert_hostname is not False
|
| 457 |
+
):
|
| 458 |
+
# While urllib3 attempts to always turn off hostname matching from
|
| 459 |
+
# the TLS library, this cannot always be done. So we check whether
|
| 460 |
+
# the TLS Library still thinks it's matching hostnames.
|
| 461 |
+
cert = self.sock.getpeercert()
|
| 462 |
+
if not cert.get("subjectAltName", ()):
|
| 463 |
+
warnings.warn(
|
| 464 |
+
(
|
| 465 |
+
"Certificate for {0} has no `subjectAltName`, falling back to check for a "
|
| 466 |
+
"`commonName` for now. This feature is being removed by major browsers and "
|
| 467 |
+
"deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 "
|
| 468 |
+
"for details.)".format(hostname)
|
| 469 |
+
),
|
| 470 |
+
SubjectAltNameWarning,
|
| 471 |
+
)
|
| 472 |
+
_match_hostname(cert, self.assert_hostname or server_hostname)
|
| 473 |
+
|
| 474 |
+
self.is_verified = (
|
| 475 |
+
context.verify_mode == ssl.CERT_REQUIRED
|
| 476 |
+
or self.assert_fingerprint is not None
|
| 477 |
+
)
|
| 478 |
+
|
| 479 |
+
def _connect_tls_proxy(self, hostname, conn):
|
| 480 |
+
"""
|
| 481 |
+
Establish a TLS connection to the proxy using the provided SSL context.
|
| 482 |
+
"""
|
| 483 |
+
proxy_config = self.proxy_config
|
| 484 |
+
ssl_context = proxy_config.ssl_context
|
| 485 |
+
if ssl_context:
|
| 486 |
+
# If the user provided a proxy context, we assume CA and client
|
| 487 |
+
# certificates have already been set
|
| 488 |
+
return ssl_wrap_socket(
|
| 489 |
+
sock=conn,
|
| 490 |
+
server_hostname=hostname,
|
| 491 |
+
ssl_context=ssl_context,
|
| 492 |
+
)
|
| 493 |
+
|
| 494 |
+
ssl_context = create_proxy_ssl_context(
|
| 495 |
+
self.ssl_version,
|
| 496 |
+
self.cert_reqs,
|
| 497 |
+
self.ca_certs,
|
| 498 |
+
self.ca_cert_dir,
|
| 499 |
+
self.ca_cert_data,
|
| 500 |
+
)
|
| 501 |
+
|
| 502 |
+
# If no cert was provided, use only the default options for server
|
| 503 |
+
# certificate validation
|
| 504 |
+
socket = ssl_wrap_socket(
|
| 505 |
+
sock=conn,
|
| 506 |
+
ca_certs=self.ca_certs,
|
| 507 |
+
ca_cert_dir=self.ca_cert_dir,
|
| 508 |
+
ca_cert_data=self.ca_cert_data,
|
| 509 |
+
server_hostname=hostname,
|
| 510 |
+
ssl_context=ssl_context,
|
| 511 |
+
)
|
| 512 |
+
|
| 513 |
+
if ssl_context.verify_mode != ssl.CERT_NONE and not getattr(
|
| 514 |
+
ssl_context, "check_hostname", False
|
| 515 |
+
):
|
| 516 |
+
# While urllib3 attempts to always turn off hostname matching from
|
| 517 |
+
# the TLS library, this cannot always be done. So we check whether
|
| 518 |
+
# the TLS Library still thinks it's matching hostnames.
|
| 519 |
+
cert = socket.getpeercert()
|
| 520 |
+
if not cert.get("subjectAltName", ()):
|
| 521 |
+
warnings.warn(
|
| 522 |
+
(
|
| 523 |
+
"Certificate for {0} has no `subjectAltName`, falling back to check for a "
|
| 524 |
+
"`commonName` for now. This feature is being removed by major browsers and "
|
| 525 |
+
"deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 "
|
| 526 |
+
"for details.)".format(hostname)
|
| 527 |
+
),
|
| 528 |
+
SubjectAltNameWarning,
|
| 529 |
+
)
|
| 530 |
+
_match_hostname(cert, hostname)
|
| 531 |
+
|
| 532 |
+
self.proxy_is_verified = ssl_context.verify_mode == ssl.CERT_REQUIRED
|
| 533 |
+
return socket
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
def _match_hostname(cert, asserted_hostname):
|
| 537 |
+
# Our upstream implementation of ssl.match_hostname()
|
| 538 |
+
# only applies this normalization to IP addresses so it doesn't
|
| 539 |
+
# match DNS SANs so we do the same thing!
|
| 540 |
+
stripped_hostname = asserted_hostname.strip("u[]")
|
| 541 |
+
if is_ipaddress(stripped_hostname):
|
| 542 |
+
asserted_hostname = stripped_hostname
|
| 543 |
+
|
| 544 |
+
try:
|
| 545 |
+
match_hostname(cert, asserted_hostname)
|
| 546 |
+
except CertificateError as e:
|
| 547 |
+
log.warning(
|
| 548 |
+
"Certificate did not match expected hostname: %s. Certificate: %s",
|
| 549 |
+
asserted_hostname,
|
| 550 |
+
cert,
|
| 551 |
+
)
|
| 552 |
+
# Add cert to exception and reraise so client code can inspect
|
| 553 |
+
# the cert when catching the exception, if they want to
|
| 554 |
+
e._peer_cert = cert
|
| 555 |
+
raise
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
def _get_default_user_agent():
|
| 559 |
+
return "python-urllib3/%s" % __version__
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
class DummyConnection(object):
|
| 563 |
+
"""Used to detect a failed ConnectionCls import."""
|
| 564 |
+
|
| 565 |
+
pass
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
if not ssl:
|
| 569 |
+
HTTPSConnection = DummyConnection # noqa: F811
|
| 570 |
+
|
| 571 |
+
|
| 572 |
+
VerifiedHTTPSConnection = HTTPSConnection
|
.venv/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py
ADDED
|
@@ -0,0 +1,1132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import absolute_import
|
| 2 |
+
|
| 3 |
+
import errno
|
| 4 |
+
import logging
|
| 5 |
+
import re
|
| 6 |
+
import socket
|
| 7 |
+
import sys
|
| 8 |
+
import warnings
|
| 9 |
+
from socket import error as SocketError
|
| 10 |
+
from socket import timeout as SocketTimeout
|
| 11 |
+
|
| 12 |
+
from .connection import (
|
| 13 |
+
BaseSSLError,
|
| 14 |
+
BrokenPipeError,
|
| 15 |
+
DummyConnection,
|
| 16 |
+
HTTPConnection,
|
| 17 |
+
HTTPException,
|
| 18 |
+
HTTPSConnection,
|
| 19 |
+
VerifiedHTTPSConnection,
|
| 20 |
+
port_by_scheme,
|
| 21 |
+
)
|
| 22 |
+
from .exceptions import (
|
| 23 |
+
ClosedPoolError,
|
| 24 |
+
EmptyPoolError,
|
| 25 |
+
HeaderParsingError,
|
| 26 |
+
HostChangedError,
|
| 27 |
+
InsecureRequestWarning,
|
| 28 |
+
LocationValueError,
|
| 29 |
+
MaxRetryError,
|
| 30 |
+
NewConnectionError,
|
| 31 |
+
ProtocolError,
|
| 32 |
+
ProxyError,
|
| 33 |
+
ReadTimeoutError,
|
| 34 |
+
SSLError,
|
| 35 |
+
TimeoutError,
|
| 36 |
+
)
|
| 37 |
+
from .packages import six
|
| 38 |
+
from .packages.six.moves import queue
|
| 39 |
+
from .request import RequestMethods
|
| 40 |
+
from .response import HTTPResponse
|
| 41 |
+
from .util.connection import is_connection_dropped
|
| 42 |
+
from .util.proxy import connection_requires_http_tunnel
|
| 43 |
+
from .util.queue import LifoQueue
|
| 44 |
+
from .util.request import set_file_position
|
| 45 |
+
from .util.response import assert_header_parsing
|
| 46 |
+
from .util.retry import Retry
|
| 47 |
+
from .util.ssl_match_hostname import CertificateError
|
| 48 |
+
from .util.timeout import Timeout
|
| 49 |
+
from .util.url import Url, _encode_target
|
| 50 |
+
from .util.url import _normalize_host as normalize_host
|
| 51 |
+
from .util.url import get_host, parse_url
|
| 52 |
+
|
| 53 |
+
try: # Platform-specific: Python 3
|
| 54 |
+
import weakref
|
| 55 |
+
|
| 56 |
+
weakref_finalize = weakref.finalize
|
| 57 |
+
except AttributeError: # Platform-specific: Python 2
|
| 58 |
+
from .packages.backports.weakref_finalize import weakref_finalize
|
| 59 |
+
|
| 60 |
+
xrange = six.moves.xrange
|
| 61 |
+
|
| 62 |
+
log = logging.getLogger(__name__)
|
| 63 |
+
|
| 64 |
+
_Default = object()
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
# Pool objects
|
| 68 |
+
class ConnectionPool(object):
|
| 69 |
+
"""
|
| 70 |
+
Base class for all connection pools, such as
|
| 71 |
+
:class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
|
| 72 |
+
|
| 73 |
+
.. note::
|
| 74 |
+
ConnectionPool.urlopen() does not normalize or percent-encode target URIs
|
| 75 |
+
which is useful if your target server doesn't support percent-encoded
|
| 76 |
+
target URIs.
|
| 77 |
+
"""
|
| 78 |
+
|
| 79 |
+
scheme = None
|
| 80 |
+
QueueCls = LifoQueue
|
| 81 |
+
|
| 82 |
+
def __init__(self, host, port=None):
|
| 83 |
+
if not host:
|
| 84 |
+
raise LocationValueError("No host specified.")
|
| 85 |
+
|
| 86 |
+
self.host = _normalize_host(host, scheme=self.scheme)
|
| 87 |
+
self._proxy_host = host.lower()
|
| 88 |
+
self.port = port
|
| 89 |
+
|
| 90 |
+
def __str__(self):
|
| 91 |
+
return "%s(host=%r, port=%r)" % (type(self).__name__, self.host, self.port)
|
| 92 |
+
|
| 93 |
+
def __enter__(self):
|
| 94 |
+
return self
|
| 95 |
+
|
| 96 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
| 97 |
+
self.close()
|
| 98 |
+
# Return False to re-raise any potential exceptions
|
| 99 |
+
return False
|
| 100 |
+
|
| 101 |
+
def close(self):
|
| 102 |
+
"""
|
| 103 |
+
Close all pooled connections and disable the pool.
|
| 104 |
+
"""
|
| 105 |
+
pass
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
# This is taken from http://hg.python.org/cpython/file/7aaba721ebc0/Lib/socket.py#l252
|
| 109 |
+
_blocking_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class HTTPConnectionPool(ConnectionPool, RequestMethods):
|
| 113 |
+
"""
|
| 114 |
+
Thread-safe connection pool for one host.
|
| 115 |
+
|
| 116 |
+
:param host:
|
| 117 |
+
Host used for this HTTP Connection (e.g. "localhost"), passed into
|
| 118 |
+
:class:`http.client.HTTPConnection`.
|
| 119 |
+
|
| 120 |
+
:param port:
|
| 121 |
+
Port used for this HTTP Connection (None is equivalent to 80), passed
|
| 122 |
+
into :class:`http.client.HTTPConnection`.
|
| 123 |
+
|
| 124 |
+
:param strict:
|
| 125 |
+
Causes BadStatusLine to be raised if the status line can't be parsed
|
| 126 |
+
as a valid HTTP/1.0 or 1.1 status line, passed into
|
| 127 |
+
:class:`http.client.HTTPConnection`.
|
| 128 |
+
|
| 129 |
+
.. note::
|
| 130 |
+
Only works in Python 2. This parameter is ignored in Python 3.
|
| 131 |
+
|
| 132 |
+
:param timeout:
|
| 133 |
+
Socket timeout in seconds for each individual connection. This can
|
| 134 |
+
be a float or integer, which sets the timeout for the HTTP request,
|
| 135 |
+
or an instance of :class:`urllib3.util.Timeout` which gives you more
|
| 136 |
+
fine-grained control over request timeouts. After the constructor has
|
| 137 |
+
been parsed, this is always a `urllib3.util.Timeout` object.
|
| 138 |
+
|
| 139 |
+
:param maxsize:
|
| 140 |
+
Number of connections to save that can be reused. More than 1 is useful
|
| 141 |
+
in multithreaded situations. If ``block`` is set to False, more
|
| 142 |
+
connections will be created but they will not be saved once they've
|
| 143 |
+
been used.
|
| 144 |
+
|
| 145 |
+
:param block:
|
| 146 |
+
If set to True, no more than ``maxsize`` connections will be used at
|
| 147 |
+
a time. When no free connections are available, the call will block
|
| 148 |
+
until a connection has been released. This is a useful side effect for
|
| 149 |
+
particular multithreaded situations where one does not want to use more
|
| 150 |
+
than maxsize connections per host to prevent flooding.
|
| 151 |
+
|
| 152 |
+
:param headers:
|
| 153 |
+
Headers to include with all requests, unless other headers are given
|
| 154 |
+
explicitly.
|
| 155 |
+
|
| 156 |
+
:param retries:
|
| 157 |
+
Retry configuration to use by default with requests in this pool.
|
| 158 |
+
|
| 159 |
+
:param _proxy:
|
| 160 |
+
Parsed proxy URL, should not be used directly, instead, see
|
| 161 |
+
:class:`urllib3.ProxyManager`
|
| 162 |
+
|
| 163 |
+
:param _proxy_headers:
|
| 164 |
+
A dictionary with proxy headers, should not be used directly,
|
| 165 |
+
instead, see :class:`urllib3.ProxyManager`
|
| 166 |
+
|
| 167 |
+
:param \\**conn_kw:
|
| 168 |
+
Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`,
|
| 169 |
+
:class:`urllib3.connection.HTTPSConnection` instances.
|
| 170 |
+
"""
|
| 171 |
+
|
| 172 |
+
scheme = "http"
|
| 173 |
+
ConnectionCls = HTTPConnection
|
| 174 |
+
ResponseCls = HTTPResponse
|
| 175 |
+
|
| 176 |
+
def __init__(
|
| 177 |
+
self,
|
| 178 |
+
host,
|
| 179 |
+
port=None,
|
| 180 |
+
strict=False,
|
| 181 |
+
timeout=Timeout.DEFAULT_TIMEOUT,
|
| 182 |
+
maxsize=1,
|
| 183 |
+
block=False,
|
| 184 |
+
headers=None,
|
| 185 |
+
retries=None,
|
| 186 |
+
_proxy=None,
|
| 187 |
+
_proxy_headers=None,
|
| 188 |
+
_proxy_config=None,
|
| 189 |
+
**conn_kw
|
| 190 |
+
):
|
| 191 |
+
ConnectionPool.__init__(self, host, port)
|
| 192 |
+
RequestMethods.__init__(self, headers)
|
| 193 |
+
|
| 194 |
+
self.strict = strict
|
| 195 |
+
|
| 196 |
+
if not isinstance(timeout, Timeout):
|
| 197 |
+
timeout = Timeout.from_float(timeout)
|
| 198 |
+
|
| 199 |
+
if retries is None:
|
| 200 |
+
retries = Retry.DEFAULT
|
| 201 |
+
|
| 202 |
+
self.timeout = timeout
|
| 203 |
+
self.retries = retries
|
| 204 |
+
|
| 205 |
+
self.pool = self.QueueCls(maxsize)
|
| 206 |
+
self.block = block
|
| 207 |
+
|
| 208 |
+
self.proxy = _proxy
|
| 209 |
+
self.proxy_headers = _proxy_headers or {}
|
| 210 |
+
self.proxy_config = _proxy_config
|
| 211 |
+
|
| 212 |
+
# Fill the queue up so that doing get() on it will block properly
|
| 213 |
+
for _ in xrange(maxsize):
|
| 214 |
+
self.pool.put(None)
|
| 215 |
+
|
| 216 |
+
# These are mostly for testing and debugging purposes.
|
| 217 |
+
self.num_connections = 0
|
| 218 |
+
self.num_requests = 0
|
| 219 |
+
self.conn_kw = conn_kw
|
| 220 |
+
|
| 221 |
+
if self.proxy:
|
| 222 |
+
# Enable Nagle's algorithm for proxies, to avoid packet fragmentation.
|
| 223 |
+
# We cannot know if the user has added default socket options, so we cannot replace the
|
| 224 |
+
# list.
|
| 225 |
+
self.conn_kw.setdefault("socket_options", [])
|
| 226 |
+
|
| 227 |
+
self.conn_kw["proxy"] = self.proxy
|
| 228 |
+
self.conn_kw["proxy_config"] = self.proxy_config
|
| 229 |
+
|
| 230 |
+
# Do not pass 'self' as callback to 'finalize'.
|
| 231 |
+
# Then the 'finalize' would keep an endless living (leak) to self.
|
| 232 |
+
# By just passing a reference to the pool allows the garbage collector
|
| 233 |
+
# to free self if nobody else has a reference to it.
|
| 234 |
+
pool = self.pool
|
| 235 |
+
|
| 236 |
+
# Close all the HTTPConnections in the pool before the
|
| 237 |
+
# HTTPConnectionPool object is garbage collected.
|
| 238 |
+
weakref_finalize(self, _close_pool_connections, pool)
|
| 239 |
+
|
| 240 |
+
def _new_conn(self):
|
| 241 |
+
"""
|
| 242 |
+
Return a fresh :class:`HTTPConnection`.
|
| 243 |
+
"""
|
| 244 |
+
self.num_connections += 1
|
| 245 |
+
log.debug(
|
| 246 |
+
"Starting new HTTP connection (%d): %s:%s",
|
| 247 |
+
self.num_connections,
|
| 248 |
+
self.host,
|
| 249 |
+
self.port or "80",
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
conn = self.ConnectionCls(
|
| 253 |
+
host=self.host,
|
| 254 |
+
port=self.port,
|
| 255 |
+
timeout=self.timeout.connect_timeout,
|
| 256 |
+
strict=self.strict,
|
| 257 |
+
**self.conn_kw
|
| 258 |
+
)
|
| 259 |
+
return conn
|
| 260 |
+
|
| 261 |
+
def _get_conn(self, timeout=None):
|
| 262 |
+
"""
|
| 263 |
+
Get a connection. Will return a pooled connection if one is available.
|
| 264 |
+
|
| 265 |
+
If no connections are available and :prop:`.block` is ``False``, then a
|
| 266 |
+
fresh connection is returned.
|
| 267 |
+
|
| 268 |
+
:param timeout:
|
| 269 |
+
Seconds to wait before giving up and raising
|
| 270 |
+
:class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and
|
| 271 |
+
:prop:`.block` is ``True``.
|
| 272 |
+
"""
|
| 273 |
+
conn = None
|
| 274 |
+
try:
|
| 275 |
+
conn = self.pool.get(block=self.block, timeout=timeout)
|
| 276 |
+
|
| 277 |
+
except AttributeError: # self.pool is None
|
| 278 |
+
raise ClosedPoolError(self, "Pool is closed.")
|
| 279 |
+
|
| 280 |
+
except queue.Empty:
|
| 281 |
+
if self.block:
|
| 282 |
+
raise EmptyPoolError(
|
| 283 |
+
self,
|
| 284 |
+
"Pool reached maximum size and no more connections are allowed.",
|
| 285 |
+
)
|
| 286 |
+
pass # Oh well, we'll create a new connection then
|
| 287 |
+
|
| 288 |
+
# If this is a persistent connection, check if it got disconnected
|
| 289 |
+
if conn and is_connection_dropped(conn):
|
| 290 |
+
log.debug("Resetting dropped connection: %s", self.host)
|
| 291 |
+
conn.close()
|
| 292 |
+
if getattr(conn, "auto_open", 1) == 0:
|
| 293 |
+
# This is a proxied connection that has been mutated by
|
| 294 |
+
# http.client._tunnel() and cannot be reused (since it would
|
| 295 |
+
# attempt to bypass the proxy)
|
| 296 |
+
conn = None
|
| 297 |
+
|
| 298 |
+
return conn or self._new_conn()
|
| 299 |
+
|
| 300 |
+
def _put_conn(self, conn):
|
| 301 |
+
"""
|
| 302 |
+
Put a connection back into the pool.
|
| 303 |
+
|
| 304 |
+
:param conn:
|
| 305 |
+
Connection object for the current host and port as returned by
|
| 306 |
+
:meth:`._new_conn` or :meth:`._get_conn`.
|
| 307 |
+
|
| 308 |
+
If the pool is already full, the connection is closed and discarded
|
| 309 |
+
because we exceeded maxsize. If connections are discarded frequently,
|
| 310 |
+
then maxsize should be increased.
|
| 311 |
+
|
| 312 |
+
If the pool is closed, then the connection will be closed and discarded.
|
| 313 |
+
"""
|
| 314 |
+
try:
|
| 315 |
+
self.pool.put(conn, block=False)
|
| 316 |
+
return # Everything is dandy, done.
|
| 317 |
+
except AttributeError:
|
| 318 |
+
# self.pool is None.
|
| 319 |
+
pass
|
| 320 |
+
except queue.Full:
|
| 321 |
+
# This should never happen if self.block == True
|
| 322 |
+
log.warning(
|
| 323 |
+
"Connection pool is full, discarding connection: %s. Connection pool size: %s",
|
| 324 |
+
self.host,
|
| 325 |
+
self.pool.qsize(),
|
| 326 |
+
)
|
| 327 |
+
# Connection never got put back into the pool, close it.
|
| 328 |
+
if conn:
|
| 329 |
+
conn.close()
|
| 330 |
+
|
| 331 |
+
def _validate_conn(self, conn):
|
| 332 |
+
"""
|
| 333 |
+
Called right before a request is made, after the socket is created.
|
| 334 |
+
"""
|
| 335 |
+
pass
|
| 336 |
+
|
| 337 |
+
def _prepare_proxy(self, conn):
|
| 338 |
+
# Nothing to do for HTTP connections.
|
| 339 |
+
pass
|
| 340 |
+
|
| 341 |
+
def _get_timeout(self, timeout):
|
| 342 |
+
"""Helper that always returns a :class:`urllib3.util.Timeout`"""
|
| 343 |
+
if timeout is _Default:
|
| 344 |
+
return self.timeout.clone()
|
| 345 |
+
|
| 346 |
+
if isinstance(timeout, Timeout):
|
| 347 |
+
return timeout.clone()
|
| 348 |
+
else:
|
| 349 |
+
# User passed us an int/float. This is for backwards compatibility,
|
| 350 |
+
# can be removed later
|
| 351 |
+
return Timeout.from_float(timeout)
|
| 352 |
+
|
| 353 |
+
def _raise_timeout(self, err, url, timeout_value):
|
| 354 |
+
"""Is the error actually a timeout? Will raise a ReadTimeout or pass"""
|
| 355 |
+
|
| 356 |
+
if isinstance(err, SocketTimeout):
|
| 357 |
+
raise ReadTimeoutError(
|
| 358 |
+
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
| 359 |
+
)
|
| 360 |
+
|
| 361 |
+
# See the above comment about EAGAIN in Python 3. In Python 2 we have
|
| 362 |
+
# to specifically catch it and throw the timeout error
|
| 363 |
+
if hasattr(err, "errno") and err.errno in _blocking_errnos:
|
| 364 |
+
raise ReadTimeoutError(
|
| 365 |
+
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
| 366 |
+
)
|
| 367 |
+
|
| 368 |
+
# Catch possible read timeouts thrown as SSL errors. If not the
|
| 369 |
+
# case, rethrow the original. We need to do this because of:
|
| 370 |
+
# http://bugs.python.org/issue10272
|
| 371 |
+
if "timed out" in str(err) or "did not complete (read)" in str(
|
| 372 |
+
err
|
| 373 |
+
): # Python < 2.7.4
|
| 374 |
+
raise ReadTimeoutError(
|
| 375 |
+
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
| 376 |
+
)
|
| 377 |
+
|
| 378 |
+
def _make_request(
|
| 379 |
+
self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw
|
| 380 |
+
):
|
| 381 |
+
"""
|
| 382 |
+
Perform a request on a given urllib connection object taken from our
|
| 383 |
+
pool.
|
| 384 |
+
|
| 385 |
+
:param conn:
|
| 386 |
+
a connection from one of our connection pools
|
| 387 |
+
|
| 388 |
+
:param timeout:
|
| 389 |
+
Socket timeout in seconds for the request. This can be a
|
| 390 |
+
float or integer, which will set the same timeout value for
|
| 391 |
+
the socket connect and the socket read, or an instance of
|
| 392 |
+
:class:`urllib3.util.Timeout`, which gives you more fine-grained
|
| 393 |
+
control over your timeouts.
|
| 394 |
+
"""
|
| 395 |
+
self.num_requests += 1
|
| 396 |
+
|
| 397 |
+
timeout_obj = self._get_timeout(timeout)
|
| 398 |
+
timeout_obj.start_connect()
|
| 399 |
+
conn.timeout = Timeout.resolve_default_timeout(timeout_obj.connect_timeout)
|
| 400 |
+
|
| 401 |
+
# Trigger any extra validation we need to do.
|
| 402 |
+
try:
|
| 403 |
+
self._validate_conn(conn)
|
| 404 |
+
except (SocketTimeout, BaseSSLError) as e:
|
| 405 |
+
# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
|
| 406 |
+
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
|
| 407 |
+
raise
|
| 408 |
+
|
| 409 |
+
# conn.request() calls http.client.*.request, not the method in
|
| 410 |
+
# urllib3.request. It also calls makefile (recv) on the socket.
|
| 411 |
+
try:
|
| 412 |
+
if chunked:
|
| 413 |
+
conn.request_chunked(method, url, **httplib_request_kw)
|
| 414 |
+
else:
|
| 415 |
+
conn.request(method, url, **httplib_request_kw)
|
| 416 |
+
|
| 417 |
+
# We are swallowing BrokenPipeError (errno.EPIPE) since the server is
|
| 418 |
+
# legitimately able to close the connection after sending a valid response.
|
| 419 |
+
# With this behaviour, the received response is still readable.
|
| 420 |
+
except BrokenPipeError:
|
| 421 |
+
# Python 3
|
| 422 |
+
pass
|
| 423 |
+
except IOError as e:
|
| 424 |
+
# Python 2 and macOS/Linux
|
| 425 |
+
# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS
|
| 426 |
+
# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
|
| 427 |
+
if e.errno not in {
|
| 428 |
+
errno.EPIPE,
|
| 429 |
+
errno.ESHUTDOWN,
|
| 430 |
+
errno.EPROTOTYPE,
|
| 431 |
+
}:
|
| 432 |
+
raise
|
| 433 |
+
|
| 434 |
+
# Reset the timeout for the recv() on the socket
|
| 435 |
+
read_timeout = timeout_obj.read_timeout
|
| 436 |
+
|
| 437 |
+
# App Engine doesn't have a sock attr
|
| 438 |
+
if getattr(conn, "sock", None):
|
| 439 |
+
# In Python 3 socket.py will catch EAGAIN and return None when you
|
| 440 |
+
# try and read into the file pointer created by http.client, which
|
| 441 |
+
# instead raises a BadStatusLine exception. Instead of catching
|
| 442 |
+
# the exception and assuming all BadStatusLine exceptions are read
|
| 443 |
+
# timeouts, check for a zero timeout before making the request.
|
| 444 |
+
if read_timeout == 0:
|
| 445 |
+
raise ReadTimeoutError(
|
| 446 |
+
self, url, "Read timed out. (read timeout=%s)" % read_timeout
|
| 447 |
+
)
|
| 448 |
+
if read_timeout is Timeout.DEFAULT_TIMEOUT:
|
| 449 |
+
conn.sock.settimeout(socket.getdefaulttimeout())
|
| 450 |
+
else: # None or a value
|
| 451 |
+
conn.sock.settimeout(read_timeout)
|
| 452 |
+
|
| 453 |
+
# Receive the response from the server
|
| 454 |
+
try:
|
| 455 |
+
try:
|
| 456 |
+
# Python 2.7, use buffering of HTTP responses
|
| 457 |
+
httplib_response = conn.getresponse(buffering=True)
|
| 458 |
+
except TypeError:
|
| 459 |
+
# Python 3
|
| 460 |
+
try:
|
| 461 |
+
httplib_response = conn.getresponse()
|
| 462 |
+
except BaseException as e:
|
| 463 |
+
# Remove the TypeError from the exception chain in
|
| 464 |
+
# Python 3 (including for exceptions like SystemExit).
|
| 465 |
+
# Otherwise it looks like a bug in the code.
|
| 466 |
+
six.raise_from(e, None)
|
| 467 |
+
except (SocketTimeout, BaseSSLError, SocketError) as e:
|
| 468 |
+
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
|
| 469 |
+
raise
|
| 470 |
+
|
| 471 |
+
# AppEngine doesn't have a version attr.
|
| 472 |
+
http_version = getattr(conn, "_http_vsn_str", "HTTP/?")
|
| 473 |
+
log.debug(
|
| 474 |
+
'%s://%s:%s "%s %s %s" %s %s',
|
| 475 |
+
self.scheme,
|
| 476 |
+
self.host,
|
| 477 |
+
self.port,
|
| 478 |
+
method,
|
| 479 |
+
url,
|
| 480 |
+
http_version,
|
| 481 |
+
httplib_response.status,
|
| 482 |
+
httplib_response.length,
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
try:
|
| 486 |
+
assert_header_parsing(httplib_response.msg)
|
| 487 |
+
except (HeaderParsingError, TypeError) as hpe: # Platform-specific: Python 3
|
| 488 |
+
log.warning(
|
| 489 |
+
"Failed to parse headers (url=%s): %s",
|
| 490 |
+
self._absolute_url(url),
|
| 491 |
+
hpe,
|
| 492 |
+
exc_info=True,
|
| 493 |
+
)
|
| 494 |
+
|
| 495 |
+
return httplib_response
|
| 496 |
+
|
| 497 |
+
def _absolute_url(self, path):
|
| 498 |
+
return Url(scheme=self.scheme, host=self.host, port=self.port, path=path).url
|
| 499 |
+
|
| 500 |
+
def close(self):
|
| 501 |
+
"""
|
| 502 |
+
Close all pooled connections and disable the pool.
|
| 503 |
+
"""
|
| 504 |
+
if self.pool is None:
|
| 505 |
+
return
|
| 506 |
+
# Disable access to the pool
|
| 507 |
+
old_pool, self.pool = self.pool, None
|
| 508 |
+
|
| 509 |
+
# Close all the HTTPConnections in the pool.
|
| 510 |
+
_close_pool_connections(old_pool)
|
| 511 |
+
|
| 512 |
+
def is_same_host(self, url):
|
| 513 |
+
"""
|
| 514 |
+
Check if the given ``url`` is a member of the same host as this
|
| 515 |
+
connection pool.
|
| 516 |
+
"""
|
| 517 |
+
if url.startswith("/"):
|
| 518 |
+
return True
|
| 519 |
+
|
| 520 |
+
# TODO: Add optional support for socket.gethostbyname checking.
|
| 521 |
+
scheme, host, port = get_host(url)
|
| 522 |
+
if host is not None:
|
| 523 |
+
host = _normalize_host(host, scheme=scheme)
|
| 524 |
+
|
| 525 |
+
# Use explicit default port for comparison when none is given
|
| 526 |
+
if self.port and not port:
|
| 527 |
+
port = port_by_scheme.get(scheme)
|
| 528 |
+
elif not self.port and port == port_by_scheme.get(scheme):
|
| 529 |
+
port = None
|
| 530 |
+
|
| 531 |
+
return (scheme, host, port) == (self.scheme, self.host, self.port)
|
| 532 |
+
|
| 533 |
+
def urlopen(
|
| 534 |
+
self,
|
| 535 |
+
method,
|
| 536 |
+
url,
|
| 537 |
+
body=None,
|
| 538 |
+
headers=None,
|
| 539 |
+
retries=None,
|
| 540 |
+
redirect=True,
|
| 541 |
+
assert_same_host=True,
|
| 542 |
+
timeout=_Default,
|
| 543 |
+
pool_timeout=None,
|
| 544 |
+
release_conn=None,
|
| 545 |
+
chunked=False,
|
| 546 |
+
body_pos=None,
|
| 547 |
+
**response_kw
|
| 548 |
+
):
|
| 549 |
+
"""
|
| 550 |
+
Get a connection from the pool and perform an HTTP request. This is the
|
| 551 |
+
lowest level call for making a request, so you'll need to specify all
|
| 552 |
+
the raw details.
|
| 553 |
+
|
| 554 |
+
.. note::
|
| 555 |
+
|
| 556 |
+
More commonly, it's appropriate to use a convenience method provided
|
| 557 |
+
by :class:`.RequestMethods`, such as :meth:`request`.
|
| 558 |
+
|
| 559 |
+
.. note::
|
| 560 |
+
|
| 561 |
+
`release_conn` will only behave as expected if
|
| 562 |
+
`preload_content=False` because we want to make
|
| 563 |
+
`preload_content=False` the default behaviour someday soon without
|
| 564 |
+
breaking backwards compatibility.
|
| 565 |
+
|
| 566 |
+
:param method:
|
| 567 |
+
HTTP request method (such as GET, POST, PUT, etc.)
|
| 568 |
+
|
| 569 |
+
:param url:
|
| 570 |
+
The URL to perform the request on.
|
| 571 |
+
|
| 572 |
+
:param body:
|
| 573 |
+
Data to send in the request body, either :class:`str`, :class:`bytes`,
|
| 574 |
+
an iterable of :class:`str`/:class:`bytes`, or a file-like object.
|
| 575 |
+
|
| 576 |
+
:param headers:
|
| 577 |
+
Dictionary of custom headers to send, such as User-Agent,
|
| 578 |
+
If-None-Match, etc. If None, pool headers are used. If provided,
|
| 579 |
+
these headers completely replace any pool-specific headers.
|
| 580 |
+
|
| 581 |
+
:param retries:
|
| 582 |
+
Configure the number of retries to allow before raising a
|
| 583 |
+
:class:`~urllib3.exceptions.MaxRetryError` exception.
|
| 584 |
+
|
| 585 |
+
Pass ``None`` to retry until you receive a response. Pass a
|
| 586 |
+
:class:`~urllib3.util.retry.Retry` object for fine-grained control
|
| 587 |
+
over different types of retries.
|
| 588 |
+
Pass an integer number to retry connection errors that many times,
|
| 589 |
+
but no other types of errors. Pass zero to never retry.
|
| 590 |
+
|
| 591 |
+
If ``False``, then retries are disabled and any exception is raised
|
| 592 |
+
immediately. Also, instead of raising a MaxRetryError on redirects,
|
| 593 |
+
the redirect response will be returned.
|
| 594 |
+
|
| 595 |
+
:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
|
| 596 |
+
|
| 597 |
+
:param redirect:
|
| 598 |
+
If True, automatically handle redirects (status codes 301, 302,
|
| 599 |
+
303, 307, 308). Each redirect counts as a retry. Disabling retries
|
| 600 |
+
will disable redirect, too.
|
| 601 |
+
|
| 602 |
+
:param assert_same_host:
|
| 603 |
+
If ``True``, will make sure that the host of the pool requests is
|
| 604 |
+
consistent else will raise HostChangedError. When ``False``, you can
|
| 605 |
+
use the pool on an HTTP proxy and request foreign hosts.
|
| 606 |
+
|
| 607 |
+
:param timeout:
|
| 608 |
+
If specified, overrides the default timeout for this one
|
| 609 |
+
request. It may be a float (in seconds) or an instance of
|
| 610 |
+
:class:`urllib3.util.Timeout`.
|
| 611 |
+
|
| 612 |
+
:param pool_timeout:
|
| 613 |
+
If set and the pool is set to block=True, then this method will
|
| 614 |
+
block for ``pool_timeout`` seconds and raise EmptyPoolError if no
|
| 615 |
+
connection is available within the time period.
|
| 616 |
+
|
| 617 |
+
:param release_conn:
|
| 618 |
+
If False, then the urlopen call will not release the connection
|
| 619 |
+
back into the pool once a response is received (but will release if
|
| 620 |
+
you read the entire contents of the response such as when
|
| 621 |
+
`preload_content=True`). This is useful if you're not preloading
|
| 622 |
+
the response's content immediately. You will need to call
|
| 623 |
+
``r.release_conn()`` on the response ``r`` to return the connection
|
| 624 |
+
back into the pool. If None, it takes the value of
|
| 625 |
+
``response_kw.get('preload_content', True)``.
|
| 626 |
+
|
| 627 |
+
:param chunked:
|
| 628 |
+
If True, urllib3 will send the body using chunked transfer
|
| 629 |
+
encoding. Otherwise, urllib3 will send the body using the standard
|
| 630 |
+
content-length form. Defaults to False.
|
| 631 |
+
|
| 632 |
+
:param int body_pos:
|
| 633 |
+
Position to seek to in file-like body in the event of a retry or
|
| 634 |
+
redirect. Typically this won't need to be set because urllib3 will
|
| 635 |
+
auto-populate the value when needed.
|
| 636 |
+
|
| 637 |
+
:param \\**response_kw:
|
| 638 |
+
Additional parameters are passed to
|
| 639 |
+
:meth:`urllib3.response.HTTPResponse.from_httplib`
|
| 640 |
+
"""
|
| 641 |
+
|
| 642 |
+
parsed_url = parse_url(url)
|
| 643 |
+
destination_scheme = parsed_url.scheme
|
| 644 |
+
|
| 645 |
+
if headers is None:
|
| 646 |
+
headers = self.headers
|
| 647 |
+
|
| 648 |
+
if not isinstance(retries, Retry):
|
| 649 |
+
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
|
| 650 |
+
|
| 651 |
+
if release_conn is None:
|
| 652 |
+
release_conn = response_kw.get("preload_content", True)
|
| 653 |
+
|
| 654 |
+
# Check host
|
| 655 |
+
if assert_same_host and not self.is_same_host(url):
|
| 656 |
+
raise HostChangedError(self, url, retries)
|
| 657 |
+
|
| 658 |
+
# Ensure that the URL we're connecting to is properly encoded
|
| 659 |
+
if url.startswith("/"):
|
| 660 |
+
url = six.ensure_str(_encode_target(url))
|
| 661 |
+
else:
|
| 662 |
+
url = six.ensure_str(parsed_url.url)
|
| 663 |
+
|
| 664 |
+
conn = None
|
| 665 |
+
|
| 666 |
+
# Track whether `conn` needs to be released before
|
| 667 |
+
# returning/raising/recursing. Update this variable if necessary, and
|
| 668 |
+
# leave `release_conn` constant throughout the function. That way, if
|
| 669 |
+
# the function recurses, the original value of `release_conn` will be
|
| 670 |
+
# passed down into the recursive call, and its value will be respected.
|
| 671 |
+
#
|
| 672 |
+
# See issue #651 [1] for details.
|
| 673 |
+
#
|
| 674 |
+
# [1] <https://github.com/urllib3/urllib3/issues/651>
|
| 675 |
+
release_this_conn = release_conn
|
| 676 |
+
|
| 677 |
+
http_tunnel_required = connection_requires_http_tunnel(
|
| 678 |
+
self.proxy, self.proxy_config, destination_scheme
|
| 679 |
+
)
|
| 680 |
+
|
| 681 |
+
# Merge the proxy headers. Only done when not using HTTP CONNECT. We
|
| 682 |
+
# have to copy the headers dict so we can safely change it without those
|
| 683 |
+
# changes being reflected in anyone else's copy.
|
| 684 |
+
if not http_tunnel_required:
|
| 685 |
+
headers = headers.copy()
|
| 686 |
+
headers.update(self.proxy_headers)
|
| 687 |
+
|
| 688 |
+
# Must keep the exception bound to a separate variable or else Python 3
|
| 689 |
+
# complains about UnboundLocalError.
|
| 690 |
+
err = None
|
| 691 |
+
|
| 692 |
+
# Keep track of whether we cleanly exited the except block. This
|
| 693 |
+
# ensures we do proper cleanup in finally.
|
| 694 |
+
clean_exit = False
|
| 695 |
+
|
| 696 |
+
# Rewind body position, if needed. Record current position
|
| 697 |
+
# for future rewinds in the event of a redirect/retry.
|
| 698 |
+
body_pos = set_file_position(body, body_pos)
|
| 699 |
+
|
| 700 |
+
try:
|
| 701 |
+
# Request a connection from the queue.
|
| 702 |
+
timeout_obj = self._get_timeout(timeout)
|
| 703 |
+
conn = self._get_conn(timeout=pool_timeout)
|
| 704 |
+
|
| 705 |
+
conn.timeout = timeout_obj.connect_timeout
|
| 706 |
+
|
| 707 |
+
is_new_proxy_conn = self.proxy is not None and not getattr(
|
| 708 |
+
conn, "sock", None
|
| 709 |
+
)
|
| 710 |
+
if is_new_proxy_conn and http_tunnel_required:
|
| 711 |
+
self._prepare_proxy(conn)
|
| 712 |
+
|
| 713 |
+
# Make the request on the httplib connection object.
|
| 714 |
+
httplib_response = self._make_request(
|
| 715 |
+
conn,
|
| 716 |
+
method,
|
| 717 |
+
url,
|
| 718 |
+
timeout=timeout_obj,
|
| 719 |
+
body=body,
|
| 720 |
+
headers=headers,
|
| 721 |
+
chunked=chunked,
|
| 722 |
+
)
|
| 723 |
+
|
| 724 |
+
# If we're going to release the connection in ``finally:``, then
|
| 725 |
+
# the response doesn't need to know about the connection. Otherwise
|
| 726 |
+
# it will also try to release it and we'll have a double-release
|
| 727 |
+
# mess.
|
| 728 |
+
response_conn = conn if not release_conn else None
|
| 729 |
+
|
| 730 |
+
# Pass method to Response for length checking
|
| 731 |
+
response_kw["request_method"] = method
|
| 732 |
+
|
| 733 |
+
# Import httplib's response into our own wrapper object
|
| 734 |
+
response = self.ResponseCls.from_httplib(
|
| 735 |
+
httplib_response,
|
| 736 |
+
pool=self,
|
| 737 |
+
connection=response_conn,
|
| 738 |
+
retries=retries,
|
| 739 |
+
**response_kw
|
| 740 |
+
)
|
| 741 |
+
|
| 742 |
+
# Everything went great!
|
| 743 |
+
clean_exit = True
|
| 744 |
+
|
| 745 |
+
except EmptyPoolError:
|
| 746 |
+
# Didn't get a connection from the pool, no need to clean up
|
| 747 |
+
clean_exit = True
|
| 748 |
+
release_this_conn = False
|
| 749 |
+
raise
|
| 750 |
+
|
| 751 |
+
except (
|
| 752 |
+
TimeoutError,
|
| 753 |
+
HTTPException,
|
| 754 |
+
SocketError,
|
| 755 |
+
ProtocolError,
|
| 756 |
+
BaseSSLError,
|
| 757 |
+
SSLError,
|
| 758 |
+
CertificateError,
|
| 759 |
+
) as e:
|
| 760 |
+
# Discard the connection for these exceptions. It will be
|
| 761 |
+
# replaced during the next _get_conn() call.
|
| 762 |
+
clean_exit = False
|
| 763 |
+
|
| 764 |
+
def _is_ssl_error_message_from_http_proxy(ssl_error):
|
| 765 |
+
# We're trying to detect the message 'WRONG_VERSION_NUMBER' but
|
| 766 |
+
# SSLErrors are kinda all over the place when it comes to the message,
|
| 767 |
+
# so we try to cover our bases here!
|
| 768 |
+
message = " ".join(re.split("[^a-z]", str(ssl_error).lower()))
|
| 769 |
+
return (
|
| 770 |
+
"wrong version number" in message or "unknown protocol" in message
|
| 771 |
+
)
|
| 772 |
+
|
| 773 |
+
# Try to detect a common user error with proxies which is to
|
| 774 |
+
# set an HTTP proxy to be HTTPS when it should be 'http://'
|
| 775 |
+
# (ie {'http': 'http://proxy', 'https': 'https://proxy'})
|
| 776 |
+
# Instead we add a nice error message and point to a URL.
|
| 777 |
+
if (
|
| 778 |
+
isinstance(e, BaseSSLError)
|
| 779 |
+
and self.proxy
|
| 780 |
+
and _is_ssl_error_message_from_http_proxy(e)
|
| 781 |
+
and conn.proxy
|
| 782 |
+
and conn.proxy.scheme == "https"
|
| 783 |
+
):
|
| 784 |
+
e = ProxyError(
|
| 785 |
+
"Your proxy appears to only use HTTP and not HTTPS, "
|
| 786 |
+
"try changing your proxy URL to be HTTP. See: "
|
| 787 |
+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
| 788 |
+
"#https-proxy-error-http-proxy",
|
| 789 |
+
SSLError(e),
|
| 790 |
+
)
|
| 791 |
+
elif isinstance(e, (BaseSSLError, CertificateError)):
|
| 792 |
+
e = SSLError(e)
|
| 793 |
+
elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
|
| 794 |
+
e = ProxyError("Cannot connect to proxy.", e)
|
| 795 |
+
elif isinstance(e, (SocketError, HTTPException)):
|
| 796 |
+
e = ProtocolError("Connection aborted.", e)
|
| 797 |
+
|
| 798 |
+
retries = retries.increment(
|
| 799 |
+
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
|
| 800 |
+
)
|
| 801 |
+
retries.sleep()
|
| 802 |
+
|
| 803 |
+
# Keep track of the error for the retry warning.
|
| 804 |
+
err = e
|
| 805 |
+
|
| 806 |
+
finally:
|
| 807 |
+
if not clean_exit:
|
| 808 |
+
# We hit some kind of exception, handled or otherwise. We need
|
| 809 |
+
# to throw the connection away unless explicitly told not to.
|
| 810 |
+
# Close the connection, set the variable to None, and make sure
|
| 811 |
+
# we put the None back in the pool to avoid leaking it.
|
| 812 |
+
conn = conn and conn.close()
|
| 813 |
+
release_this_conn = True
|
| 814 |
+
|
| 815 |
+
if release_this_conn:
|
| 816 |
+
# Put the connection back to be reused. If the connection is
|
| 817 |
+
# expired then it will be None, which will get replaced with a
|
| 818 |
+
# fresh connection during _get_conn.
|
| 819 |
+
self._put_conn(conn)
|
| 820 |
+
|
| 821 |
+
if not conn:
|
| 822 |
+
# Try again
|
| 823 |
+
log.warning(
|
| 824 |
+
"Retrying (%r) after connection broken by '%r': %s", retries, err, url
|
| 825 |
+
)
|
| 826 |
+
return self.urlopen(
|
| 827 |
+
method,
|
| 828 |
+
url,
|
| 829 |
+
body,
|
| 830 |
+
headers,
|
| 831 |
+
retries,
|
| 832 |
+
redirect,
|
| 833 |
+
assert_same_host,
|
| 834 |
+
timeout=timeout,
|
| 835 |
+
pool_timeout=pool_timeout,
|
| 836 |
+
release_conn=release_conn,
|
| 837 |
+
chunked=chunked,
|
| 838 |
+
body_pos=body_pos,
|
| 839 |
+
**response_kw
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
# Handle redirect?
|
| 843 |
+
redirect_location = redirect and response.get_redirect_location()
|
| 844 |
+
if redirect_location:
|
| 845 |
+
if response.status == 303:
|
| 846 |
+
method = "GET"
|
| 847 |
+
|
| 848 |
+
try:
|
| 849 |
+
retries = retries.increment(method, url, response=response, _pool=self)
|
| 850 |
+
except MaxRetryError:
|
| 851 |
+
if retries.raise_on_redirect:
|
| 852 |
+
response.drain_conn()
|
| 853 |
+
raise
|
| 854 |
+
return response
|
| 855 |
+
|
| 856 |
+
response.drain_conn()
|
| 857 |
+
retries.sleep_for_retry(response)
|
| 858 |
+
log.debug("Redirecting %s -> %s", url, redirect_location)
|
| 859 |
+
return self.urlopen(
|
| 860 |
+
method,
|
| 861 |
+
redirect_location,
|
| 862 |
+
body,
|
| 863 |
+
headers,
|
| 864 |
+
retries=retries,
|
| 865 |
+
redirect=redirect,
|
| 866 |
+
assert_same_host=assert_same_host,
|
| 867 |
+
timeout=timeout,
|
| 868 |
+
pool_timeout=pool_timeout,
|
| 869 |
+
release_conn=release_conn,
|
| 870 |
+
chunked=chunked,
|
| 871 |
+
body_pos=body_pos,
|
| 872 |
+
**response_kw
|
| 873 |
+
)
|
| 874 |
+
|
| 875 |
+
# Check if we should retry the HTTP response.
|
| 876 |
+
has_retry_after = bool(response.headers.get("Retry-After"))
|
| 877 |
+
if retries.is_retry(method, response.status, has_retry_after):
|
| 878 |
+
try:
|
| 879 |
+
retries = retries.increment(method, url, response=response, _pool=self)
|
| 880 |
+
except MaxRetryError:
|
| 881 |
+
if retries.raise_on_status:
|
| 882 |
+
response.drain_conn()
|
| 883 |
+
raise
|
| 884 |
+
return response
|
| 885 |
+
|
| 886 |
+
response.drain_conn()
|
| 887 |
+
retries.sleep(response)
|
| 888 |
+
log.debug("Retry: %s", url)
|
| 889 |
+
return self.urlopen(
|
| 890 |
+
method,
|
| 891 |
+
url,
|
| 892 |
+
body,
|
| 893 |
+
headers,
|
| 894 |
+
retries=retries,
|
| 895 |
+
redirect=redirect,
|
| 896 |
+
assert_same_host=assert_same_host,
|
| 897 |
+
timeout=timeout,
|
| 898 |
+
pool_timeout=pool_timeout,
|
| 899 |
+
release_conn=release_conn,
|
| 900 |
+
chunked=chunked,
|
| 901 |
+
body_pos=body_pos,
|
| 902 |
+
**response_kw
|
| 903 |
+
)
|
| 904 |
+
|
| 905 |
+
return response
|
| 906 |
+
|
| 907 |
+
|
| 908 |
+
class HTTPSConnectionPool(HTTPConnectionPool):
|
| 909 |
+
"""
|
| 910 |
+
Same as :class:`.HTTPConnectionPool`, but HTTPS.
|
| 911 |
+
|
| 912 |
+
:class:`.HTTPSConnection` uses one of ``assert_fingerprint``,
|
| 913 |
+
``assert_hostname`` and ``host`` in this order to verify connections.
|
| 914 |
+
If ``assert_hostname`` is False, no verification is done.
|
| 915 |
+
|
| 916 |
+
The ``key_file``, ``cert_file``, ``cert_reqs``, ``ca_certs``,
|
| 917 |
+
``ca_cert_dir``, ``ssl_version``, ``key_password`` are only used if :mod:`ssl`
|
| 918 |
+
is available and are fed into :meth:`urllib3.util.ssl_wrap_socket` to upgrade
|
| 919 |
+
the connection socket into an SSL socket.
|
| 920 |
+
"""
|
| 921 |
+
|
| 922 |
+
scheme = "https"
|
| 923 |
+
ConnectionCls = HTTPSConnection
|
| 924 |
+
|
| 925 |
+
def __init__(
|
| 926 |
+
self,
|
| 927 |
+
host,
|
| 928 |
+
port=None,
|
| 929 |
+
strict=False,
|
| 930 |
+
timeout=Timeout.DEFAULT_TIMEOUT,
|
| 931 |
+
maxsize=1,
|
| 932 |
+
block=False,
|
| 933 |
+
headers=None,
|
| 934 |
+
retries=None,
|
| 935 |
+
_proxy=None,
|
| 936 |
+
_proxy_headers=None,
|
| 937 |
+
key_file=None,
|
| 938 |
+
cert_file=None,
|
| 939 |
+
cert_reqs=None,
|
| 940 |
+
key_password=None,
|
| 941 |
+
ca_certs=None,
|
| 942 |
+
ssl_version=None,
|
| 943 |
+
assert_hostname=None,
|
| 944 |
+
assert_fingerprint=None,
|
| 945 |
+
ca_cert_dir=None,
|
| 946 |
+
**conn_kw
|
| 947 |
+
):
|
| 948 |
+
|
| 949 |
+
HTTPConnectionPool.__init__(
|
| 950 |
+
self,
|
| 951 |
+
host,
|
| 952 |
+
port,
|
| 953 |
+
strict,
|
| 954 |
+
timeout,
|
| 955 |
+
maxsize,
|
| 956 |
+
block,
|
| 957 |
+
headers,
|
| 958 |
+
retries,
|
| 959 |
+
_proxy,
|
| 960 |
+
_proxy_headers,
|
| 961 |
+
**conn_kw
|
| 962 |
+
)
|
| 963 |
+
|
| 964 |
+
self.key_file = key_file
|
| 965 |
+
self.cert_file = cert_file
|
| 966 |
+
self.cert_reqs = cert_reqs
|
| 967 |
+
self.key_password = key_password
|
| 968 |
+
self.ca_certs = ca_certs
|
| 969 |
+
self.ca_cert_dir = ca_cert_dir
|
| 970 |
+
self.ssl_version = ssl_version
|
| 971 |
+
self.assert_hostname = assert_hostname
|
| 972 |
+
self.assert_fingerprint = assert_fingerprint
|
| 973 |
+
|
| 974 |
+
def _prepare_conn(self, conn):
|
| 975 |
+
"""
|
| 976 |
+
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket`
|
| 977 |
+
and establish the tunnel if proxy is used.
|
| 978 |
+
"""
|
| 979 |
+
|
| 980 |
+
if isinstance(conn, VerifiedHTTPSConnection):
|
| 981 |
+
conn.set_cert(
|
| 982 |
+
key_file=self.key_file,
|
| 983 |
+
key_password=self.key_password,
|
| 984 |
+
cert_file=self.cert_file,
|
| 985 |
+
cert_reqs=self.cert_reqs,
|
| 986 |
+
ca_certs=self.ca_certs,
|
| 987 |
+
ca_cert_dir=self.ca_cert_dir,
|
| 988 |
+
assert_hostname=self.assert_hostname,
|
| 989 |
+
assert_fingerprint=self.assert_fingerprint,
|
| 990 |
+
)
|
| 991 |
+
conn.ssl_version = self.ssl_version
|
| 992 |
+
return conn
|
| 993 |
+
|
| 994 |
+
def _prepare_proxy(self, conn):
|
| 995 |
+
"""
|
| 996 |
+
Establishes a tunnel connection through HTTP CONNECT.
|
| 997 |
+
|
| 998 |
+
Tunnel connection is established early because otherwise httplib would
|
| 999 |
+
improperly set Host: header to proxy's IP:port.
|
| 1000 |
+
"""
|
| 1001 |
+
|
| 1002 |
+
conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
|
| 1003 |
+
|
| 1004 |
+
if self.proxy.scheme == "https":
|
| 1005 |
+
conn.tls_in_tls_required = True
|
| 1006 |
+
|
| 1007 |
+
conn.connect()
|
| 1008 |
+
|
| 1009 |
+
def _new_conn(self):
|
| 1010 |
+
"""
|
| 1011 |
+
Return a fresh :class:`http.client.HTTPSConnection`.
|
| 1012 |
+
"""
|
| 1013 |
+
self.num_connections += 1
|
| 1014 |
+
log.debug(
|
| 1015 |
+
"Starting new HTTPS connection (%d): %s:%s",
|
| 1016 |
+
self.num_connections,
|
| 1017 |
+
self.host,
|
| 1018 |
+
self.port or "443",
|
| 1019 |
+
)
|
| 1020 |
+
|
| 1021 |
+
if not self.ConnectionCls or self.ConnectionCls is DummyConnection:
|
| 1022 |
+
raise SSLError(
|
| 1023 |
+
"Can't connect to HTTPS URL because the SSL module is not available."
|
| 1024 |
+
)
|
| 1025 |
+
|
| 1026 |
+
actual_host = self.host
|
| 1027 |
+
actual_port = self.port
|
| 1028 |
+
if self.proxy is not None:
|
| 1029 |
+
actual_host = self.proxy.host
|
| 1030 |
+
actual_port = self.proxy.port
|
| 1031 |
+
|
| 1032 |
+
conn = self.ConnectionCls(
|
| 1033 |
+
host=actual_host,
|
| 1034 |
+
port=actual_port,
|
| 1035 |
+
timeout=self.timeout.connect_timeout,
|
| 1036 |
+
strict=self.strict,
|
| 1037 |
+
cert_file=self.cert_file,
|
| 1038 |
+
key_file=self.key_file,
|
| 1039 |
+
key_password=self.key_password,
|
| 1040 |
+
**self.conn_kw
|
| 1041 |
+
)
|
| 1042 |
+
|
| 1043 |
+
return self._prepare_conn(conn)
|
| 1044 |
+
|
| 1045 |
+
def _validate_conn(self, conn):
|
| 1046 |
+
"""
|
| 1047 |
+
Called right before a request is made, after the socket is created.
|
| 1048 |
+
"""
|
| 1049 |
+
super(HTTPSConnectionPool, self)._validate_conn(conn)
|
| 1050 |
+
|
| 1051 |
+
# Force connect early to allow us to validate the connection.
|
| 1052 |
+
if not getattr(conn, "sock", None): # AppEngine might not have `.sock`
|
| 1053 |
+
conn.connect()
|
| 1054 |
+
|
| 1055 |
+
if not conn.is_verified:
|
| 1056 |
+
warnings.warn(
|
| 1057 |
+
(
|
| 1058 |
+
"Unverified HTTPS request is being made to host '%s'. "
|
| 1059 |
+
"Adding certificate verification is strongly advised. See: "
|
| 1060 |
+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
| 1061 |
+
"#ssl-warnings" % conn.host
|
| 1062 |
+
),
|
| 1063 |
+
InsecureRequestWarning,
|
| 1064 |
+
)
|
| 1065 |
+
|
| 1066 |
+
if getattr(conn, "proxy_is_verified", None) is False:
|
| 1067 |
+
warnings.warn(
|
| 1068 |
+
(
|
| 1069 |
+
"Unverified HTTPS connection done to an HTTPS proxy. "
|
| 1070 |
+
"Adding certificate verification is strongly advised. See: "
|
| 1071 |
+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
| 1072 |
+
"#ssl-warnings"
|
| 1073 |
+
),
|
| 1074 |
+
InsecureRequestWarning,
|
| 1075 |
+
)
|
| 1076 |
+
|
| 1077 |
+
|
| 1078 |
+
def connection_from_url(url, **kw):
|
| 1079 |
+
"""
|
| 1080 |
+
Given a url, return an :class:`.ConnectionPool` instance of its host.
|
| 1081 |
+
|
| 1082 |
+
This is a shortcut for not having to parse out the scheme, host, and port
|
| 1083 |
+
of the url before creating an :class:`.ConnectionPool` instance.
|
| 1084 |
+
|
| 1085 |
+
:param url:
|
| 1086 |
+
Absolute URL string that must include the scheme. Port is optional.
|
| 1087 |
+
|
| 1088 |
+
:param \\**kw:
|
| 1089 |
+
Passes additional parameters to the constructor of the appropriate
|
| 1090 |
+
:class:`.ConnectionPool`. Useful for specifying things like
|
| 1091 |
+
timeout, maxsize, headers, etc.
|
| 1092 |
+
|
| 1093 |
+
Example::
|
| 1094 |
+
|
| 1095 |
+
>>> conn = connection_from_url('http://google.com/')
|
| 1096 |
+
>>> r = conn.request('GET', '/')
|
| 1097 |
+
"""
|
| 1098 |
+
scheme, host, port = get_host(url)
|
| 1099 |
+
port = port or port_by_scheme.get(scheme, 80)
|
| 1100 |
+
if scheme == "https":
|
| 1101 |
+
return HTTPSConnectionPool(host, port=port, **kw)
|
| 1102 |
+
else:
|
| 1103 |
+
return HTTPConnectionPool(host, port=port, **kw)
|
| 1104 |
+
|
| 1105 |
+
|
| 1106 |
+
def _normalize_host(host, scheme):
|
| 1107 |
+
"""
|
| 1108 |
+
Normalize hosts for comparisons and use with sockets.
|
| 1109 |
+
"""
|
| 1110 |
+
|
| 1111 |
+
host = normalize_host(host, scheme)
|
| 1112 |
+
|
| 1113 |
+
# httplib doesn't like it when we include brackets in IPv6 addresses
|
| 1114 |
+
# Specifically, if we include brackets but also pass the port then
|
| 1115 |
+
# httplib crazily doubles up the square brackets on the Host header.
|
| 1116 |
+
# Instead, we need to make sure we never pass ``None`` as the port.
|
| 1117 |
+
# However, for backward compatibility reasons we can't actually
|
| 1118 |
+
# *assert* that. See http://bugs.python.org/issue28539
|
| 1119 |
+
if host.startswith("[") and host.endswith("]"):
|
| 1120 |
+
host = host[1:-1]
|
| 1121 |
+
return host
|
| 1122 |
+
|
| 1123 |
+
|
| 1124 |
+
def _close_pool_connections(pool):
|
| 1125 |
+
"""Drains a queue of connections and closes each one."""
|
| 1126 |
+
try:
|
| 1127 |
+
while True:
|
| 1128 |
+
conn = pool.get(block=False)
|
| 1129 |
+
if conn:
|
| 1130 |
+
conn.close()
|
| 1131 |
+
except queue.Empty:
|
| 1132 |
+
pass # Done.
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/__init__.py
ADDED
|
File without changes
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This module provides means to detect the App Engine environment.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def is_appengine():
|
| 9 |
+
return is_local_appengine() or is_prod_appengine()
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def is_appengine_sandbox():
|
| 13 |
+
"""Reports if the app is running in the first generation sandbox.
|
| 14 |
+
|
| 15 |
+
The second generation runtimes are technically still in a sandbox, but it
|
| 16 |
+
is much less restrictive, so generally you shouldn't need to check for it.
|
| 17 |
+
see https://cloud.google.com/appengine/docs/standard/runtimes
|
| 18 |
+
"""
|
| 19 |
+
return is_appengine() and os.environ["APPENGINE_RUNTIME"] == "python27"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def is_local_appengine():
|
| 23 |
+
return "APPENGINE_RUNTIME" in os.environ and os.environ.get(
|
| 24 |
+
"SERVER_SOFTWARE", ""
|
| 25 |
+
).startswith("Development/")
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def is_prod_appengine():
|
| 29 |
+
return "APPENGINE_RUNTIME" in os.environ and os.environ.get(
|
| 30 |
+
"SERVER_SOFTWARE", ""
|
| 31 |
+
).startswith("Google App Engine/")
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def is_prod_appengine_mvms():
|
| 35 |
+
"""Deprecated."""
|
| 36 |
+
return False
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This module uses ctypes to bind a whole bunch of functions and constants from
|
| 3 |
+
SecureTransport. The goal here is to provide the low-level API to
|
| 4 |
+
SecureTransport. These are essentially the C-level functions and constants, and
|
| 5 |
+
they're pretty gross to work with.
|
| 6 |
+
|
| 7 |
+
This code is a bastardised version of the code found in Will Bond's oscrypto
|
| 8 |
+
library. An enormous debt is owed to him for blazing this trail for us. For
|
| 9 |
+
that reason, this code should be considered to be covered both by urllib3's
|
| 10 |
+
license and by oscrypto's:
|
| 11 |
+
|
| 12 |
+
Copyright (c) 2015-2016 Will Bond <will@wbond.net>
|
| 13 |
+
|
| 14 |
+
Permission is hereby granted, free of charge, to any person obtaining a
|
| 15 |
+
copy of this software and associated documentation files (the "Software"),
|
| 16 |
+
to deal in the Software without restriction, including without limitation
|
| 17 |
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
| 18 |
+
and/or sell copies of the Software, and to permit persons to whom the
|
| 19 |
+
Software is furnished to do so, subject to the following conditions:
|
| 20 |
+
|
| 21 |
+
The above copyright notice and this permission notice shall be included in
|
| 22 |
+
all copies or substantial portions of the Software.
|
| 23 |
+
|
| 24 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 25 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 26 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 27 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 28 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 29 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 30 |
+
DEALINGS IN THE SOFTWARE.
|
| 31 |
+
"""
|
| 32 |
+
from __future__ import absolute_import
|
| 33 |
+
|
| 34 |
+
import platform
|
| 35 |
+
from ctypes import (
|
| 36 |
+
CDLL,
|
| 37 |
+
CFUNCTYPE,
|
| 38 |
+
POINTER,
|
| 39 |
+
c_bool,
|
| 40 |
+
c_byte,
|
| 41 |
+
c_char_p,
|
| 42 |
+
c_int32,
|
| 43 |
+
c_long,
|
| 44 |
+
c_size_t,
|
| 45 |
+
c_uint32,
|
| 46 |
+
c_ulong,
|
| 47 |
+
c_void_p,
|
| 48 |
+
)
|
| 49 |
+
from ctypes.util import find_library
|
| 50 |
+
|
| 51 |
+
from ...packages.six import raise_from
|
| 52 |
+
|
| 53 |
+
if platform.system() != "Darwin":
|
| 54 |
+
raise ImportError("Only macOS is supported")
|
| 55 |
+
|
| 56 |
+
version = platform.mac_ver()[0]
|
| 57 |
+
version_info = tuple(map(int, version.split(".")))
|
| 58 |
+
if version_info < (10, 8):
|
| 59 |
+
raise OSError(
|
| 60 |
+
"Only OS X 10.8 and newer are supported, not %s.%s"
|
| 61 |
+
% (version_info[0], version_info[1])
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def load_cdll(name, macos10_16_path):
|
| 66 |
+
"""Loads a CDLL by name, falling back to known path on 10.16+"""
|
| 67 |
+
try:
|
| 68 |
+
# Big Sur is technically 11 but we use 10.16 due to the Big Sur
|
| 69 |
+
# beta being labeled as 10.16.
|
| 70 |
+
if version_info >= (10, 16):
|
| 71 |
+
path = macos10_16_path
|
| 72 |
+
else:
|
| 73 |
+
path = find_library(name)
|
| 74 |
+
if not path:
|
| 75 |
+
raise OSError # Caught and reraised as 'ImportError'
|
| 76 |
+
return CDLL(path, use_errno=True)
|
| 77 |
+
except OSError:
|
| 78 |
+
raise_from(ImportError("The library %s failed to load" % name), None)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
Security = load_cdll(
|
| 82 |
+
"Security", "/System/Library/Frameworks/Security.framework/Security"
|
| 83 |
+
)
|
| 84 |
+
CoreFoundation = load_cdll(
|
| 85 |
+
"CoreFoundation",
|
| 86 |
+
"/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation",
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
Boolean = c_bool
|
| 91 |
+
CFIndex = c_long
|
| 92 |
+
CFStringEncoding = c_uint32
|
| 93 |
+
CFData = c_void_p
|
| 94 |
+
CFString = c_void_p
|
| 95 |
+
CFArray = c_void_p
|
| 96 |
+
CFMutableArray = c_void_p
|
| 97 |
+
CFDictionary = c_void_p
|
| 98 |
+
CFError = c_void_p
|
| 99 |
+
CFType = c_void_p
|
| 100 |
+
CFTypeID = c_ulong
|
| 101 |
+
|
| 102 |
+
CFTypeRef = POINTER(CFType)
|
| 103 |
+
CFAllocatorRef = c_void_p
|
| 104 |
+
|
| 105 |
+
OSStatus = c_int32
|
| 106 |
+
|
| 107 |
+
CFDataRef = POINTER(CFData)
|
| 108 |
+
CFStringRef = POINTER(CFString)
|
| 109 |
+
CFArrayRef = POINTER(CFArray)
|
| 110 |
+
CFMutableArrayRef = POINTER(CFMutableArray)
|
| 111 |
+
CFDictionaryRef = POINTER(CFDictionary)
|
| 112 |
+
CFArrayCallBacks = c_void_p
|
| 113 |
+
CFDictionaryKeyCallBacks = c_void_p
|
| 114 |
+
CFDictionaryValueCallBacks = c_void_p
|
| 115 |
+
|
| 116 |
+
SecCertificateRef = POINTER(c_void_p)
|
| 117 |
+
SecExternalFormat = c_uint32
|
| 118 |
+
SecExternalItemType = c_uint32
|
| 119 |
+
SecIdentityRef = POINTER(c_void_p)
|
| 120 |
+
SecItemImportExportFlags = c_uint32
|
| 121 |
+
SecItemImportExportKeyParameters = c_void_p
|
| 122 |
+
SecKeychainRef = POINTER(c_void_p)
|
| 123 |
+
SSLProtocol = c_uint32
|
| 124 |
+
SSLCipherSuite = c_uint32
|
| 125 |
+
SSLContextRef = POINTER(c_void_p)
|
| 126 |
+
SecTrustRef = POINTER(c_void_p)
|
| 127 |
+
SSLConnectionRef = c_uint32
|
| 128 |
+
SecTrustResultType = c_uint32
|
| 129 |
+
SecTrustOptionFlags = c_uint32
|
| 130 |
+
SSLProtocolSide = c_uint32
|
| 131 |
+
SSLConnectionType = c_uint32
|
| 132 |
+
SSLSessionOption = c_uint32
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
try:
|
| 136 |
+
Security.SecItemImport.argtypes = [
|
| 137 |
+
CFDataRef,
|
| 138 |
+
CFStringRef,
|
| 139 |
+
POINTER(SecExternalFormat),
|
| 140 |
+
POINTER(SecExternalItemType),
|
| 141 |
+
SecItemImportExportFlags,
|
| 142 |
+
POINTER(SecItemImportExportKeyParameters),
|
| 143 |
+
SecKeychainRef,
|
| 144 |
+
POINTER(CFArrayRef),
|
| 145 |
+
]
|
| 146 |
+
Security.SecItemImport.restype = OSStatus
|
| 147 |
+
|
| 148 |
+
Security.SecCertificateGetTypeID.argtypes = []
|
| 149 |
+
Security.SecCertificateGetTypeID.restype = CFTypeID
|
| 150 |
+
|
| 151 |
+
Security.SecIdentityGetTypeID.argtypes = []
|
| 152 |
+
Security.SecIdentityGetTypeID.restype = CFTypeID
|
| 153 |
+
|
| 154 |
+
Security.SecKeyGetTypeID.argtypes = []
|
| 155 |
+
Security.SecKeyGetTypeID.restype = CFTypeID
|
| 156 |
+
|
| 157 |
+
Security.SecCertificateCreateWithData.argtypes = [CFAllocatorRef, CFDataRef]
|
| 158 |
+
Security.SecCertificateCreateWithData.restype = SecCertificateRef
|
| 159 |
+
|
| 160 |
+
Security.SecCertificateCopyData.argtypes = [SecCertificateRef]
|
| 161 |
+
Security.SecCertificateCopyData.restype = CFDataRef
|
| 162 |
+
|
| 163 |
+
Security.SecCopyErrorMessageString.argtypes = [OSStatus, c_void_p]
|
| 164 |
+
Security.SecCopyErrorMessageString.restype = CFStringRef
|
| 165 |
+
|
| 166 |
+
Security.SecIdentityCreateWithCertificate.argtypes = [
|
| 167 |
+
CFTypeRef,
|
| 168 |
+
SecCertificateRef,
|
| 169 |
+
POINTER(SecIdentityRef),
|
| 170 |
+
]
|
| 171 |
+
Security.SecIdentityCreateWithCertificate.restype = OSStatus
|
| 172 |
+
|
| 173 |
+
Security.SecKeychainCreate.argtypes = [
|
| 174 |
+
c_char_p,
|
| 175 |
+
c_uint32,
|
| 176 |
+
c_void_p,
|
| 177 |
+
Boolean,
|
| 178 |
+
c_void_p,
|
| 179 |
+
POINTER(SecKeychainRef),
|
| 180 |
+
]
|
| 181 |
+
Security.SecKeychainCreate.restype = OSStatus
|
| 182 |
+
|
| 183 |
+
Security.SecKeychainDelete.argtypes = [SecKeychainRef]
|
| 184 |
+
Security.SecKeychainDelete.restype = OSStatus
|
| 185 |
+
|
| 186 |
+
Security.SecPKCS12Import.argtypes = [
|
| 187 |
+
CFDataRef,
|
| 188 |
+
CFDictionaryRef,
|
| 189 |
+
POINTER(CFArrayRef),
|
| 190 |
+
]
|
| 191 |
+
Security.SecPKCS12Import.restype = OSStatus
|
| 192 |
+
|
| 193 |
+
SSLReadFunc = CFUNCTYPE(OSStatus, SSLConnectionRef, c_void_p, POINTER(c_size_t))
|
| 194 |
+
SSLWriteFunc = CFUNCTYPE(
|
| 195 |
+
OSStatus, SSLConnectionRef, POINTER(c_byte), POINTER(c_size_t)
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
Security.SSLSetIOFuncs.argtypes = [SSLContextRef, SSLReadFunc, SSLWriteFunc]
|
| 199 |
+
Security.SSLSetIOFuncs.restype = OSStatus
|
| 200 |
+
|
| 201 |
+
Security.SSLSetPeerID.argtypes = [SSLContextRef, c_char_p, c_size_t]
|
| 202 |
+
Security.SSLSetPeerID.restype = OSStatus
|
| 203 |
+
|
| 204 |
+
Security.SSLSetCertificate.argtypes = [SSLContextRef, CFArrayRef]
|
| 205 |
+
Security.SSLSetCertificate.restype = OSStatus
|
| 206 |
+
|
| 207 |
+
Security.SSLSetCertificateAuthorities.argtypes = [SSLContextRef, CFTypeRef, Boolean]
|
| 208 |
+
Security.SSLSetCertificateAuthorities.restype = OSStatus
|
| 209 |
+
|
| 210 |
+
Security.SSLSetConnection.argtypes = [SSLContextRef, SSLConnectionRef]
|
| 211 |
+
Security.SSLSetConnection.restype = OSStatus
|
| 212 |
+
|
| 213 |
+
Security.SSLSetPeerDomainName.argtypes = [SSLContextRef, c_char_p, c_size_t]
|
| 214 |
+
Security.SSLSetPeerDomainName.restype = OSStatus
|
| 215 |
+
|
| 216 |
+
Security.SSLHandshake.argtypes = [SSLContextRef]
|
| 217 |
+
Security.SSLHandshake.restype = OSStatus
|
| 218 |
+
|
| 219 |
+
Security.SSLRead.argtypes = [SSLContextRef, c_char_p, c_size_t, POINTER(c_size_t)]
|
| 220 |
+
Security.SSLRead.restype = OSStatus
|
| 221 |
+
|
| 222 |
+
Security.SSLWrite.argtypes = [SSLContextRef, c_char_p, c_size_t, POINTER(c_size_t)]
|
| 223 |
+
Security.SSLWrite.restype = OSStatus
|
| 224 |
+
|
| 225 |
+
Security.SSLClose.argtypes = [SSLContextRef]
|
| 226 |
+
Security.SSLClose.restype = OSStatus
|
| 227 |
+
|
| 228 |
+
Security.SSLGetNumberSupportedCiphers.argtypes = [SSLContextRef, POINTER(c_size_t)]
|
| 229 |
+
Security.SSLGetNumberSupportedCiphers.restype = OSStatus
|
| 230 |
+
|
| 231 |
+
Security.SSLGetSupportedCiphers.argtypes = [
|
| 232 |
+
SSLContextRef,
|
| 233 |
+
POINTER(SSLCipherSuite),
|
| 234 |
+
POINTER(c_size_t),
|
| 235 |
+
]
|
| 236 |
+
Security.SSLGetSupportedCiphers.restype = OSStatus
|
| 237 |
+
|
| 238 |
+
Security.SSLSetEnabledCiphers.argtypes = [
|
| 239 |
+
SSLContextRef,
|
| 240 |
+
POINTER(SSLCipherSuite),
|
| 241 |
+
c_size_t,
|
| 242 |
+
]
|
| 243 |
+
Security.SSLSetEnabledCiphers.restype = OSStatus
|
| 244 |
+
|
| 245 |
+
Security.SSLGetNumberEnabledCiphers.argtype = [SSLContextRef, POINTER(c_size_t)]
|
| 246 |
+
Security.SSLGetNumberEnabledCiphers.restype = OSStatus
|
| 247 |
+
|
| 248 |
+
Security.SSLGetEnabledCiphers.argtypes = [
|
| 249 |
+
SSLContextRef,
|
| 250 |
+
POINTER(SSLCipherSuite),
|
| 251 |
+
POINTER(c_size_t),
|
| 252 |
+
]
|
| 253 |
+
Security.SSLGetEnabledCiphers.restype = OSStatus
|
| 254 |
+
|
| 255 |
+
Security.SSLGetNegotiatedCipher.argtypes = [SSLContextRef, POINTER(SSLCipherSuite)]
|
| 256 |
+
Security.SSLGetNegotiatedCipher.restype = OSStatus
|
| 257 |
+
|
| 258 |
+
Security.SSLGetNegotiatedProtocolVersion.argtypes = [
|
| 259 |
+
SSLContextRef,
|
| 260 |
+
POINTER(SSLProtocol),
|
| 261 |
+
]
|
| 262 |
+
Security.SSLGetNegotiatedProtocolVersion.restype = OSStatus
|
| 263 |
+
|
| 264 |
+
Security.SSLCopyPeerTrust.argtypes = [SSLContextRef, POINTER(SecTrustRef)]
|
| 265 |
+
Security.SSLCopyPeerTrust.restype = OSStatus
|
| 266 |
+
|
| 267 |
+
Security.SecTrustSetAnchorCertificates.argtypes = [SecTrustRef, CFArrayRef]
|
| 268 |
+
Security.SecTrustSetAnchorCertificates.restype = OSStatus
|
| 269 |
+
|
| 270 |
+
Security.SecTrustSetAnchorCertificatesOnly.argstypes = [SecTrustRef, Boolean]
|
| 271 |
+
Security.SecTrustSetAnchorCertificatesOnly.restype = OSStatus
|
| 272 |
+
|
| 273 |
+
Security.SecTrustEvaluate.argtypes = [SecTrustRef, POINTER(SecTrustResultType)]
|
| 274 |
+
Security.SecTrustEvaluate.restype = OSStatus
|
| 275 |
+
|
| 276 |
+
Security.SecTrustGetCertificateCount.argtypes = [SecTrustRef]
|
| 277 |
+
Security.SecTrustGetCertificateCount.restype = CFIndex
|
| 278 |
+
|
| 279 |
+
Security.SecTrustGetCertificateAtIndex.argtypes = [SecTrustRef, CFIndex]
|
| 280 |
+
Security.SecTrustGetCertificateAtIndex.restype = SecCertificateRef
|
| 281 |
+
|
| 282 |
+
Security.SSLCreateContext.argtypes = [
|
| 283 |
+
CFAllocatorRef,
|
| 284 |
+
SSLProtocolSide,
|
| 285 |
+
SSLConnectionType,
|
| 286 |
+
]
|
| 287 |
+
Security.SSLCreateContext.restype = SSLContextRef
|
| 288 |
+
|
| 289 |
+
Security.SSLSetSessionOption.argtypes = [SSLContextRef, SSLSessionOption, Boolean]
|
| 290 |
+
Security.SSLSetSessionOption.restype = OSStatus
|
| 291 |
+
|
| 292 |
+
Security.SSLSetProtocolVersionMin.argtypes = [SSLContextRef, SSLProtocol]
|
| 293 |
+
Security.SSLSetProtocolVersionMin.restype = OSStatus
|
| 294 |
+
|
| 295 |
+
Security.SSLSetProtocolVersionMax.argtypes = [SSLContextRef, SSLProtocol]
|
| 296 |
+
Security.SSLSetProtocolVersionMax.restype = OSStatus
|
| 297 |
+
|
| 298 |
+
try:
|
| 299 |
+
Security.SSLSetALPNProtocols.argtypes = [SSLContextRef, CFArrayRef]
|
| 300 |
+
Security.SSLSetALPNProtocols.restype = OSStatus
|
| 301 |
+
except AttributeError:
|
| 302 |
+
# Supported only in 10.12+
|
| 303 |
+
pass
|
| 304 |
+
|
| 305 |
+
Security.SecCopyErrorMessageString.argtypes = [OSStatus, c_void_p]
|
| 306 |
+
Security.SecCopyErrorMessageString.restype = CFStringRef
|
| 307 |
+
|
| 308 |
+
Security.SSLReadFunc = SSLReadFunc
|
| 309 |
+
Security.SSLWriteFunc = SSLWriteFunc
|
| 310 |
+
Security.SSLContextRef = SSLContextRef
|
| 311 |
+
Security.SSLProtocol = SSLProtocol
|
| 312 |
+
Security.SSLCipherSuite = SSLCipherSuite
|
| 313 |
+
Security.SecIdentityRef = SecIdentityRef
|
| 314 |
+
Security.SecKeychainRef = SecKeychainRef
|
| 315 |
+
Security.SecTrustRef = SecTrustRef
|
| 316 |
+
Security.SecTrustResultType = SecTrustResultType
|
| 317 |
+
Security.SecExternalFormat = SecExternalFormat
|
| 318 |
+
Security.OSStatus = OSStatus
|
| 319 |
+
|
| 320 |
+
Security.kSecImportExportPassphrase = CFStringRef.in_dll(
|
| 321 |
+
Security, "kSecImportExportPassphrase"
|
| 322 |
+
)
|
| 323 |
+
Security.kSecImportItemIdentity = CFStringRef.in_dll(
|
| 324 |
+
Security, "kSecImportItemIdentity"
|
| 325 |
+
)
|
| 326 |
+
|
| 327 |
+
# CoreFoundation time!
|
| 328 |
+
CoreFoundation.CFRetain.argtypes = [CFTypeRef]
|
| 329 |
+
CoreFoundation.CFRetain.restype = CFTypeRef
|
| 330 |
+
|
| 331 |
+
CoreFoundation.CFRelease.argtypes = [CFTypeRef]
|
| 332 |
+
CoreFoundation.CFRelease.restype = None
|
| 333 |
+
|
| 334 |
+
CoreFoundation.CFGetTypeID.argtypes = [CFTypeRef]
|
| 335 |
+
CoreFoundation.CFGetTypeID.restype = CFTypeID
|
| 336 |
+
|
| 337 |
+
CoreFoundation.CFStringCreateWithCString.argtypes = [
|
| 338 |
+
CFAllocatorRef,
|
| 339 |
+
c_char_p,
|
| 340 |
+
CFStringEncoding,
|
| 341 |
+
]
|
| 342 |
+
CoreFoundation.CFStringCreateWithCString.restype = CFStringRef
|
| 343 |
+
|
| 344 |
+
CoreFoundation.CFStringGetCStringPtr.argtypes = [CFStringRef, CFStringEncoding]
|
| 345 |
+
CoreFoundation.CFStringGetCStringPtr.restype = c_char_p
|
| 346 |
+
|
| 347 |
+
CoreFoundation.CFStringGetCString.argtypes = [
|
| 348 |
+
CFStringRef,
|
| 349 |
+
c_char_p,
|
| 350 |
+
CFIndex,
|
| 351 |
+
CFStringEncoding,
|
| 352 |
+
]
|
| 353 |
+
CoreFoundation.CFStringGetCString.restype = c_bool
|
| 354 |
+
|
| 355 |
+
CoreFoundation.CFDataCreate.argtypes = [CFAllocatorRef, c_char_p, CFIndex]
|
| 356 |
+
CoreFoundation.CFDataCreate.restype = CFDataRef
|
| 357 |
+
|
| 358 |
+
CoreFoundation.CFDataGetLength.argtypes = [CFDataRef]
|
| 359 |
+
CoreFoundation.CFDataGetLength.restype = CFIndex
|
| 360 |
+
|
| 361 |
+
CoreFoundation.CFDataGetBytePtr.argtypes = [CFDataRef]
|
| 362 |
+
CoreFoundation.CFDataGetBytePtr.restype = c_void_p
|
| 363 |
+
|
| 364 |
+
CoreFoundation.CFDictionaryCreate.argtypes = [
|
| 365 |
+
CFAllocatorRef,
|
| 366 |
+
POINTER(CFTypeRef),
|
| 367 |
+
POINTER(CFTypeRef),
|
| 368 |
+
CFIndex,
|
| 369 |
+
CFDictionaryKeyCallBacks,
|
| 370 |
+
CFDictionaryValueCallBacks,
|
| 371 |
+
]
|
| 372 |
+
CoreFoundation.CFDictionaryCreate.restype = CFDictionaryRef
|
| 373 |
+
|
| 374 |
+
CoreFoundation.CFDictionaryGetValue.argtypes = [CFDictionaryRef, CFTypeRef]
|
| 375 |
+
CoreFoundation.CFDictionaryGetValue.restype = CFTypeRef
|
| 376 |
+
|
| 377 |
+
CoreFoundation.CFArrayCreate.argtypes = [
|
| 378 |
+
CFAllocatorRef,
|
| 379 |
+
POINTER(CFTypeRef),
|
| 380 |
+
CFIndex,
|
| 381 |
+
CFArrayCallBacks,
|
| 382 |
+
]
|
| 383 |
+
CoreFoundation.CFArrayCreate.restype = CFArrayRef
|
| 384 |
+
|
| 385 |
+
CoreFoundation.CFArrayCreateMutable.argtypes = [
|
| 386 |
+
CFAllocatorRef,
|
| 387 |
+
CFIndex,
|
| 388 |
+
CFArrayCallBacks,
|
| 389 |
+
]
|
| 390 |
+
CoreFoundation.CFArrayCreateMutable.restype = CFMutableArrayRef
|
| 391 |
+
|
| 392 |
+
CoreFoundation.CFArrayAppendValue.argtypes = [CFMutableArrayRef, c_void_p]
|
| 393 |
+
CoreFoundation.CFArrayAppendValue.restype = None
|
| 394 |
+
|
| 395 |
+
CoreFoundation.CFArrayGetCount.argtypes = [CFArrayRef]
|
| 396 |
+
CoreFoundation.CFArrayGetCount.restype = CFIndex
|
| 397 |
+
|
| 398 |
+
CoreFoundation.CFArrayGetValueAtIndex.argtypes = [CFArrayRef, CFIndex]
|
| 399 |
+
CoreFoundation.CFArrayGetValueAtIndex.restype = c_void_p
|
| 400 |
+
|
| 401 |
+
CoreFoundation.kCFAllocatorDefault = CFAllocatorRef.in_dll(
|
| 402 |
+
CoreFoundation, "kCFAllocatorDefault"
|
| 403 |
+
)
|
| 404 |
+
CoreFoundation.kCFTypeArrayCallBacks = c_void_p.in_dll(
|
| 405 |
+
CoreFoundation, "kCFTypeArrayCallBacks"
|
| 406 |
+
)
|
| 407 |
+
CoreFoundation.kCFTypeDictionaryKeyCallBacks = c_void_p.in_dll(
|
| 408 |
+
CoreFoundation, "kCFTypeDictionaryKeyCallBacks"
|
| 409 |
+
)
|
| 410 |
+
CoreFoundation.kCFTypeDictionaryValueCallBacks = c_void_p.in_dll(
|
| 411 |
+
CoreFoundation, "kCFTypeDictionaryValueCallBacks"
|
| 412 |
+
)
|
| 413 |
+
|
| 414 |
+
CoreFoundation.CFTypeRef = CFTypeRef
|
| 415 |
+
CoreFoundation.CFArrayRef = CFArrayRef
|
| 416 |
+
CoreFoundation.CFStringRef = CFStringRef
|
| 417 |
+
CoreFoundation.CFDictionaryRef = CFDictionaryRef
|
| 418 |
+
|
| 419 |
+
except (AttributeError):
|
| 420 |
+
raise ImportError("Error initializing ctypes")
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
class CFConst(object):
|
| 424 |
+
"""
|
| 425 |
+
A class object that acts as essentially a namespace for CoreFoundation
|
| 426 |
+
constants.
|
| 427 |
+
"""
|
| 428 |
+
|
| 429 |
+
kCFStringEncodingUTF8 = CFStringEncoding(0x08000100)
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
class SecurityConst(object):
|
| 433 |
+
"""
|
| 434 |
+
A class object that acts as essentially a namespace for Security constants.
|
| 435 |
+
"""
|
| 436 |
+
|
| 437 |
+
kSSLSessionOptionBreakOnServerAuth = 0
|
| 438 |
+
|
| 439 |
+
kSSLProtocol2 = 1
|
| 440 |
+
kSSLProtocol3 = 2
|
| 441 |
+
kTLSProtocol1 = 4
|
| 442 |
+
kTLSProtocol11 = 7
|
| 443 |
+
kTLSProtocol12 = 8
|
| 444 |
+
# SecureTransport does not support TLS 1.3 even if there's a constant for it
|
| 445 |
+
kTLSProtocol13 = 10
|
| 446 |
+
kTLSProtocolMaxSupported = 999
|
| 447 |
+
|
| 448 |
+
kSSLClientSide = 1
|
| 449 |
+
kSSLStreamType = 0
|
| 450 |
+
|
| 451 |
+
kSecFormatPEMSequence = 10
|
| 452 |
+
|
| 453 |
+
kSecTrustResultInvalid = 0
|
| 454 |
+
kSecTrustResultProceed = 1
|
| 455 |
+
# This gap is present on purpose: this was kSecTrustResultConfirm, which
|
| 456 |
+
# is deprecated.
|
| 457 |
+
kSecTrustResultDeny = 3
|
| 458 |
+
kSecTrustResultUnspecified = 4
|
| 459 |
+
kSecTrustResultRecoverableTrustFailure = 5
|
| 460 |
+
kSecTrustResultFatalTrustFailure = 6
|
| 461 |
+
kSecTrustResultOtherError = 7
|
| 462 |
+
|
| 463 |
+
errSSLProtocol = -9800
|
| 464 |
+
errSSLWouldBlock = -9803
|
| 465 |
+
errSSLClosedGraceful = -9805
|
| 466 |
+
errSSLClosedNoNotify = -9816
|
| 467 |
+
errSSLClosedAbort = -9806
|
| 468 |
+
|
| 469 |
+
errSSLXCertChainInvalid = -9807
|
| 470 |
+
errSSLCrypto = -9809
|
| 471 |
+
errSSLInternal = -9810
|
| 472 |
+
errSSLCertExpired = -9814
|
| 473 |
+
errSSLCertNotYetValid = -9815
|
| 474 |
+
errSSLUnknownRootCert = -9812
|
| 475 |
+
errSSLNoRootCert = -9813
|
| 476 |
+
errSSLHostNameMismatch = -9843
|
| 477 |
+
errSSLPeerHandshakeFail = -9824
|
| 478 |
+
errSSLPeerUserCancelled = -9839
|
| 479 |
+
errSSLWeakPeerEphemeralDHKey = -9850
|
| 480 |
+
errSSLServerAuthCompleted = -9841
|
| 481 |
+
errSSLRecordOverflow = -9847
|
| 482 |
+
|
| 483 |
+
errSecVerifyFailed = -67808
|
| 484 |
+
errSecNoTrustSettings = -25263
|
| 485 |
+
errSecItemNotFound = -25300
|
| 486 |
+
errSecInvalidTrustSettings = -25262
|
| 487 |
+
|
| 488 |
+
# Cipher suites. We only pick the ones our default cipher string allows.
|
| 489 |
+
# Source: https://developer.apple.com/documentation/security/1550981-ssl_cipher_suite_values
|
| 490 |
+
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xC02C
|
| 491 |
+
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xC030
|
| 492 |
+
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xC02B
|
| 493 |
+
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xC02F
|
| 494 |
+
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = 0xCCA9
|
| 495 |
+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = 0xCCA8
|
| 496 |
+
TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = 0x009F
|
| 497 |
+
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = 0x009E
|
| 498 |
+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = 0xC024
|
| 499 |
+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = 0xC028
|
| 500 |
+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xC00A
|
| 501 |
+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014
|
| 502 |
+
TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x006B
|
| 503 |
+
TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x0039
|
| 504 |
+
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 0xC023
|
| 505 |
+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 0xC027
|
| 506 |
+
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0xC009
|
| 507 |
+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xC013
|
| 508 |
+
TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x0067
|
| 509 |
+
TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x0033
|
| 510 |
+
TLS_RSA_WITH_AES_256_GCM_SHA384 = 0x009D
|
| 511 |
+
TLS_RSA_WITH_AES_128_GCM_SHA256 = 0x009C
|
| 512 |
+
TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x003D
|
| 513 |
+
TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x003C
|
| 514 |
+
TLS_RSA_WITH_AES_256_CBC_SHA = 0x0035
|
| 515 |
+
TLS_RSA_WITH_AES_128_CBC_SHA = 0x002F
|
| 516 |
+
TLS_AES_128_GCM_SHA256 = 0x1301
|
| 517 |
+
TLS_AES_256_GCM_SHA384 = 0x1302
|
| 518 |
+
TLS_AES_128_CCM_8_SHA256 = 0x1305
|
| 519 |
+
TLS_AES_128_CCM_SHA256 = 0x1304
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Low-level helpers for the SecureTransport bindings.
|
| 3 |
+
|
| 4 |
+
These are Python functions that are not directly related to the high-level APIs
|
| 5 |
+
but are necessary to get them to work. They include a whole bunch of low-level
|
| 6 |
+
CoreFoundation messing about and memory management. The concerns in this module
|
| 7 |
+
are almost entirely about trying to avoid memory leaks and providing
|
| 8 |
+
appropriate and useful assistance to the higher-level code.
|
| 9 |
+
"""
|
| 10 |
+
import base64
|
| 11 |
+
import ctypes
|
| 12 |
+
import itertools
|
| 13 |
+
import os
|
| 14 |
+
import re
|
| 15 |
+
import ssl
|
| 16 |
+
import struct
|
| 17 |
+
import tempfile
|
| 18 |
+
|
| 19 |
+
from .bindings import CFConst, CoreFoundation, Security
|
| 20 |
+
|
| 21 |
+
# This regular expression is used to grab PEM data out of a PEM bundle.
|
| 22 |
+
_PEM_CERTS_RE = re.compile(
|
| 23 |
+
b"-----BEGIN CERTIFICATE-----\n(.*?)\n-----END CERTIFICATE-----", re.DOTALL
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _cf_data_from_bytes(bytestring):
|
| 28 |
+
"""
|
| 29 |
+
Given a bytestring, create a CFData object from it. This CFData object must
|
| 30 |
+
be CFReleased by the caller.
|
| 31 |
+
"""
|
| 32 |
+
return CoreFoundation.CFDataCreate(
|
| 33 |
+
CoreFoundation.kCFAllocatorDefault, bytestring, len(bytestring)
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def _cf_dictionary_from_tuples(tuples):
|
| 38 |
+
"""
|
| 39 |
+
Given a list of Python tuples, create an associated CFDictionary.
|
| 40 |
+
"""
|
| 41 |
+
dictionary_size = len(tuples)
|
| 42 |
+
|
| 43 |
+
# We need to get the dictionary keys and values out in the same order.
|
| 44 |
+
keys = (t[0] for t in tuples)
|
| 45 |
+
values = (t[1] for t in tuples)
|
| 46 |
+
cf_keys = (CoreFoundation.CFTypeRef * dictionary_size)(*keys)
|
| 47 |
+
cf_values = (CoreFoundation.CFTypeRef * dictionary_size)(*values)
|
| 48 |
+
|
| 49 |
+
return CoreFoundation.CFDictionaryCreate(
|
| 50 |
+
CoreFoundation.kCFAllocatorDefault,
|
| 51 |
+
cf_keys,
|
| 52 |
+
cf_values,
|
| 53 |
+
dictionary_size,
|
| 54 |
+
CoreFoundation.kCFTypeDictionaryKeyCallBacks,
|
| 55 |
+
CoreFoundation.kCFTypeDictionaryValueCallBacks,
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def _cfstr(py_bstr):
|
| 60 |
+
"""
|
| 61 |
+
Given a Python binary data, create a CFString.
|
| 62 |
+
The string must be CFReleased by the caller.
|
| 63 |
+
"""
|
| 64 |
+
c_str = ctypes.c_char_p(py_bstr)
|
| 65 |
+
cf_str = CoreFoundation.CFStringCreateWithCString(
|
| 66 |
+
CoreFoundation.kCFAllocatorDefault,
|
| 67 |
+
c_str,
|
| 68 |
+
CFConst.kCFStringEncodingUTF8,
|
| 69 |
+
)
|
| 70 |
+
return cf_str
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def _create_cfstring_array(lst):
|
| 74 |
+
"""
|
| 75 |
+
Given a list of Python binary data, create an associated CFMutableArray.
|
| 76 |
+
The array must be CFReleased by the caller.
|
| 77 |
+
|
| 78 |
+
Raises an ssl.SSLError on failure.
|
| 79 |
+
"""
|
| 80 |
+
cf_arr = None
|
| 81 |
+
try:
|
| 82 |
+
cf_arr = CoreFoundation.CFArrayCreateMutable(
|
| 83 |
+
CoreFoundation.kCFAllocatorDefault,
|
| 84 |
+
0,
|
| 85 |
+
ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
|
| 86 |
+
)
|
| 87 |
+
if not cf_arr:
|
| 88 |
+
raise MemoryError("Unable to allocate memory!")
|
| 89 |
+
for item in lst:
|
| 90 |
+
cf_str = _cfstr(item)
|
| 91 |
+
if not cf_str:
|
| 92 |
+
raise MemoryError("Unable to allocate memory!")
|
| 93 |
+
try:
|
| 94 |
+
CoreFoundation.CFArrayAppendValue(cf_arr, cf_str)
|
| 95 |
+
finally:
|
| 96 |
+
CoreFoundation.CFRelease(cf_str)
|
| 97 |
+
except BaseException as e:
|
| 98 |
+
if cf_arr:
|
| 99 |
+
CoreFoundation.CFRelease(cf_arr)
|
| 100 |
+
raise ssl.SSLError("Unable to allocate array: %s" % (e,))
|
| 101 |
+
return cf_arr
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def _cf_string_to_unicode(value):
|
| 105 |
+
"""
|
| 106 |
+
Creates a Unicode string from a CFString object. Used entirely for error
|
| 107 |
+
reporting.
|
| 108 |
+
|
| 109 |
+
Yes, it annoys me quite a lot that this function is this complex.
|
| 110 |
+
"""
|
| 111 |
+
value_as_void_p = ctypes.cast(value, ctypes.POINTER(ctypes.c_void_p))
|
| 112 |
+
|
| 113 |
+
string = CoreFoundation.CFStringGetCStringPtr(
|
| 114 |
+
value_as_void_p, CFConst.kCFStringEncodingUTF8
|
| 115 |
+
)
|
| 116 |
+
if string is None:
|
| 117 |
+
buffer = ctypes.create_string_buffer(1024)
|
| 118 |
+
result = CoreFoundation.CFStringGetCString(
|
| 119 |
+
value_as_void_p, buffer, 1024, CFConst.kCFStringEncodingUTF8
|
| 120 |
+
)
|
| 121 |
+
if not result:
|
| 122 |
+
raise OSError("Error copying C string from CFStringRef")
|
| 123 |
+
string = buffer.value
|
| 124 |
+
if string is not None:
|
| 125 |
+
string = string.decode("utf-8")
|
| 126 |
+
return string
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def _assert_no_error(error, exception_class=None):
|
| 130 |
+
"""
|
| 131 |
+
Checks the return code and throws an exception if there is an error to
|
| 132 |
+
report
|
| 133 |
+
"""
|
| 134 |
+
if error == 0:
|
| 135 |
+
return
|
| 136 |
+
|
| 137 |
+
cf_error_string = Security.SecCopyErrorMessageString(error, None)
|
| 138 |
+
output = _cf_string_to_unicode(cf_error_string)
|
| 139 |
+
CoreFoundation.CFRelease(cf_error_string)
|
| 140 |
+
|
| 141 |
+
if output is None or output == u"":
|
| 142 |
+
output = u"OSStatus %s" % error
|
| 143 |
+
|
| 144 |
+
if exception_class is None:
|
| 145 |
+
exception_class = ssl.SSLError
|
| 146 |
+
|
| 147 |
+
raise exception_class(output)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def _cert_array_from_pem(pem_bundle):
|
| 151 |
+
"""
|
| 152 |
+
Given a bundle of certs in PEM format, turns them into a CFArray of certs
|
| 153 |
+
that can be used to validate a cert chain.
|
| 154 |
+
"""
|
| 155 |
+
# Normalize the PEM bundle's line endings.
|
| 156 |
+
pem_bundle = pem_bundle.replace(b"\r\n", b"\n")
|
| 157 |
+
|
| 158 |
+
der_certs = [
|
| 159 |
+
base64.b64decode(match.group(1)) for match in _PEM_CERTS_RE.finditer(pem_bundle)
|
| 160 |
+
]
|
| 161 |
+
if not der_certs:
|
| 162 |
+
raise ssl.SSLError("No root certificates specified")
|
| 163 |
+
|
| 164 |
+
cert_array = CoreFoundation.CFArrayCreateMutable(
|
| 165 |
+
CoreFoundation.kCFAllocatorDefault,
|
| 166 |
+
0,
|
| 167 |
+
ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
|
| 168 |
+
)
|
| 169 |
+
if not cert_array:
|
| 170 |
+
raise ssl.SSLError("Unable to allocate memory!")
|
| 171 |
+
|
| 172 |
+
try:
|
| 173 |
+
for der_bytes in der_certs:
|
| 174 |
+
certdata = _cf_data_from_bytes(der_bytes)
|
| 175 |
+
if not certdata:
|
| 176 |
+
raise ssl.SSLError("Unable to allocate memory!")
|
| 177 |
+
cert = Security.SecCertificateCreateWithData(
|
| 178 |
+
CoreFoundation.kCFAllocatorDefault, certdata
|
| 179 |
+
)
|
| 180 |
+
CoreFoundation.CFRelease(certdata)
|
| 181 |
+
if not cert:
|
| 182 |
+
raise ssl.SSLError("Unable to build cert object!")
|
| 183 |
+
|
| 184 |
+
CoreFoundation.CFArrayAppendValue(cert_array, cert)
|
| 185 |
+
CoreFoundation.CFRelease(cert)
|
| 186 |
+
except Exception:
|
| 187 |
+
# We need to free the array before the exception bubbles further.
|
| 188 |
+
# We only want to do that if an error occurs: otherwise, the caller
|
| 189 |
+
# should free.
|
| 190 |
+
CoreFoundation.CFRelease(cert_array)
|
| 191 |
+
raise
|
| 192 |
+
|
| 193 |
+
return cert_array
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def _is_cert(item):
|
| 197 |
+
"""
|
| 198 |
+
Returns True if a given CFTypeRef is a certificate.
|
| 199 |
+
"""
|
| 200 |
+
expected = Security.SecCertificateGetTypeID()
|
| 201 |
+
return CoreFoundation.CFGetTypeID(item) == expected
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def _is_identity(item):
|
| 205 |
+
"""
|
| 206 |
+
Returns True if a given CFTypeRef is an identity.
|
| 207 |
+
"""
|
| 208 |
+
expected = Security.SecIdentityGetTypeID()
|
| 209 |
+
return CoreFoundation.CFGetTypeID(item) == expected
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def _temporary_keychain():
|
| 213 |
+
"""
|
| 214 |
+
This function creates a temporary Mac keychain that we can use to work with
|
| 215 |
+
credentials. This keychain uses a one-time password and a temporary file to
|
| 216 |
+
store the data. We expect to have one keychain per socket. The returned
|
| 217 |
+
SecKeychainRef must be freed by the caller, including calling
|
| 218 |
+
SecKeychainDelete.
|
| 219 |
+
|
| 220 |
+
Returns a tuple of the SecKeychainRef and the path to the temporary
|
| 221 |
+
directory that contains it.
|
| 222 |
+
"""
|
| 223 |
+
# Unfortunately, SecKeychainCreate requires a path to a keychain. This
|
| 224 |
+
# means we cannot use mkstemp to use a generic temporary file. Instead,
|
| 225 |
+
# we're going to create a temporary directory and a filename to use there.
|
| 226 |
+
# This filename will be 8 random bytes expanded into base64. We also need
|
| 227 |
+
# some random bytes to password-protect the keychain we're creating, so we
|
| 228 |
+
# ask for 40 random bytes.
|
| 229 |
+
random_bytes = os.urandom(40)
|
| 230 |
+
filename = base64.b16encode(random_bytes[:8]).decode("utf-8")
|
| 231 |
+
password = base64.b16encode(random_bytes[8:]) # Must be valid UTF-8
|
| 232 |
+
tempdirectory = tempfile.mkdtemp()
|
| 233 |
+
|
| 234 |
+
keychain_path = os.path.join(tempdirectory, filename).encode("utf-8")
|
| 235 |
+
|
| 236 |
+
# We now want to create the keychain itself.
|
| 237 |
+
keychain = Security.SecKeychainRef()
|
| 238 |
+
status = Security.SecKeychainCreate(
|
| 239 |
+
keychain_path, len(password), password, False, None, ctypes.byref(keychain)
|
| 240 |
+
)
|
| 241 |
+
_assert_no_error(status)
|
| 242 |
+
|
| 243 |
+
# Having created the keychain, we want to pass it off to the caller.
|
| 244 |
+
return keychain, tempdirectory
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def _load_items_from_file(keychain, path):
|
| 248 |
+
"""
|
| 249 |
+
Given a single file, loads all the trust objects from it into arrays and
|
| 250 |
+
the keychain.
|
| 251 |
+
Returns a tuple of lists: the first list is a list of identities, the
|
| 252 |
+
second a list of certs.
|
| 253 |
+
"""
|
| 254 |
+
certificates = []
|
| 255 |
+
identities = []
|
| 256 |
+
result_array = None
|
| 257 |
+
|
| 258 |
+
with open(path, "rb") as f:
|
| 259 |
+
raw_filedata = f.read()
|
| 260 |
+
|
| 261 |
+
try:
|
| 262 |
+
filedata = CoreFoundation.CFDataCreate(
|
| 263 |
+
CoreFoundation.kCFAllocatorDefault, raw_filedata, len(raw_filedata)
|
| 264 |
+
)
|
| 265 |
+
result_array = CoreFoundation.CFArrayRef()
|
| 266 |
+
result = Security.SecItemImport(
|
| 267 |
+
filedata, # cert data
|
| 268 |
+
None, # Filename, leaving it out for now
|
| 269 |
+
None, # What the type of the file is, we don't care
|
| 270 |
+
None, # what's in the file, we don't care
|
| 271 |
+
0, # import flags
|
| 272 |
+
None, # key params, can include passphrase in the future
|
| 273 |
+
keychain, # The keychain to insert into
|
| 274 |
+
ctypes.byref(result_array), # Results
|
| 275 |
+
)
|
| 276 |
+
_assert_no_error(result)
|
| 277 |
+
|
| 278 |
+
# A CFArray is not very useful to us as an intermediary
|
| 279 |
+
# representation, so we are going to extract the objects we want
|
| 280 |
+
# and then free the array. We don't need to keep hold of keys: the
|
| 281 |
+
# keychain already has them!
|
| 282 |
+
result_count = CoreFoundation.CFArrayGetCount(result_array)
|
| 283 |
+
for index in range(result_count):
|
| 284 |
+
item = CoreFoundation.CFArrayGetValueAtIndex(result_array, index)
|
| 285 |
+
item = ctypes.cast(item, CoreFoundation.CFTypeRef)
|
| 286 |
+
|
| 287 |
+
if _is_cert(item):
|
| 288 |
+
CoreFoundation.CFRetain(item)
|
| 289 |
+
certificates.append(item)
|
| 290 |
+
elif _is_identity(item):
|
| 291 |
+
CoreFoundation.CFRetain(item)
|
| 292 |
+
identities.append(item)
|
| 293 |
+
finally:
|
| 294 |
+
if result_array:
|
| 295 |
+
CoreFoundation.CFRelease(result_array)
|
| 296 |
+
|
| 297 |
+
CoreFoundation.CFRelease(filedata)
|
| 298 |
+
|
| 299 |
+
return (identities, certificates)
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
def _load_client_cert_chain(keychain, *paths):
|
| 303 |
+
"""
|
| 304 |
+
Load certificates and maybe keys from a number of files. Has the end goal
|
| 305 |
+
of returning a CFArray containing one SecIdentityRef, and then zero or more
|
| 306 |
+
SecCertificateRef objects, suitable for use as a client certificate trust
|
| 307 |
+
chain.
|
| 308 |
+
"""
|
| 309 |
+
# Ok, the strategy.
|
| 310 |
+
#
|
| 311 |
+
# This relies on knowing that macOS will not give you a SecIdentityRef
|
| 312 |
+
# unless you have imported a key into a keychain. This is a somewhat
|
| 313 |
+
# artificial limitation of macOS (for example, it doesn't necessarily
|
| 314 |
+
# affect iOS), but there is nothing inside Security.framework that lets you
|
| 315 |
+
# get a SecIdentityRef without having a key in a keychain.
|
| 316 |
+
#
|
| 317 |
+
# So the policy here is we take all the files and iterate them in order.
|
| 318 |
+
# Each one will use SecItemImport to have one or more objects loaded from
|
| 319 |
+
# it. We will also point at a keychain that macOS can use to work with the
|
| 320 |
+
# private key.
|
| 321 |
+
#
|
| 322 |
+
# Once we have all the objects, we'll check what we actually have. If we
|
| 323 |
+
# already have a SecIdentityRef in hand, fab: we'll use that. Otherwise,
|
| 324 |
+
# we'll take the first certificate (which we assume to be our leaf) and
|
| 325 |
+
# ask the keychain to give us a SecIdentityRef with that cert's associated
|
| 326 |
+
# key.
|
| 327 |
+
#
|
| 328 |
+
# We'll then return a CFArray containing the trust chain: one
|
| 329 |
+
# SecIdentityRef and then zero-or-more SecCertificateRef objects. The
|
| 330 |
+
# responsibility for freeing this CFArray will be with the caller. This
|
| 331 |
+
# CFArray must remain alive for the entire connection, so in practice it
|
| 332 |
+
# will be stored with a single SSLSocket, along with the reference to the
|
| 333 |
+
# keychain.
|
| 334 |
+
certificates = []
|
| 335 |
+
identities = []
|
| 336 |
+
|
| 337 |
+
# Filter out bad paths.
|
| 338 |
+
paths = (path for path in paths if path)
|
| 339 |
+
|
| 340 |
+
try:
|
| 341 |
+
for file_path in paths:
|
| 342 |
+
new_identities, new_certs = _load_items_from_file(keychain, file_path)
|
| 343 |
+
identities.extend(new_identities)
|
| 344 |
+
certificates.extend(new_certs)
|
| 345 |
+
|
| 346 |
+
# Ok, we have everything. The question is: do we have an identity? If
|
| 347 |
+
# not, we want to grab one from the first cert we have.
|
| 348 |
+
if not identities:
|
| 349 |
+
new_identity = Security.SecIdentityRef()
|
| 350 |
+
status = Security.SecIdentityCreateWithCertificate(
|
| 351 |
+
keychain, certificates[0], ctypes.byref(new_identity)
|
| 352 |
+
)
|
| 353 |
+
_assert_no_error(status)
|
| 354 |
+
identities.append(new_identity)
|
| 355 |
+
|
| 356 |
+
# We now want to release the original certificate, as we no longer
|
| 357 |
+
# need it.
|
| 358 |
+
CoreFoundation.CFRelease(certificates.pop(0))
|
| 359 |
+
|
| 360 |
+
# We now need to build a new CFArray that holds the trust chain.
|
| 361 |
+
trust_chain = CoreFoundation.CFArrayCreateMutable(
|
| 362 |
+
CoreFoundation.kCFAllocatorDefault,
|
| 363 |
+
0,
|
| 364 |
+
ctypes.byref(CoreFoundation.kCFTypeArrayCallBacks),
|
| 365 |
+
)
|
| 366 |
+
for item in itertools.chain(identities, certificates):
|
| 367 |
+
# ArrayAppendValue does a CFRetain on the item. That's fine,
|
| 368 |
+
# because the finally block will release our other refs to them.
|
| 369 |
+
CoreFoundation.CFArrayAppendValue(trust_chain, item)
|
| 370 |
+
|
| 371 |
+
return trust_chain
|
| 372 |
+
finally:
|
| 373 |
+
for obj in itertools.chain(identities, certificates):
|
| 374 |
+
CoreFoundation.CFRelease(obj)
|
| 375 |
+
|
| 376 |
+
|
| 377 |
+
TLS_PROTOCOL_VERSIONS = {
|
| 378 |
+
"SSLv2": (0, 2),
|
| 379 |
+
"SSLv3": (3, 0),
|
| 380 |
+
"TLSv1": (3, 1),
|
| 381 |
+
"TLSv1.1": (3, 2),
|
| 382 |
+
"TLSv1.2": (3, 3),
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
def _build_tls_unknown_ca_alert(version):
|
| 387 |
+
"""
|
| 388 |
+
Builds a TLS alert record for an unknown CA.
|
| 389 |
+
"""
|
| 390 |
+
ver_maj, ver_min = TLS_PROTOCOL_VERSIONS[version]
|
| 391 |
+
severity_fatal = 0x02
|
| 392 |
+
description_unknown_ca = 0x30
|
| 393 |
+
msg = struct.pack(">BB", severity_fatal, description_unknown_ca)
|
| 394 |
+
msg_len = len(msg)
|
| 395 |
+
record_type_alert = 0x15
|
| 396 |
+
record = struct.pack(">BBBH", record_type_alert, ver_maj, ver_min, msg_len) + msg
|
| 397 |
+
return record
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/appengine.py
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This module provides a pool manager that uses Google App Engine's
|
| 3 |
+
`URLFetch Service <https://cloud.google.com/appengine/docs/python/urlfetch>`_.
|
| 4 |
+
|
| 5 |
+
Example usage::
|
| 6 |
+
|
| 7 |
+
from pip._vendor.urllib3 import PoolManager
|
| 8 |
+
from pip._vendor.urllib3.contrib.appengine import AppEngineManager, is_appengine_sandbox
|
| 9 |
+
|
| 10 |
+
if is_appengine_sandbox():
|
| 11 |
+
# AppEngineManager uses AppEngine's URLFetch API behind the scenes
|
| 12 |
+
http = AppEngineManager()
|
| 13 |
+
else:
|
| 14 |
+
# PoolManager uses a socket-level API behind the scenes
|
| 15 |
+
http = PoolManager()
|
| 16 |
+
|
| 17 |
+
r = http.request('GET', 'https://google.com/')
|
| 18 |
+
|
| 19 |
+
There are `limitations <https://cloud.google.com/appengine/docs/python/\
|
| 20 |
+
urlfetch/#Python_Quotas_and_limits>`_ to the URLFetch service and it may not be
|
| 21 |
+
the best choice for your application. There are three options for using
|
| 22 |
+
urllib3 on Google App Engine:
|
| 23 |
+
|
| 24 |
+
1. You can use :class:`AppEngineManager` with URLFetch. URLFetch is
|
| 25 |
+
cost-effective in many circumstances as long as your usage is within the
|
| 26 |
+
limitations.
|
| 27 |
+
2. You can use a normal :class:`~urllib3.PoolManager` by enabling sockets.
|
| 28 |
+
Sockets also have `limitations and restrictions
|
| 29 |
+
<https://cloud.google.com/appengine/docs/python/sockets/\
|
| 30 |
+
#limitations-and-restrictions>`_ and have a lower free quota than URLFetch.
|
| 31 |
+
To use sockets, be sure to specify the following in your ``app.yaml``::
|
| 32 |
+
|
| 33 |
+
env_variables:
|
| 34 |
+
GAE_USE_SOCKETS_HTTPLIB : 'true'
|
| 35 |
+
|
| 36 |
+
3. If you are using `App Engine Flexible
|
| 37 |
+
<https://cloud.google.com/appengine/docs/flexible/>`_, you can use the standard
|
| 38 |
+
:class:`PoolManager` without any configuration or special environment variables.
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
from __future__ import absolute_import
|
| 42 |
+
|
| 43 |
+
import io
|
| 44 |
+
import logging
|
| 45 |
+
import warnings
|
| 46 |
+
|
| 47 |
+
from ..exceptions import (
|
| 48 |
+
HTTPError,
|
| 49 |
+
HTTPWarning,
|
| 50 |
+
MaxRetryError,
|
| 51 |
+
ProtocolError,
|
| 52 |
+
SSLError,
|
| 53 |
+
TimeoutError,
|
| 54 |
+
)
|
| 55 |
+
from ..packages.six.moves.urllib.parse import urljoin
|
| 56 |
+
from ..request import RequestMethods
|
| 57 |
+
from ..response import HTTPResponse
|
| 58 |
+
from ..util.retry import Retry
|
| 59 |
+
from ..util.timeout import Timeout
|
| 60 |
+
from . import _appengine_environ
|
| 61 |
+
|
| 62 |
+
try:
|
| 63 |
+
from google.appengine.api import urlfetch
|
| 64 |
+
except ImportError:
|
| 65 |
+
urlfetch = None
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
log = logging.getLogger(__name__)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class AppEnginePlatformWarning(HTTPWarning):
|
| 72 |
+
pass
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class AppEnginePlatformError(HTTPError):
|
| 76 |
+
pass
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class AppEngineManager(RequestMethods):
|
| 80 |
+
"""
|
| 81 |
+
Connection manager for Google App Engine sandbox applications.
|
| 82 |
+
|
| 83 |
+
This manager uses the URLFetch service directly instead of using the
|
| 84 |
+
emulated httplib, and is subject to URLFetch limitations as described in
|
| 85 |
+
the App Engine documentation `here
|
| 86 |
+
<https://cloud.google.com/appengine/docs/python/urlfetch>`_.
|
| 87 |
+
|
| 88 |
+
Notably it will raise an :class:`AppEnginePlatformError` if:
|
| 89 |
+
* URLFetch is not available.
|
| 90 |
+
* If you attempt to use this on App Engine Flexible, as full socket
|
| 91 |
+
support is available.
|
| 92 |
+
* If a request size is more than 10 megabytes.
|
| 93 |
+
* If a response size is more than 32 megabytes.
|
| 94 |
+
* If you use an unsupported request method such as OPTIONS.
|
| 95 |
+
|
| 96 |
+
Beyond those cases, it will raise normal urllib3 errors.
|
| 97 |
+
"""
|
| 98 |
+
|
| 99 |
+
def __init__(
|
| 100 |
+
self,
|
| 101 |
+
headers=None,
|
| 102 |
+
retries=None,
|
| 103 |
+
validate_certificate=True,
|
| 104 |
+
urlfetch_retries=True,
|
| 105 |
+
):
|
| 106 |
+
if not urlfetch:
|
| 107 |
+
raise AppEnginePlatformError(
|
| 108 |
+
"URLFetch is not available in this environment."
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
warnings.warn(
|
| 112 |
+
"urllib3 is using URLFetch on Google App Engine sandbox instead "
|
| 113 |
+
"of sockets. To use sockets directly instead of URLFetch see "
|
| 114 |
+
"https://urllib3.readthedocs.io/en/1.26.x/reference/urllib3.contrib.html.",
|
| 115 |
+
AppEnginePlatformWarning,
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
RequestMethods.__init__(self, headers)
|
| 119 |
+
self.validate_certificate = validate_certificate
|
| 120 |
+
self.urlfetch_retries = urlfetch_retries
|
| 121 |
+
|
| 122 |
+
self.retries = retries or Retry.DEFAULT
|
| 123 |
+
|
| 124 |
+
def __enter__(self):
|
| 125 |
+
return self
|
| 126 |
+
|
| 127 |
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
| 128 |
+
# Return False to re-raise any potential exceptions
|
| 129 |
+
return False
|
| 130 |
+
|
| 131 |
+
def urlopen(
|
| 132 |
+
self,
|
| 133 |
+
method,
|
| 134 |
+
url,
|
| 135 |
+
body=None,
|
| 136 |
+
headers=None,
|
| 137 |
+
retries=None,
|
| 138 |
+
redirect=True,
|
| 139 |
+
timeout=Timeout.DEFAULT_TIMEOUT,
|
| 140 |
+
**response_kw
|
| 141 |
+
):
|
| 142 |
+
|
| 143 |
+
retries = self._get_retries(retries, redirect)
|
| 144 |
+
|
| 145 |
+
try:
|
| 146 |
+
follow_redirects = redirect and retries.redirect != 0 and retries.total
|
| 147 |
+
response = urlfetch.fetch(
|
| 148 |
+
url,
|
| 149 |
+
payload=body,
|
| 150 |
+
method=method,
|
| 151 |
+
headers=headers or {},
|
| 152 |
+
allow_truncated=False,
|
| 153 |
+
follow_redirects=self.urlfetch_retries and follow_redirects,
|
| 154 |
+
deadline=self._get_absolute_timeout(timeout),
|
| 155 |
+
validate_certificate=self.validate_certificate,
|
| 156 |
+
)
|
| 157 |
+
except urlfetch.DeadlineExceededError as e:
|
| 158 |
+
raise TimeoutError(self, e)
|
| 159 |
+
|
| 160 |
+
except urlfetch.InvalidURLError as e:
|
| 161 |
+
if "too large" in str(e):
|
| 162 |
+
raise AppEnginePlatformError(
|
| 163 |
+
"URLFetch request too large, URLFetch only "
|
| 164 |
+
"supports requests up to 10mb in size.",
|
| 165 |
+
e,
|
| 166 |
+
)
|
| 167 |
+
raise ProtocolError(e)
|
| 168 |
+
|
| 169 |
+
except urlfetch.DownloadError as e:
|
| 170 |
+
if "Too many redirects" in str(e):
|
| 171 |
+
raise MaxRetryError(self, url, reason=e)
|
| 172 |
+
raise ProtocolError(e)
|
| 173 |
+
|
| 174 |
+
except urlfetch.ResponseTooLargeError as e:
|
| 175 |
+
raise AppEnginePlatformError(
|
| 176 |
+
"URLFetch response too large, URLFetch only supports"
|
| 177 |
+
"responses up to 32mb in size.",
|
| 178 |
+
e,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
except urlfetch.SSLCertificateError as e:
|
| 182 |
+
raise SSLError(e)
|
| 183 |
+
|
| 184 |
+
except urlfetch.InvalidMethodError as e:
|
| 185 |
+
raise AppEnginePlatformError(
|
| 186 |
+
"URLFetch does not support method: %s" % method, e
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
http_response = self._urlfetch_response_to_http_response(
|
| 190 |
+
response, retries=retries, **response_kw
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
# Handle redirect?
|
| 194 |
+
redirect_location = redirect and http_response.get_redirect_location()
|
| 195 |
+
if redirect_location:
|
| 196 |
+
# Check for redirect response
|
| 197 |
+
if self.urlfetch_retries and retries.raise_on_redirect:
|
| 198 |
+
raise MaxRetryError(self, url, "too many redirects")
|
| 199 |
+
else:
|
| 200 |
+
if http_response.status == 303:
|
| 201 |
+
method = "GET"
|
| 202 |
+
|
| 203 |
+
try:
|
| 204 |
+
retries = retries.increment(
|
| 205 |
+
method, url, response=http_response, _pool=self
|
| 206 |
+
)
|
| 207 |
+
except MaxRetryError:
|
| 208 |
+
if retries.raise_on_redirect:
|
| 209 |
+
raise MaxRetryError(self, url, "too many redirects")
|
| 210 |
+
return http_response
|
| 211 |
+
|
| 212 |
+
retries.sleep_for_retry(http_response)
|
| 213 |
+
log.debug("Redirecting %s -> %s", url, redirect_location)
|
| 214 |
+
redirect_url = urljoin(url, redirect_location)
|
| 215 |
+
return self.urlopen(
|
| 216 |
+
method,
|
| 217 |
+
redirect_url,
|
| 218 |
+
body,
|
| 219 |
+
headers,
|
| 220 |
+
retries=retries,
|
| 221 |
+
redirect=redirect,
|
| 222 |
+
timeout=timeout,
|
| 223 |
+
**response_kw
|
| 224 |
+
)
|
| 225 |
+
|
| 226 |
+
# Check if we should retry the HTTP response.
|
| 227 |
+
has_retry_after = bool(http_response.headers.get("Retry-After"))
|
| 228 |
+
if retries.is_retry(method, http_response.status, has_retry_after):
|
| 229 |
+
retries = retries.increment(method, url, response=http_response, _pool=self)
|
| 230 |
+
log.debug("Retry: %s", url)
|
| 231 |
+
retries.sleep(http_response)
|
| 232 |
+
return self.urlopen(
|
| 233 |
+
method,
|
| 234 |
+
url,
|
| 235 |
+
body=body,
|
| 236 |
+
headers=headers,
|
| 237 |
+
retries=retries,
|
| 238 |
+
redirect=redirect,
|
| 239 |
+
timeout=timeout,
|
| 240 |
+
**response_kw
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
return http_response
|
| 244 |
+
|
| 245 |
+
def _urlfetch_response_to_http_response(self, urlfetch_resp, **response_kw):
|
| 246 |
+
|
| 247 |
+
if is_prod_appengine():
|
| 248 |
+
# Production GAE handles deflate encoding automatically, but does
|
| 249 |
+
# not remove the encoding header.
|
| 250 |
+
content_encoding = urlfetch_resp.headers.get("content-encoding")
|
| 251 |
+
|
| 252 |
+
if content_encoding == "deflate":
|
| 253 |
+
del urlfetch_resp.headers["content-encoding"]
|
| 254 |
+
|
| 255 |
+
transfer_encoding = urlfetch_resp.headers.get("transfer-encoding")
|
| 256 |
+
# We have a full response's content,
|
| 257 |
+
# so let's make sure we don't report ourselves as chunked data.
|
| 258 |
+
if transfer_encoding == "chunked":
|
| 259 |
+
encodings = transfer_encoding.split(",")
|
| 260 |
+
encodings.remove("chunked")
|
| 261 |
+
urlfetch_resp.headers["transfer-encoding"] = ",".join(encodings)
|
| 262 |
+
|
| 263 |
+
original_response = HTTPResponse(
|
| 264 |
+
# In order for decoding to work, we must present the content as
|
| 265 |
+
# a file-like object.
|
| 266 |
+
body=io.BytesIO(urlfetch_resp.content),
|
| 267 |
+
msg=urlfetch_resp.header_msg,
|
| 268 |
+
headers=urlfetch_resp.headers,
|
| 269 |
+
status=urlfetch_resp.status_code,
|
| 270 |
+
**response_kw
|
| 271 |
+
)
|
| 272 |
+
|
| 273 |
+
return HTTPResponse(
|
| 274 |
+
body=io.BytesIO(urlfetch_resp.content),
|
| 275 |
+
headers=urlfetch_resp.headers,
|
| 276 |
+
status=urlfetch_resp.status_code,
|
| 277 |
+
original_response=original_response,
|
| 278 |
+
**response_kw
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
def _get_absolute_timeout(self, timeout):
|
| 282 |
+
if timeout is Timeout.DEFAULT_TIMEOUT:
|
| 283 |
+
return None # Defer to URLFetch's default.
|
| 284 |
+
if isinstance(timeout, Timeout):
|
| 285 |
+
if timeout._read is not None or timeout._connect is not None:
|
| 286 |
+
warnings.warn(
|
| 287 |
+
"URLFetch does not support granular timeout settings, "
|
| 288 |
+
"reverting to total or default URLFetch timeout.",
|
| 289 |
+
AppEnginePlatformWarning,
|
| 290 |
+
)
|
| 291 |
+
return timeout.total
|
| 292 |
+
return timeout
|
| 293 |
+
|
| 294 |
+
def _get_retries(self, retries, redirect):
|
| 295 |
+
if not isinstance(retries, Retry):
|
| 296 |
+
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
|
| 297 |
+
|
| 298 |
+
if retries.connect or retries.read or retries.redirect:
|
| 299 |
+
warnings.warn(
|
| 300 |
+
"URLFetch only supports total retries and does not "
|
| 301 |
+
"recognize connect, read, or redirect retry parameters.",
|
| 302 |
+
AppEnginePlatformWarning,
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
return retries
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
# Alias methods from _appengine_environ to maintain public API interface.
|
| 309 |
+
|
| 310 |
+
is_appengine = _appengine_environ.is_appengine
|
| 311 |
+
is_appengine_sandbox = _appengine_environ.is_appengine_sandbox
|
| 312 |
+
is_local_appengine = _appengine_environ.is_local_appengine
|
| 313 |
+
is_prod_appengine = _appengine_environ.is_prod_appengine
|
| 314 |
+
is_prod_appengine_mvms = _appengine_environ.is_prod_appengine_mvms
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
NTLM authenticating pool, contributed by erikcederstran
|
| 3 |
+
|
| 4 |
+
Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10
|
| 5 |
+
"""
|
| 6 |
+
from __future__ import absolute_import
|
| 7 |
+
|
| 8 |
+
import warnings
|
| 9 |
+
from logging import getLogger
|
| 10 |
+
|
| 11 |
+
from ntlm import ntlm
|
| 12 |
+
|
| 13 |
+
from .. import HTTPSConnectionPool
|
| 14 |
+
from ..packages.six.moves.http_client import HTTPSConnection
|
| 15 |
+
|
| 16 |
+
warnings.warn(
|
| 17 |
+
"The 'urllib3.contrib.ntlmpool' module is deprecated and will be removed "
|
| 18 |
+
"in urllib3 v2.0 release, urllib3 is not able to support it properly due "
|
| 19 |
+
"to reasons listed in issue: https://github.com/urllib3/urllib3/issues/2282. "
|
| 20 |
+
"If you are a user of this module please comment in the mentioned issue.",
|
| 21 |
+
DeprecationWarning,
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
log = getLogger(__name__)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class NTLMConnectionPool(HTTPSConnectionPool):
|
| 28 |
+
"""
|
| 29 |
+
Implements an NTLM authentication version of an urllib3 connection pool
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
scheme = "https"
|
| 33 |
+
|
| 34 |
+
def __init__(self, user, pw, authurl, *args, **kwargs):
|
| 35 |
+
"""
|
| 36 |
+
authurl is a random URL on the server that is protected by NTLM.
|
| 37 |
+
user is the Windows user, probably in the DOMAIN\\username format.
|
| 38 |
+
pw is the password for the user.
|
| 39 |
+
"""
|
| 40 |
+
super(NTLMConnectionPool, self).__init__(*args, **kwargs)
|
| 41 |
+
self.authurl = authurl
|
| 42 |
+
self.rawuser = user
|
| 43 |
+
user_parts = user.split("\\", 1)
|
| 44 |
+
self.domain = user_parts[0].upper()
|
| 45 |
+
self.user = user_parts[1]
|
| 46 |
+
self.pw = pw
|
| 47 |
+
|
| 48 |
+
def _new_conn(self):
|
| 49 |
+
# Performs the NTLM handshake that secures the connection. The socket
|
| 50 |
+
# must be kept open while requests are performed.
|
| 51 |
+
self.num_connections += 1
|
| 52 |
+
log.debug(
|
| 53 |
+
"Starting NTLM HTTPS connection no. %d: https://%s%s",
|
| 54 |
+
self.num_connections,
|
| 55 |
+
self.host,
|
| 56 |
+
self.authurl,
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
headers = {"Connection": "Keep-Alive"}
|
| 60 |
+
req_header = "Authorization"
|
| 61 |
+
resp_header = "www-authenticate"
|
| 62 |
+
|
| 63 |
+
conn = HTTPSConnection(host=self.host, port=self.port)
|
| 64 |
+
|
| 65 |
+
# Send negotiation message
|
| 66 |
+
headers[req_header] = "NTLM %s" % ntlm.create_NTLM_NEGOTIATE_MESSAGE(
|
| 67 |
+
self.rawuser
|
| 68 |
+
)
|
| 69 |
+
log.debug("Request headers: %s", headers)
|
| 70 |
+
conn.request("GET", self.authurl, None, headers)
|
| 71 |
+
res = conn.getresponse()
|
| 72 |
+
reshdr = dict(res.headers)
|
| 73 |
+
log.debug("Response status: %s %s", res.status, res.reason)
|
| 74 |
+
log.debug("Response headers: %s", reshdr)
|
| 75 |
+
log.debug("Response data: %s [...]", res.read(100))
|
| 76 |
+
|
| 77 |
+
# Remove the reference to the socket, so that it can not be closed by
|
| 78 |
+
# the response object (we want to keep the socket open)
|
| 79 |
+
res.fp = None
|
| 80 |
+
|
| 81 |
+
# Server should respond with a challenge message
|
| 82 |
+
auth_header_values = reshdr[resp_header].split(", ")
|
| 83 |
+
auth_header_value = None
|
| 84 |
+
for s in auth_header_values:
|
| 85 |
+
if s[:5] == "NTLM ":
|
| 86 |
+
auth_header_value = s[5:]
|
| 87 |
+
if auth_header_value is None:
|
| 88 |
+
raise Exception(
|
| 89 |
+
"Unexpected %s response header: %s" % (resp_header, reshdr[resp_header])
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
# Send authentication message
|
| 93 |
+
ServerChallenge, NegotiateFlags = ntlm.parse_NTLM_CHALLENGE_MESSAGE(
|
| 94 |
+
auth_header_value
|
| 95 |
+
)
|
| 96 |
+
auth_msg = ntlm.create_NTLM_AUTHENTICATE_MESSAGE(
|
| 97 |
+
ServerChallenge, self.user, self.domain, self.pw, NegotiateFlags
|
| 98 |
+
)
|
| 99 |
+
headers[req_header] = "NTLM %s" % auth_msg
|
| 100 |
+
log.debug("Request headers: %s", headers)
|
| 101 |
+
conn.request("GET", self.authurl, None, headers)
|
| 102 |
+
res = conn.getresponse()
|
| 103 |
+
log.debug("Response status: %s %s", res.status, res.reason)
|
| 104 |
+
log.debug("Response headers: %s", dict(res.headers))
|
| 105 |
+
log.debug("Response data: %s [...]", res.read()[:100])
|
| 106 |
+
if res.status != 200:
|
| 107 |
+
if res.status == 401:
|
| 108 |
+
raise Exception("Server rejected request: wrong username or password")
|
| 109 |
+
raise Exception("Wrong server response: %s %s" % (res.status, res.reason))
|
| 110 |
+
|
| 111 |
+
res.fp = None
|
| 112 |
+
log.debug("Connection established")
|
| 113 |
+
return conn
|
| 114 |
+
|
| 115 |
+
def urlopen(
|
| 116 |
+
self,
|
| 117 |
+
method,
|
| 118 |
+
url,
|
| 119 |
+
body=None,
|
| 120 |
+
headers=None,
|
| 121 |
+
retries=3,
|
| 122 |
+
redirect=True,
|
| 123 |
+
assert_same_host=True,
|
| 124 |
+
):
|
| 125 |
+
if headers is None:
|
| 126 |
+
headers = {}
|
| 127 |
+
headers["Connection"] = "Keep-Alive"
|
| 128 |
+
return super(NTLMConnectionPool, self).urlopen(
|
| 129 |
+
method, url, body, headers, retries, redirect, assert_same_host
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
TLS with SNI_-support for Python 2. Follow these instructions if you would
|
| 3 |
+
like to verify TLS certificates in Python 2. Note, the default libraries do
|
| 4 |
+
*not* do certificate checking; you need to do additional work to validate
|
| 5 |
+
certificates yourself.
|
| 6 |
+
|
| 7 |
+
This needs the following packages installed:
|
| 8 |
+
|
| 9 |
+
* `pyOpenSSL`_ (tested with 16.0.0)
|
| 10 |
+
* `cryptography`_ (minimum 1.3.4, from pyopenssl)
|
| 11 |
+
* `idna`_ (minimum 2.0, from cryptography)
|
| 12 |
+
|
| 13 |
+
However, pyopenssl depends on cryptography, which depends on idna, so while we
|
| 14 |
+
use all three directly here we end up having relatively few packages required.
|
| 15 |
+
|
| 16 |
+
You can install them with the following command:
|
| 17 |
+
|
| 18 |
+
.. code-block:: bash
|
| 19 |
+
|
| 20 |
+
$ python -m pip install pyopenssl cryptography idna
|
| 21 |
+
|
| 22 |
+
To activate certificate checking, call
|
| 23 |
+
:func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code
|
| 24 |
+
before you begin making HTTP requests. This can be done in a ``sitecustomize``
|
| 25 |
+
module, or at any other time before your application begins using ``urllib3``,
|
| 26 |
+
like this:
|
| 27 |
+
|
| 28 |
+
.. code-block:: python
|
| 29 |
+
|
| 30 |
+
try:
|
| 31 |
+
import pip._vendor.urllib3.contrib.pyopenssl as pyopenssl
|
| 32 |
+
pyopenssl.inject_into_urllib3()
|
| 33 |
+
except ImportError:
|
| 34 |
+
pass
|
| 35 |
+
|
| 36 |
+
Now you can use :mod:`urllib3` as you normally would, and it will support SNI
|
| 37 |
+
when the required modules are installed.
|
| 38 |
+
|
| 39 |
+
Activating this module also has the positive side effect of disabling SSL/TLS
|
| 40 |
+
compression in Python 2 (see `CRIME attack`_).
|
| 41 |
+
|
| 42 |
+
.. _sni: https://en.wikipedia.org/wiki/Server_Name_Indication
|
| 43 |
+
.. _crime attack: https://en.wikipedia.org/wiki/CRIME_(security_exploit)
|
| 44 |
+
.. _pyopenssl: https://www.pyopenssl.org
|
| 45 |
+
.. _cryptography: https://cryptography.io
|
| 46 |
+
.. _idna: https://github.com/kjd/idna
|
| 47 |
+
"""
|
| 48 |
+
from __future__ import absolute_import
|
| 49 |
+
|
| 50 |
+
import OpenSSL.crypto
|
| 51 |
+
import OpenSSL.SSL
|
| 52 |
+
from cryptography import x509
|
| 53 |
+
from cryptography.hazmat.backends.openssl import backend as openssl_backend
|
| 54 |
+
|
| 55 |
+
try:
|
| 56 |
+
from cryptography.x509 import UnsupportedExtension
|
| 57 |
+
except ImportError:
|
| 58 |
+
# UnsupportedExtension is gone in cryptography >= 2.1.0
|
| 59 |
+
class UnsupportedExtension(Exception):
|
| 60 |
+
pass
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
from io import BytesIO
|
| 64 |
+
from socket import error as SocketError
|
| 65 |
+
from socket import timeout
|
| 66 |
+
|
| 67 |
+
try: # Platform-specific: Python 2
|
| 68 |
+
from socket import _fileobject
|
| 69 |
+
except ImportError: # Platform-specific: Python 3
|
| 70 |
+
_fileobject = None
|
| 71 |
+
from ..packages.backports.makefile import backport_makefile
|
| 72 |
+
|
| 73 |
+
import logging
|
| 74 |
+
import ssl
|
| 75 |
+
import sys
|
| 76 |
+
import warnings
|
| 77 |
+
|
| 78 |
+
from .. import util
|
| 79 |
+
from ..packages import six
|
| 80 |
+
from ..util.ssl_ import PROTOCOL_TLS_CLIENT
|
| 81 |
+
|
| 82 |
+
warnings.warn(
|
| 83 |
+
"'urllib3.contrib.pyopenssl' module is deprecated and will be removed "
|
| 84 |
+
"in a future release of urllib3 2.x. Read more in this issue: "
|
| 85 |
+
"https://github.com/urllib3/urllib3/issues/2680",
|
| 86 |
+
category=DeprecationWarning,
|
| 87 |
+
stacklevel=2,
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
__all__ = ["inject_into_urllib3", "extract_from_urllib3"]
|
| 91 |
+
|
| 92 |
+
# SNI always works.
|
| 93 |
+
HAS_SNI = True
|
| 94 |
+
|
| 95 |
+
# Map from urllib3 to PyOpenSSL compatible parameter-values.
|
| 96 |
+
_openssl_versions = {
|
| 97 |
+
util.PROTOCOL_TLS: OpenSSL.SSL.SSLv23_METHOD,
|
| 98 |
+
PROTOCOL_TLS_CLIENT: OpenSSL.SSL.SSLv23_METHOD,
|
| 99 |
+
ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD,
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
if hasattr(ssl, "PROTOCOL_SSLv3") and hasattr(OpenSSL.SSL, "SSLv3_METHOD"):
|
| 103 |
+
_openssl_versions[ssl.PROTOCOL_SSLv3] = OpenSSL.SSL.SSLv3_METHOD
|
| 104 |
+
|
| 105 |
+
if hasattr(ssl, "PROTOCOL_TLSv1_1") and hasattr(OpenSSL.SSL, "TLSv1_1_METHOD"):
|
| 106 |
+
_openssl_versions[ssl.PROTOCOL_TLSv1_1] = OpenSSL.SSL.TLSv1_1_METHOD
|
| 107 |
+
|
| 108 |
+
if hasattr(ssl, "PROTOCOL_TLSv1_2") and hasattr(OpenSSL.SSL, "TLSv1_2_METHOD"):
|
| 109 |
+
_openssl_versions[ssl.PROTOCOL_TLSv1_2] = OpenSSL.SSL.TLSv1_2_METHOD
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
_stdlib_to_openssl_verify = {
|
| 113 |
+
ssl.CERT_NONE: OpenSSL.SSL.VERIFY_NONE,
|
| 114 |
+
ssl.CERT_OPTIONAL: OpenSSL.SSL.VERIFY_PEER,
|
| 115 |
+
ssl.CERT_REQUIRED: OpenSSL.SSL.VERIFY_PEER
|
| 116 |
+
+ OpenSSL.SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
|
| 117 |
+
}
|
| 118 |
+
_openssl_to_stdlib_verify = dict((v, k) for k, v in _stdlib_to_openssl_verify.items())
|
| 119 |
+
|
| 120 |
+
# OpenSSL will only write 16K at a time
|
| 121 |
+
SSL_WRITE_BLOCKSIZE = 16384
|
| 122 |
+
|
| 123 |
+
orig_util_HAS_SNI = util.HAS_SNI
|
| 124 |
+
orig_util_SSLContext = util.ssl_.SSLContext
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
log = logging.getLogger(__name__)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def inject_into_urllib3():
|
| 131 |
+
"Monkey-patch urllib3 with PyOpenSSL-backed SSL-support."
|
| 132 |
+
|
| 133 |
+
_validate_dependencies_met()
|
| 134 |
+
|
| 135 |
+
util.SSLContext = PyOpenSSLContext
|
| 136 |
+
util.ssl_.SSLContext = PyOpenSSLContext
|
| 137 |
+
util.HAS_SNI = HAS_SNI
|
| 138 |
+
util.ssl_.HAS_SNI = HAS_SNI
|
| 139 |
+
util.IS_PYOPENSSL = True
|
| 140 |
+
util.ssl_.IS_PYOPENSSL = True
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def extract_from_urllib3():
|
| 144 |
+
"Undo monkey-patching by :func:`inject_into_urllib3`."
|
| 145 |
+
|
| 146 |
+
util.SSLContext = orig_util_SSLContext
|
| 147 |
+
util.ssl_.SSLContext = orig_util_SSLContext
|
| 148 |
+
util.HAS_SNI = orig_util_HAS_SNI
|
| 149 |
+
util.ssl_.HAS_SNI = orig_util_HAS_SNI
|
| 150 |
+
util.IS_PYOPENSSL = False
|
| 151 |
+
util.ssl_.IS_PYOPENSSL = False
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def _validate_dependencies_met():
|
| 155 |
+
"""
|
| 156 |
+
Verifies that PyOpenSSL's package-level dependencies have been met.
|
| 157 |
+
Throws `ImportError` if they are not met.
|
| 158 |
+
"""
|
| 159 |
+
# Method added in `cryptography==1.1`; not available in older versions
|
| 160 |
+
from cryptography.x509.extensions import Extensions
|
| 161 |
+
|
| 162 |
+
if getattr(Extensions, "get_extension_for_class", None) is None:
|
| 163 |
+
raise ImportError(
|
| 164 |
+
"'cryptography' module missing required functionality. "
|
| 165 |
+
"Try upgrading to v1.3.4 or newer."
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
# pyOpenSSL 0.14 and above use cryptography for OpenSSL bindings. The _x509
|
| 169 |
+
# attribute is only present on those versions.
|
| 170 |
+
from OpenSSL.crypto import X509
|
| 171 |
+
|
| 172 |
+
x509 = X509()
|
| 173 |
+
if getattr(x509, "_x509", None) is None:
|
| 174 |
+
raise ImportError(
|
| 175 |
+
"'pyOpenSSL' module missing required functionality. "
|
| 176 |
+
"Try upgrading to v0.14 or newer."
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def _dnsname_to_stdlib(name):
|
| 181 |
+
"""
|
| 182 |
+
Converts a dNSName SubjectAlternativeName field to the form used by the
|
| 183 |
+
standard library on the given Python version.
|
| 184 |
+
|
| 185 |
+
Cryptography produces a dNSName as a unicode string that was idna-decoded
|
| 186 |
+
from ASCII bytes. We need to idna-encode that string to get it back, and
|
| 187 |
+
then on Python 3 we also need to convert to unicode via UTF-8 (the stdlib
|
| 188 |
+
uses PyUnicode_FromStringAndSize on it, which decodes via UTF-8).
|
| 189 |
+
|
| 190 |
+
If the name cannot be idna-encoded then we return None signalling that
|
| 191 |
+
the name given should be skipped.
|
| 192 |
+
"""
|
| 193 |
+
|
| 194 |
+
def idna_encode(name):
|
| 195 |
+
"""
|
| 196 |
+
Borrowed wholesale from the Python Cryptography Project. It turns out
|
| 197 |
+
that we can't just safely call `idna.encode`: it can explode for
|
| 198 |
+
wildcard names. This avoids that problem.
|
| 199 |
+
"""
|
| 200 |
+
from pip._vendor import idna
|
| 201 |
+
|
| 202 |
+
try:
|
| 203 |
+
for prefix in [u"*.", u"."]:
|
| 204 |
+
if name.startswith(prefix):
|
| 205 |
+
name = name[len(prefix) :]
|
| 206 |
+
return prefix.encode("ascii") + idna.encode(name)
|
| 207 |
+
return idna.encode(name)
|
| 208 |
+
except idna.core.IDNAError:
|
| 209 |
+
return None
|
| 210 |
+
|
| 211 |
+
# Don't send IPv6 addresses through the IDNA encoder.
|
| 212 |
+
if ":" in name:
|
| 213 |
+
return name
|
| 214 |
+
|
| 215 |
+
name = idna_encode(name)
|
| 216 |
+
if name is None:
|
| 217 |
+
return None
|
| 218 |
+
elif sys.version_info >= (3, 0):
|
| 219 |
+
name = name.decode("utf-8")
|
| 220 |
+
return name
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def get_subj_alt_name(peer_cert):
|
| 224 |
+
"""
|
| 225 |
+
Given an PyOpenSSL certificate, provides all the subject alternative names.
|
| 226 |
+
"""
|
| 227 |
+
# Pass the cert to cryptography, which has much better APIs for this.
|
| 228 |
+
if hasattr(peer_cert, "to_cryptography"):
|
| 229 |
+
cert = peer_cert.to_cryptography()
|
| 230 |
+
else:
|
| 231 |
+
der = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_ASN1, peer_cert)
|
| 232 |
+
cert = x509.load_der_x509_certificate(der, openssl_backend)
|
| 233 |
+
|
| 234 |
+
# We want to find the SAN extension. Ask Cryptography to locate it (it's
|
| 235 |
+
# faster than looping in Python)
|
| 236 |
+
try:
|
| 237 |
+
ext = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName).value
|
| 238 |
+
except x509.ExtensionNotFound:
|
| 239 |
+
# No such extension, return the empty list.
|
| 240 |
+
return []
|
| 241 |
+
except (
|
| 242 |
+
x509.DuplicateExtension,
|
| 243 |
+
UnsupportedExtension,
|
| 244 |
+
x509.UnsupportedGeneralNameType,
|
| 245 |
+
UnicodeError,
|
| 246 |
+
) as e:
|
| 247 |
+
# A problem has been found with the quality of the certificate. Assume
|
| 248 |
+
# no SAN field is present.
|
| 249 |
+
log.warning(
|
| 250 |
+
"A problem was encountered with the certificate that prevented "
|
| 251 |
+
"urllib3 from finding the SubjectAlternativeName field. This can "
|
| 252 |
+
"affect certificate validation. The error was %s",
|
| 253 |
+
e,
|
| 254 |
+
)
|
| 255 |
+
return []
|
| 256 |
+
|
| 257 |
+
# We want to return dNSName and iPAddress fields. We need to cast the IPs
|
| 258 |
+
# back to strings because the match_hostname function wants them as
|
| 259 |
+
# strings.
|
| 260 |
+
# Sadly the DNS names need to be idna encoded and then, on Python 3, UTF-8
|
| 261 |
+
# decoded. This is pretty frustrating, but that's what the standard library
|
| 262 |
+
# does with certificates, and so we need to attempt to do the same.
|
| 263 |
+
# We also want to skip over names which cannot be idna encoded.
|
| 264 |
+
names = [
|
| 265 |
+
("DNS", name)
|
| 266 |
+
for name in map(_dnsname_to_stdlib, ext.get_values_for_type(x509.DNSName))
|
| 267 |
+
if name is not None
|
| 268 |
+
]
|
| 269 |
+
names.extend(
|
| 270 |
+
("IP Address", str(name)) for name in ext.get_values_for_type(x509.IPAddress)
|
| 271 |
+
)
|
| 272 |
+
|
| 273 |
+
return names
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
class WrappedSocket(object):
|
| 277 |
+
"""API-compatibility wrapper for Python OpenSSL's Connection-class.
|
| 278 |
+
|
| 279 |
+
Note: _makefile_refs, _drop() and _reuse() are needed for the garbage
|
| 280 |
+
collector of pypy.
|
| 281 |
+
"""
|
| 282 |
+
|
| 283 |
+
def __init__(self, connection, socket, suppress_ragged_eofs=True):
|
| 284 |
+
self.connection = connection
|
| 285 |
+
self.socket = socket
|
| 286 |
+
self.suppress_ragged_eofs = suppress_ragged_eofs
|
| 287 |
+
self._makefile_refs = 0
|
| 288 |
+
self._closed = False
|
| 289 |
+
|
| 290 |
+
def fileno(self):
|
| 291 |
+
return self.socket.fileno()
|
| 292 |
+
|
| 293 |
+
# Copy-pasted from Python 3.5 source code
|
| 294 |
+
def _decref_socketios(self):
|
| 295 |
+
if self._makefile_refs > 0:
|
| 296 |
+
self._makefile_refs -= 1
|
| 297 |
+
if self._closed:
|
| 298 |
+
self.close()
|
| 299 |
+
|
| 300 |
+
def recv(self, *args, **kwargs):
|
| 301 |
+
try:
|
| 302 |
+
data = self.connection.recv(*args, **kwargs)
|
| 303 |
+
except OpenSSL.SSL.SysCallError as e:
|
| 304 |
+
if self.suppress_ragged_eofs and e.args == (-1, "Unexpected EOF"):
|
| 305 |
+
return b""
|
| 306 |
+
else:
|
| 307 |
+
raise SocketError(str(e))
|
| 308 |
+
except OpenSSL.SSL.ZeroReturnError:
|
| 309 |
+
if self.connection.get_shutdown() == OpenSSL.SSL.RECEIVED_SHUTDOWN:
|
| 310 |
+
return b""
|
| 311 |
+
else:
|
| 312 |
+
raise
|
| 313 |
+
except OpenSSL.SSL.WantReadError:
|
| 314 |
+
if not util.wait_for_read(self.socket, self.socket.gettimeout()):
|
| 315 |
+
raise timeout("The read operation timed out")
|
| 316 |
+
else:
|
| 317 |
+
return self.recv(*args, **kwargs)
|
| 318 |
+
|
| 319 |
+
# TLS 1.3 post-handshake authentication
|
| 320 |
+
except OpenSSL.SSL.Error as e:
|
| 321 |
+
raise ssl.SSLError("read error: %r" % e)
|
| 322 |
+
else:
|
| 323 |
+
return data
|
| 324 |
+
|
| 325 |
+
def recv_into(self, *args, **kwargs):
|
| 326 |
+
try:
|
| 327 |
+
return self.connection.recv_into(*args, **kwargs)
|
| 328 |
+
except OpenSSL.SSL.SysCallError as e:
|
| 329 |
+
if self.suppress_ragged_eofs and e.args == (-1, "Unexpected EOF"):
|
| 330 |
+
return 0
|
| 331 |
+
else:
|
| 332 |
+
raise SocketError(str(e))
|
| 333 |
+
except OpenSSL.SSL.ZeroReturnError:
|
| 334 |
+
if self.connection.get_shutdown() == OpenSSL.SSL.RECEIVED_SHUTDOWN:
|
| 335 |
+
return 0
|
| 336 |
+
else:
|
| 337 |
+
raise
|
| 338 |
+
except OpenSSL.SSL.WantReadError:
|
| 339 |
+
if not util.wait_for_read(self.socket, self.socket.gettimeout()):
|
| 340 |
+
raise timeout("The read operation timed out")
|
| 341 |
+
else:
|
| 342 |
+
return self.recv_into(*args, **kwargs)
|
| 343 |
+
|
| 344 |
+
# TLS 1.3 post-handshake authentication
|
| 345 |
+
except OpenSSL.SSL.Error as e:
|
| 346 |
+
raise ssl.SSLError("read error: %r" % e)
|
| 347 |
+
|
| 348 |
+
def settimeout(self, timeout):
|
| 349 |
+
return self.socket.settimeout(timeout)
|
| 350 |
+
|
| 351 |
+
def _send_until_done(self, data):
|
| 352 |
+
while True:
|
| 353 |
+
try:
|
| 354 |
+
return self.connection.send(data)
|
| 355 |
+
except OpenSSL.SSL.WantWriteError:
|
| 356 |
+
if not util.wait_for_write(self.socket, self.socket.gettimeout()):
|
| 357 |
+
raise timeout()
|
| 358 |
+
continue
|
| 359 |
+
except OpenSSL.SSL.SysCallError as e:
|
| 360 |
+
raise SocketError(str(e))
|
| 361 |
+
|
| 362 |
+
def sendall(self, data):
|
| 363 |
+
total_sent = 0
|
| 364 |
+
while total_sent < len(data):
|
| 365 |
+
sent = self._send_until_done(
|
| 366 |
+
data[total_sent : total_sent + SSL_WRITE_BLOCKSIZE]
|
| 367 |
+
)
|
| 368 |
+
total_sent += sent
|
| 369 |
+
|
| 370 |
+
def shutdown(self):
|
| 371 |
+
# FIXME rethrow compatible exceptions should we ever use this
|
| 372 |
+
self.connection.shutdown()
|
| 373 |
+
|
| 374 |
+
def close(self):
|
| 375 |
+
if self._makefile_refs < 1:
|
| 376 |
+
try:
|
| 377 |
+
self._closed = True
|
| 378 |
+
return self.connection.close()
|
| 379 |
+
except OpenSSL.SSL.Error:
|
| 380 |
+
return
|
| 381 |
+
else:
|
| 382 |
+
self._makefile_refs -= 1
|
| 383 |
+
|
| 384 |
+
def getpeercert(self, binary_form=False):
|
| 385 |
+
x509 = self.connection.get_peer_certificate()
|
| 386 |
+
|
| 387 |
+
if not x509:
|
| 388 |
+
return x509
|
| 389 |
+
|
| 390 |
+
if binary_form:
|
| 391 |
+
return OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_ASN1, x509)
|
| 392 |
+
|
| 393 |
+
return {
|
| 394 |
+
"subject": ((("commonName", x509.get_subject().CN),),),
|
| 395 |
+
"subjectAltName": get_subj_alt_name(x509),
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
def version(self):
|
| 399 |
+
return self.connection.get_protocol_version_name()
|
| 400 |
+
|
| 401 |
+
def _reuse(self):
|
| 402 |
+
self._makefile_refs += 1
|
| 403 |
+
|
| 404 |
+
def _drop(self):
|
| 405 |
+
if self._makefile_refs < 1:
|
| 406 |
+
self.close()
|
| 407 |
+
else:
|
| 408 |
+
self._makefile_refs -= 1
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
if _fileobject: # Platform-specific: Python 2
|
| 412 |
+
|
| 413 |
+
def makefile(self, mode, bufsize=-1):
|
| 414 |
+
self._makefile_refs += 1
|
| 415 |
+
return _fileobject(self, mode, bufsize, close=True)
|
| 416 |
+
|
| 417 |
+
else: # Platform-specific: Python 3
|
| 418 |
+
makefile = backport_makefile
|
| 419 |
+
|
| 420 |
+
WrappedSocket.makefile = makefile
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
class PyOpenSSLContext(object):
|
| 424 |
+
"""
|
| 425 |
+
I am a wrapper class for the PyOpenSSL ``Context`` object. I am responsible
|
| 426 |
+
for translating the interface of the standard library ``SSLContext`` object
|
| 427 |
+
to calls into PyOpenSSL.
|
| 428 |
+
"""
|
| 429 |
+
|
| 430 |
+
def __init__(self, protocol):
|
| 431 |
+
self.protocol = _openssl_versions[protocol]
|
| 432 |
+
self._ctx = OpenSSL.SSL.Context(self.protocol)
|
| 433 |
+
self._options = 0
|
| 434 |
+
self.check_hostname = False
|
| 435 |
+
|
| 436 |
+
@property
|
| 437 |
+
def options(self):
|
| 438 |
+
return self._options
|
| 439 |
+
|
| 440 |
+
@options.setter
|
| 441 |
+
def options(self, value):
|
| 442 |
+
self._options = value
|
| 443 |
+
self._ctx.set_options(value)
|
| 444 |
+
|
| 445 |
+
@property
|
| 446 |
+
def verify_mode(self):
|
| 447 |
+
return _openssl_to_stdlib_verify[self._ctx.get_verify_mode()]
|
| 448 |
+
|
| 449 |
+
@verify_mode.setter
|
| 450 |
+
def verify_mode(self, value):
|
| 451 |
+
self._ctx.set_verify(_stdlib_to_openssl_verify[value], _verify_callback)
|
| 452 |
+
|
| 453 |
+
def set_default_verify_paths(self):
|
| 454 |
+
self._ctx.set_default_verify_paths()
|
| 455 |
+
|
| 456 |
+
def set_ciphers(self, ciphers):
|
| 457 |
+
if isinstance(ciphers, six.text_type):
|
| 458 |
+
ciphers = ciphers.encode("utf-8")
|
| 459 |
+
self._ctx.set_cipher_list(ciphers)
|
| 460 |
+
|
| 461 |
+
def load_verify_locations(self, cafile=None, capath=None, cadata=None):
|
| 462 |
+
if cafile is not None:
|
| 463 |
+
cafile = cafile.encode("utf-8")
|
| 464 |
+
if capath is not None:
|
| 465 |
+
capath = capath.encode("utf-8")
|
| 466 |
+
try:
|
| 467 |
+
self._ctx.load_verify_locations(cafile, capath)
|
| 468 |
+
if cadata is not None:
|
| 469 |
+
self._ctx.load_verify_locations(BytesIO(cadata))
|
| 470 |
+
except OpenSSL.SSL.Error as e:
|
| 471 |
+
raise ssl.SSLError("unable to load trusted certificates: %r" % e)
|
| 472 |
+
|
| 473 |
+
def load_cert_chain(self, certfile, keyfile=None, password=None):
|
| 474 |
+
self._ctx.use_certificate_chain_file(certfile)
|
| 475 |
+
if password is not None:
|
| 476 |
+
if not isinstance(password, six.binary_type):
|
| 477 |
+
password = password.encode("utf-8")
|
| 478 |
+
self._ctx.set_passwd_cb(lambda *_: password)
|
| 479 |
+
self._ctx.use_privatekey_file(keyfile or certfile)
|
| 480 |
+
|
| 481 |
+
def set_alpn_protocols(self, protocols):
|
| 482 |
+
protocols = [six.ensure_binary(p) for p in protocols]
|
| 483 |
+
return self._ctx.set_alpn_protos(protocols)
|
| 484 |
+
|
| 485 |
+
def wrap_socket(
|
| 486 |
+
self,
|
| 487 |
+
sock,
|
| 488 |
+
server_side=False,
|
| 489 |
+
do_handshake_on_connect=True,
|
| 490 |
+
suppress_ragged_eofs=True,
|
| 491 |
+
server_hostname=None,
|
| 492 |
+
):
|
| 493 |
+
cnx = OpenSSL.SSL.Connection(self._ctx, sock)
|
| 494 |
+
|
| 495 |
+
if isinstance(server_hostname, six.text_type): # Platform-specific: Python 3
|
| 496 |
+
server_hostname = server_hostname.encode("utf-8")
|
| 497 |
+
|
| 498 |
+
if server_hostname is not None:
|
| 499 |
+
cnx.set_tlsext_host_name(server_hostname)
|
| 500 |
+
|
| 501 |
+
cnx.set_connect_state()
|
| 502 |
+
|
| 503 |
+
while True:
|
| 504 |
+
try:
|
| 505 |
+
cnx.do_handshake()
|
| 506 |
+
except OpenSSL.SSL.WantReadError:
|
| 507 |
+
if not util.wait_for_read(sock, sock.gettimeout()):
|
| 508 |
+
raise timeout("select timed out")
|
| 509 |
+
continue
|
| 510 |
+
except OpenSSL.SSL.Error as e:
|
| 511 |
+
raise ssl.SSLError("bad handshake: %r" % e)
|
| 512 |
+
break
|
| 513 |
+
|
| 514 |
+
return WrappedSocket(cnx, sock)
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
def _verify_callback(cnx, x509, err_no, err_depth, return_code):
|
| 518 |
+
return err_no == 0
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/securetransport.py
ADDED
|
@@ -0,0 +1,921 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
SecureTranport support for urllib3 via ctypes.
|
| 3 |
+
|
| 4 |
+
This makes platform-native TLS available to urllib3 users on macOS without the
|
| 5 |
+
use of a compiler. This is an important feature because the Python Package
|
| 6 |
+
Index is moving to become a TLSv1.2-or-higher server, and the default OpenSSL
|
| 7 |
+
that ships with macOS is not capable of doing TLSv1.2. The only way to resolve
|
| 8 |
+
this is to give macOS users an alternative solution to the problem, and that
|
| 9 |
+
solution is to use SecureTransport.
|
| 10 |
+
|
| 11 |
+
We use ctypes here because this solution must not require a compiler. That's
|
| 12 |
+
because pip is not allowed to require a compiler either.
|
| 13 |
+
|
| 14 |
+
This is not intended to be a seriously long-term solution to this problem.
|
| 15 |
+
The hope is that PEP 543 will eventually solve this issue for us, at which
|
| 16 |
+
point we can retire this contrib module. But in the short term, we need to
|
| 17 |
+
solve the impending tire fire that is Python on Mac without this kind of
|
| 18 |
+
contrib module. So...here we are.
|
| 19 |
+
|
| 20 |
+
To use this module, simply import and inject it::
|
| 21 |
+
|
| 22 |
+
import pip._vendor.urllib3.contrib.securetransport as securetransport
|
| 23 |
+
securetransport.inject_into_urllib3()
|
| 24 |
+
|
| 25 |
+
Happy TLSing!
|
| 26 |
+
|
| 27 |
+
This code is a bastardised version of the code found in Will Bond's oscrypto
|
| 28 |
+
library. An enormous debt is owed to him for blazing this trail for us. For
|
| 29 |
+
that reason, this code should be considered to be covered both by urllib3's
|
| 30 |
+
license and by oscrypto's:
|
| 31 |
+
|
| 32 |
+
.. code-block::
|
| 33 |
+
|
| 34 |
+
Copyright (c) 2015-2016 Will Bond <will@wbond.net>
|
| 35 |
+
|
| 36 |
+
Permission is hereby granted, free of charge, to any person obtaining a
|
| 37 |
+
copy of this software and associated documentation files (the "Software"),
|
| 38 |
+
to deal in the Software without restriction, including without limitation
|
| 39 |
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
| 40 |
+
and/or sell copies of the Software, and to permit persons to whom the
|
| 41 |
+
Software is furnished to do so, subject to the following conditions:
|
| 42 |
+
|
| 43 |
+
The above copyright notice and this permission notice shall be included in
|
| 44 |
+
all copies or substantial portions of the Software.
|
| 45 |
+
|
| 46 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 47 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 48 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 49 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 50 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 51 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 52 |
+
DEALINGS IN THE SOFTWARE.
|
| 53 |
+
"""
|
| 54 |
+
from __future__ import absolute_import
|
| 55 |
+
|
| 56 |
+
import contextlib
|
| 57 |
+
import ctypes
|
| 58 |
+
import errno
|
| 59 |
+
import os.path
|
| 60 |
+
import shutil
|
| 61 |
+
import socket
|
| 62 |
+
import ssl
|
| 63 |
+
import struct
|
| 64 |
+
import threading
|
| 65 |
+
import weakref
|
| 66 |
+
|
| 67 |
+
from pip._vendor import six
|
| 68 |
+
|
| 69 |
+
from .. import util
|
| 70 |
+
from ..util.ssl_ import PROTOCOL_TLS_CLIENT
|
| 71 |
+
from ._securetransport.bindings import CoreFoundation, Security, SecurityConst
|
| 72 |
+
from ._securetransport.low_level import (
|
| 73 |
+
_assert_no_error,
|
| 74 |
+
_build_tls_unknown_ca_alert,
|
| 75 |
+
_cert_array_from_pem,
|
| 76 |
+
_create_cfstring_array,
|
| 77 |
+
_load_client_cert_chain,
|
| 78 |
+
_temporary_keychain,
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
try: # Platform-specific: Python 2
|
| 82 |
+
from socket import _fileobject
|
| 83 |
+
except ImportError: # Platform-specific: Python 3
|
| 84 |
+
_fileobject = None
|
| 85 |
+
from ..packages.backports.makefile import backport_makefile
|
| 86 |
+
|
| 87 |
+
__all__ = ["inject_into_urllib3", "extract_from_urllib3"]
|
| 88 |
+
|
| 89 |
+
# SNI always works
|
| 90 |
+
HAS_SNI = True
|
| 91 |
+
|
| 92 |
+
orig_util_HAS_SNI = util.HAS_SNI
|
| 93 |
+
orig_util_SSLContext = util.ssl_.SSLContext
|
| 94 |
+
|
| 95 |
+
# This dictionary is used by the read callback to obtain a handle to the
|
| 96 |
+
# calling wrapped socket. This is a pretty silly approach, but for now it'll
|
| 97 |
+
# do. I feel like I should be able to smuggle a handle to the wrapped socket
|
| 98 |
+
# directly in the SSLConnectionRef, but for now this approach will work I
|
| 99 |
+
# guess.
|
| 100 |
+
#
|
| 101 |
+
# We need to lock around this structure for inserts, but we don't do it for
|
| 102 |
+
# reads/writes in the callbacks. The reasoning here goes as follows:
|
| 103 |
+
#
|
| 104 |
+
# 1. It is not possible to call into the callbacks before the dictionary is
|
| 105 |
+
# populated, so once in the callback the id must be in the dictionary.
|
| 106 |
+
# 2. The callbacks don't mutate the dictionary, they only read from it, and
|
| 107 |
+
# so cannot conflict with any of the insertions.
|
| 108 |
+
#
|
| 109 |
+
# This is good: if we had to lock in the callbacks we'd drastically slow down
|
| 110 |
+
# the performance of this code.
|
| 111 |
+
_connection_refs = weakref.WeakValueDictionary()
|
| 112 |
+
_connection_ref_lock = threading.Lock()
|
| 113 |
+
|
| 114 |
+
# Limit writes to 16kB. This is OpenSSL's limit, but we'll cargo-cult it over
|
| 115 |
+
# for no better reason than we need *a* limit, and this one is right there.
|
| 116 |
+
SSL_WRITE_BLOCKSIZE = 16384
|
| 117 |
+
|
| 118 |
+
# This is our equivalent of util.ssl_.DEFAULT_CIPHERS, but expanded out to
|
| 119 |
+
# individual cipher suites. We need to do this because this is how
|
| 120 |
+
# SecureTransport wants them.
|
| 121 |
+
CIPHER_SUITES = [
|
| 122 |
+
SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
| 123 |
+
SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
| 124 |
+
SecurityConst.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
| 125 |
+
SecurityConst.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
| 126 |
+
SecurityConst.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
|
| 127 |
+
SecurityConst.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
|
| 128 |
+
SecurityConst.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
|
| 129 |
+
SecurityConst.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,
|
| 130 |
+
SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
|
| 131 |
+
SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
|
| 132 |
+
SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
|
| 133 |
+
SecurityConst.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
|
| 134 |
+
SecurityConst.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
|
| 135 |
+
SecurityConst.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
| 136 |
+
SecurityConst.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
|
| 137 |
+
SecurityConst.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
|
| 138 |
+
SecurityConst.TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
|
| 139 |
+
SecurityConst.TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
|
| 140 |
+
SecurityConst.TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
|
| 141 |
+
SecurityConst.TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
|
| 142 |
+
SecurityConst.TLS_AES_256_GCM_SHA384,
|
| 143 |
+
SecurityConst.TLS_AES_128_GCM_SHA256,
|
| 144 |
+
SecurityConst.TLS_RSA_WITH_AES_256_GCM_SHA384,
|
| 145 |
+
SecurityConst.TLS_RSA_WITH_AES_128_GCM_SHA256,
|
| 146 |
+
SecurityConst.TLS_AES_128_CCM_8_SHA256,
|
| 147 |
+
SecurityConst.TLS_AES_128_CCM_SHA256,
|
| 148 |
+
SecurityConst.TLS_RSA_WITH_AES_256_CBC_SHA256,
|
| 149 |
+
SecurityConst.TLS_RSA_WITH_AES_128_CBC_SHA256,
|
| 150 |
+
SecurityConst.TLS_RSA_WITH_AES_256_CBC_SHA,
|
| 151 |
+
SecurityConst.TLS_RSA_WITH_AES_128_CBC_SHA,
|
| 152 |
+
]
|
| 153 |
+
|
| 154 |
+
# Basically this is simple: for PROTOCOL_SSLv23 we turn it into a low of
|
| 155 |
+
# TLSv1 and a high of TLSv1.2. For everything else, we pin to that version.
|
| 156 |
+
# TLSv1 to 1.2 are supported on macOS 10.8+
|
| 157 |
+
_protocol_to_min_max = {
|
| 158 |
+
util.PROTOCOL_TLS: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12),
|
| 159 |
+
PROTOCOL_TLS_CLIENT: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12),
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
if hasattr(ssl, "PROTOCOL_SSLv2"):
|
| 163 |
+
_protocol_to_min_max[ssl.PROTOCOL_SSLv2] = (
|
| 164 |
+
SecurityConst.kSSLProtocol2,
|
| 165 |
+
SecurityConst.kSSLProtocol2,
|
| 166 |
+
)
|
| 167 |
+
if hasattr(ssl, "PROTOCOL_SSLv3"):
|
| 168 |
+
_protocol_to_min_max[ssl.PROTOCOL_SSLv3] = (
|
| 169 |
+
SecurityConst.kSSLProtocol3,
|
| 170 |
+
SecurityConst.kSSLProtocol3,
|
| 171 |
+
)
|
| 172 |
+
if hasattr(ssl, "PROTOCOL_TLSv1"):
|
| 173 |
+
_protocol_to_min_max[ssl.PROTOCOL_TLSv1] = (
|
| 174 |
+
SecurityConst.kTLSProtocol1,
|
| 175 |
+
SecurityConst.kTLSProtocol1,
|
| 176 |
+
)
|
| 177 |
+
if hasattr(ssl, "PROTOCOL_TLSv1_1"):
|
| 178 |
+
_protocol_to_min_max[ssl.PROTOCOL_TLSv1_1] = (
|
| 179 |
+
SecurityConst.kTLSProtocol11,
|
| 180 |
+
SecurityConst.kTLSProtocol11,
|
| 181 |
+
)
|
| 182 |
+
if hasattr(ssl, "PROTOCOL_TLSv1_2"):
|
| 183 |
+
_protocol_to_min_max[ssl.PROTOCOL_TLSv1_2] = (
|
| 184 |
+
SecurityConst.kTLSProtocol12,
|
| 185 |
+
SecurityConst.kTLSProtocol12,
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def inject_into_urllib3():
|
| 190 |
+
"""
|
| 191 |
+
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
|
| 192 |
+
"""
|
| 193 |
+
util.SSLContext = SecureTransportContext
|
| 194 |
+
util.ssl_.SSLContext = SecureTransportContext
|
| 195 |
+
util.HAS_SNI = HAS_SNI
|
| 196 |
+
util.ssl_.HAS_SNI = HAS_SNI
|
| 197 |
+
util.IS_SECURETRANSPORT = True
|
| 198 |
+
util.ssl_.IS_SECURETRANSPORT = True
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def extract_from_urllib3():
|
| 202 |
+
"""
|
| 203 |
+
Undo monkey-patching by :func:`inject_into_urllib3`.
|
| 204 |
+
"""
|
| 205 |
+
util.SSLContext = orig_util_SSLContext
|
| 206 |
+
util.ssl_.SSLContext = orig_util_SSLContext
|
| 207 |
+
util.HAS_SNI = orig_util_HAS_SNI
|
| 208 |
+
util.ssl_.HAS_SNI = orig_util_HAS_SNI
|
| 209 |
+
util.IS_SECURETRANSPORT = False
|
| 210 |
+
util.ssl_.IS_SECURETRANSPORT = False
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def _read_callback(connection_id, data_buffer, data_length_pointer):
|
| 214 |
+
"""
|
| 215 |
+
SecureTransport read callback. This is called by ST to request that data
|
| 216 |
+
be returned from the socket.
|
| 217 |
+
"""
|
| 218 |
+
wrapped_socket = None
|
| 219 |
+
try:
|
| 220 |
+
wrapped_socket = _connection_refs.get(connection_id)
|
| 221 |
+
if wrapped_socket is None:
|
| 222 |
+
return SecurityConst.errSSLInternal
|
| 223 |
+
base_socket = wrapped_socket.socket
|
| 224 |
+
|
| 225 |
+
requested_length = data_length_pointer[0]
|
| 226 |
+
|
| 227 |
+
timeout = wrapped_socket.gettimeout()
|
| 228 |
+
error = None
|
| 229 |
+
read_count = 0
|
| 230 |
+
|
| 231 |
+
try:
|
| 232 |
+
while read_count < requested_length:
|
| 233 |
+
if timeout is None or timeout >= 0:
|
| 234 |
+
if not util.wait_for_read(base_socket, timeout):
|
| 235 |
+
raise socket.error(errno.EAGAIN, "timed out")
|
| 236 |
+
|
| 237 |
+
remaining = requested_length - read_count
|
| 238 |
+
buffer = (ctypes.c_char * remaining).from_address(
|
| 239 |
+
data_buffer + read_count
|
| 240 |
+
)
|
| 241 |
+
chunk_size = base_socket.recv_into(buffer, remaining)
|
| 242 |
+
read_count += chunk_size
|
| 243 |
+
if not chunk_size:
|
| 244 |
+
if not read_count:
|
| 245 |
+
return SecurityConst.errSSLClosedGraceful
|
| 246 |
+
break
|
| 247 |
+
except (socket.error) as e:
|
| 248 |
+
error = e.errno
|
| 249 |
+
|
| 250 |
+
if error is not None and error != errno.EAGAIN:
|
| 251 |
+
data_length_pointer[0] = read_count
|
| 252 |
+
if error == errno.ECONNRESET or error == errno.EPIPE:
|
| 253 |
+
return SecurityConst.errSSLClosedAbort
|
| 254 |
+
raise
|
| 255 |
+
|
| 256 |
+
data_length_pointer[0] = read_count
|
| 257 |
+
|
| 258 |
+
if read_count != requested_length:
|
| 259 |
+
return SecurityConst.errSSLWouldBlock
|
| 260 |
+
|
| 261 |
+
return 0
|
| 262 |
+
except Exception as e:
|
| 263 |
+
if wrapped_socket is not None:
|
| 264 |
+
wrapped_socket._exception = e
|
| 265 |
+
return SecurityConst.errSSLInternal
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
def _write_callback(connection_id, data_buffer, data_length_pointer):
|
| 269 |
+
"""
|
| 270 |
+
SecureTransport write callback. This is called by ST to request that data
|
| 271 |
+
actually be sent on the network.
|
| 272 |
+
"""
|
| 273 |
+
wrapped_socket = None
|
| 274 |
+
try:
|
| 275 |
+
wrapped_socket = _connection_refs.get(connection_id)
|
| 276 |
+
if wrapped_socket is None:
|
| 277 |
+
return SecurityConst.errSSLInternal
|
| 278 |
+
base_socket = wrapped_socket.socket
|
| 279 |
+
|
| 280 |
+
bytes_to_write = data_length_pointer[0]
|
| 281 |
+
data = ctypes.string_at(data_buffer, bytes_to_write)
|
| 282 |
+
|
| 283 |
+
timeout = wrapped_socket.gettimeout()
|
| 284 |
+
error = None
|
| 285 |
+
sent = 0
|
| 286 |
+
|
| 287 |
+
try:
|
| 288 |
+
while sent < bytes_to_write:
|
| 289 |
+
if timeout is None or timeout >= 0:
|
| 290 |
+
if not util.wait_for_write(base_socket, timeout):
|
| 291 |
+
raise socket.error(errno.EAGAIN, "timed out")
|
| 292 |
+
chunk_sent = base_socket.send(data)
|
| 293 |
+
sent += chunk_sent
|
| 294 |
+
|
| 295 |
+
# This has some needless copying here, but I'm not sure there's
|
| 296 |
+
# much value in optimising this data path.
|
| 297 |
+
data = data[chunk_sent:]
|
| 298 |
+
except (socket.error) as e:
|
| 299 |
+
error = e.errno
|
| 300 |
+
|
| 301 |
+
if error is not None and error != errno.EAGAIN:
|
| 302 |
+
data_length_pointer[0] = sent
|
| 303 |
+
if error == errno.ECONNRESET or error == errno.EPIPE:
|
| 304 |
+
return SecurityConst.errSSLClosedAbort
|
| 305 |
+
raise
|
| 306 |
+
|
| 307 |
+
data_length_pointer[0] = sent
|
| 308 |
+
|
| 309 |
+
if sent != bytes_to_write:
|
| 310 |
+
return SecurityConst.errSSLWouldBlock
|
| 311 |
+
|
| 312 |
+
return 0
|
| 313 |
+
except Exception as e:
|
| 314 |
+
if wrapped_socket is not None:
|
| 315 |
+
wrapped_socket._exception = e
|
| 316 |
+
return SecurityConst.errSSLInternal
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
# We need to keep these two objects references alive: if they get GC'd while
|
| 320 |
+
# in use then SecureTransport could attempt to call a function that is in freed
|
| 321 |
+
# memory. That would be...uh...bad. Yeah, that's the word. Bad.
|
| 322 |
+
_read_callback_pointer = Security.SSLReadFunc(_read_callback)
|
| 323 |
+
_write_callback_pointer = Security.SSLWriteFunc(_write_callback)
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
class WrappedSocket(object):
|
| 327 |
+
"""
|
| 328 |
+
API-compatibility wrapper for Python's OpenSSL wrapped socket object.
|
| 329 |
+
|
| 330 |
+
Note: _makefile_refs, _drop(), and _reuse() are needed for the garbage
|
| 331 |
+
collector of PyPy.
|
| 332 |
+
"""
|
| 333 |
+
|
| 334 |
+
def __init__(self, socket):
|
| 335 |
+
self.socket = socket
|
| 336 |
+
self.context = None
|
| 337 |
+
self._makefile_refs = 0
|
| 338 |
+
self._closed = False
|
| 339 |
+
self._exception = None
|
| 340 |
+
self._keychain = None
|
| 341 |
+
self._keychain_dir = None
|
| 342 |
+
self._client_cert_chain = None
|
| 343 |
+
|
| 344 |
+
# We save off the previously-configured timeout and then set it to
|
| 345 |
+
# zero. This is done because we use select and friends to handle the
|
| 346 |
+
# timeouts, but if we leave the timeout set on the lower socket then
|
| 347 |
+
# Python will "kindly" call select on that socket again for us. Avoid
|
| 348 |
+
# that by forcing the timeout to zero.
|
| 349 |
+
self._timeout = self.socket.gettimeout()
|
| 350 |
+
self.socket.settimeout(0)
|
| 351 |
+
|
| 352 |
+
@contextlib.contextmanager
|
| 353 |
+
def _raise_on_error(self):
|
| 354 |
+
"""
|
| 355 |
+
A context manager that can be used to wrap calls that do I/O from
|
| 356 |
+
SecureTransport. If any of the I/O callbacks hit an exception, this
|
| 357 |
+
context manager will correctly propagate the exception after the fact.
|
| 358 |
+
This avoids silently swallowing those exceptions.
|
| 359 |
+
|
| 360 |
+
It also correctly forces the socket closed.
|
| 361 |
+
"""
|
| 362 |
+
self._exception = None
|
| 363 |
+
|
| 364 |
+
# We explicitly don't catch around this yield because in the unlikely
|
| 365 |
+
# event that an exception was hit in the block we don't want to swallow
|
| 366 |
+
# it.
|
| 367 |
+
yield
|
| 368 |
+
if self._exception is not None:
|
| 369 |
+
exception, self._exception = self._exception, None
|
| 370 |
+
self.close()
|
| 371 |
+
raise exception
|
| 372 |
+
|
| 373 |
+
def _set_ciphers(self):
|
| 374 |
+
"""
|
| 375 |
+
Sets up the allowed ciphers. By default this matches the set in
|
| 376 |
+
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
|
| 377 |
+
custom and doesn't allow changing at this time, mostly because parsing
|
| 378 |
+
OpenSSL cipher strings is going to be a freaking nightmare.
|
| 379 |
+
"""
|
| 380 |
+
ciphers = (Security.SSLCipherSuite * len(CIPHER_SUITES))(*CIPHER_SUITES)
|
| 381 |
+
result = Security.SSLSetEnabledCiphers(
|
| 382 |
+
self.context, ciphers, len(CIPHER_SUITES)
|
| 383 |
+
)
|
| 384 |
+
_assert_no_error(result)
|
| 385 |
+
|
| 386 |
+
def _set_alpn_protocols(self, protocols):
|
| 387 |
+
"""
|
| 388 |
+
Sets up the ALPN protocols on the context.
|
| 389 |
+
"""
|
| 390 |
+
if not protocols:
|
| 391 |
+
return
|
| 392 |
+
protocols_arr = _create_cfstring_array(protocols)
|
| 393 |
+
try:
|
| 394 |
+
result = Security.SSLSetALPNProtocols(self.context, protocols_arr)
|
| 395 |
+
_assert_no_error(result)
|
| 396 |
+
finally:
|
| 397 |
+
CoreFoundation.CFRelease(protocols_arr)
|
| 398 |
+
|
| 399 |
+
def _custom_validate(self, verify, trust_bundle):
|
| 400 |
+
"""
|
| 401 |
+
Called when we have set custom validation. We do this in two cases:
|
| 402 |
+
first, when cert validation is entirely disabled; and second, when
|
| 403 |
+
using a custom trust DB.
|
| 404 |
+
Raises an SSLError if the connection is not trusted.
|
| 405 |
+
"""
|
| 406 |
+
# If we disabled cert validation, just say: cool.
|
| 407 |
+
if not verify:
|
| 408 |
+
return
|
| 409 |
+
|
| 410 |
+
successes = (
|
| 411 |
+
SecurityConst.kSecTrustResultUnspecified,
|
| 412 |
+
SecurityConst.kSecTrustResultProceed,
|
| 413 |
+
)
|
| 414 |
+
try:
|
| 415 |
+
trust_result = self._evaluate_trust(trust_bundle)
|
| 416 |
+
if trust_result in successes:
|
| 417 |
+
return
|
| 418 |
+
reason = "error code: %d" % (trust_result,)
|
| 419 |
+
except Exception as e:
|
| 420 |
+
# Do not trust on error
|
| 421 |
+
reason = "exception: %r" % (e,)
|
| 422 |
+
|
| 423 |
+
# SecureTransport does not send an alert nor shuts down the connection.
|
| 424 |
+
rec = _build_tls_unknown_ca_alert(self.version())
|
| 425 |
+
self.socket.sendall(rec)
|
| 426 |
+
# close the connection immediately
|
| 427 |
+
# l_onoff = 1, activate linger
|
| 428 |
+
# l_linger = 0, linger for 0 seoncds
|
| 429 |
+
opts = struct.pack("ii", 1, 0)
|
| 430 |
+
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, opts)
|
| 431 |
+
self.close()
|
| 432 |
+
raise ssl.SSLError("certificate verify failed, %s" % reason)
|
| 433 |
+
|
| 434 |
+
def _evaluate_trust(self, trust_bundle):
|
| 435 |
+
# We want data in memory, so load it up.
|
| 436 |
+
if os.path.isfile(trust_bundle):
|
| 437 |
+
with open(trust_bundle, "rb") as f:
|
| 438 |
+
trust_bundle = f.read()
|
| 439 |
+
|
| 440 |
+
cert_array = None
|
| 441 |
+
trust = Security.SecTrustRef()
|
| 442 |
+
|
| 443 |
+
try:
|
| 444 |
+
# Get a CFArray that contains the certs we want.
|
| 445 |
+
cert_array = _cert_array_from_pem(trust_bundle)
|
| 446 |
+
|
| 447 |
+
# Ok, now the hard part. We want to get the SecTrustRef that ST has
|
| 448 |
+
# created for this connection, shove our CAs into it, tell ST to
|
| 449 |
+
# ignore everything else it knows, and then ask if it can build a
|
| 450 |
+
# chain. This is a buuuunch of code.
|
| 451 |
+
result = Security.SSLCopyPeerTrust(self.context, ctypes.byref(trust))
|
| 452 |
+
_assert_no_error(result)
|
| 453 |
+
if not trust:
|
| 454 |
+
raise ssl.SSLError("Failed to copy trust reference")
|
| 455 |
+
|
| 456 |
+
result = Security.SecTrustSetAnchorCertificates(trust, cert_array)
|
| 457 |
+
_assert_no_error(result)
|
| 458 |
+
|
| 459 |
+
result = Security.SecTrustSetAnchorCertificatesOnly(trust, True)
|
| 460 |
+
_assert_no_error(result)
|
| 461 |
+
|
| 462 |
+
trust_result = Security.SecTrustResultType()
|
| 463 |
+
result = Security.SecTrustEvaluate(trust, ctypes.byref(trust_result))
|
| 464 |
+
_assert_no_error(result)
|
| 465 |
+
finally:
|
| 466 |
+
if trust:
|
| 467 |
+
CoreFoundation.CFRelease(trust)
|
| 468 |
+
|
| 469 |
+
if cert_array is not None:
|
| 470 |
+
CoreFoundation.CFRelease(cert_array)
|
| 471 |
+
|
| 472 |
+
return trust_result.value
|
| 473 |
+
|
| 474 |
+
def handshake(
|
| 475 |
+
self,
|
| 476 |
+
server_hostname,
|
| 477 |
+
verify,
|
| 478 |
+
trust_bundle,
|
| 479 |
+
min_version,
|
| 480 |
+
max_version,
|
| 481 |
+
client_cert,
|
| 482 |
+
client_key,
|
| 483 |
+
client_key_passphrase,
|
| 484 |
+
alpn_protocols,
|
| 485 |
+
):
|
| 486 |
+
"""
|
| 487 |
+
Actually performs the TLS handshake. This is run automatically by
|
| 488 |
+
wrapped socket, and shouldn't be needed in user code.
|
| 489 |
+
"""
|
| 490 |
+
# First, we do the initial bits of connection setup. We need to create
|
| 491 |
+
# a context, set its I/O funcs, and set the connection reference.
|
| 492 |
+
self.context = Security.SSLCreateContext(
|
| 493 |
+
None, SecurityConst.kSSLClientSide, SecurityConst.kSSLStreamType
|
| 494 |
+
)
|
| 495 |
+
result = Security.SSLSetIOFuncs(
|
| 496 |
+
self.context, _read_callback_pointer, _write_callback_pointer
|
| 497 |
+
)
|
| 498 |
+
_assert_no_error(result)
|
| 499 |
+
|
| 500 |
+
# Here we need to compute the handle to use. We do this by taking the
|
| 501 |
+
# id of self modulo 2**31 - 1. If this is already in the dictionary, we
|
| 502 |
+
# just keep incrementing by one until we find a free space.
|
| 503 |
+
with _connection_ref_lock:
|
| 504 |
+
handle = id(self) % 2147483647
|
| 505 |
+
while handle in _connection_refs:
|
| 506 |
+
handle = (handle + 1) % 2147483647
|
| 507 |
+
_connection_refs[handle] = self
|
| 508 |
+
|
| 509 |
+
result = Security.SSLSetConnection(self.context, handle)
|
| 510 |
+
_assert_no_error(result)
|
| 511 |
+
|
| 512 |
+
# If we have a server hostname, we should set that too.
|
| 513 |
+
if server_hostname:
|
| 514 |
+
if not isinstance(server_hostname, bytes):
|
| 515 |
+
server_hostname = server_hostname.encode("utf-8")
|
| 516 |
+
|
| 517 |
+
result = Security.SSLSetPeerDomainName(
|
| 518 |
+
self.context, server_hostname, len(server_hostname)
|
| 519 |
+
)
|
| 520 |
+
_assert_no_error(result)
|
| 521 |
+
|
| 522 |
+
# Setup the ciphers.
|
| 523 |
+
self._set_ciphers()
|
| 524 |
+
|
| 525 |
+
# Setup the ALPN protocols.
|
| 526 |
+
self._set_alpn_protocols(alpn_protocols)
|
| 527 |
+
|
| 528 |
+
# Set the minimum and maximum TLS versions.
|
| 529 |
+
result = Security.SSLSetProtocolVersionMin(self.context, min_version)
|
| 530 |
+
_assert_no_error(result)
|
| 531 |
+
|
| 532 |
+
result = Security.SSLSetProtocolVersionMax(self.context, max_version)
|
| 533 |
+
_assert_no_error(result)
|
| 534 |
+
|
| 535 |
+
# If there's a trust DB, we need to use it. We do that by telling
|
| 536 |
+
# SecureTransport to break on server auth. We also do that if we don't
|
| 537 |
+
# want to validate the certs at all: we just won't actually do any
|
| 538 |
+
# authing in that case.
|
| 539 |
+
if not verify or trust_bundle is not None:
|
| 540 |
+
result = Security.SSLSetSessionOption(
|
| 541 |
+
self.context, SecurityConst.kSSLSessionOptionBreakOnServerAuth, True
|
| 542 |
+
)
|
| 543 |
+
_assert_no_error(result)
|
| 544 |
+
|
| 545 |
+
# If there's a client cert, we need to use it.
|
| 546 |
+
if client_cert:
|
| 547 |
+
self._keychain, self._keychain_dir = _temporary_keychain()
|
| 548 |
+
self._client_cert_chain = _load_client_cert_chain(
|
| 549 |
+
self._keychain, client_cert, client_key
|
| 550 |
+
)
|
| 551 |
+
result = Security.SSLSetCertificate(self.context, self._client_cert_chain)
|
| 552 |
+
_assert_no_error(result)
|
| 553 |
+
|
| 554 |
+
while True:
|
| 555 |
+
with self._raise_on_error():
|
| 556 |
+
result = Security.SSLHandshake(self.context)
|
| 557 |
+
|
| 558 |
+
if result == SecurityConst.errSSLWouldBlock:
|
| 559 |
+
raise socket.timeout("handshake timed out")
|
| 560 |
+
elif result == SecurityConst.errSSLServerAuthCompleted:
|
| 561 |
+
self._custom_validate(verify, trust_bundle)
|
| 562 |
+
continue
|
| 563 |
+
else:
|
| 564 |
+
_assert_no_error(result)
|
| 565 |
+
break
|
| 566 |
+
|
| 567 |
+
def fileno(self):
|
| 568 |
+
return self.socket.fileno()
|
| 569 |
+
|
| 570 |
+
# Copy-pasted from Python 3.5 source code
|
| 571 |
+
def _decref_socketios(self):
|
| 572 |
+
if self._makefile_refs > 0:
|
| 573 |
+
self._makefile_refs -= 1
|
| 574 |
+
if self._closed:
|
| 575 |
+
self.close()
|
| 576 |
+
|
| 577 |
+
def recv(self, bufsiz):
|
| 578 |
+
buffer = ctypes.create_string_buffer(bufsiz)
|
| 579 |
+
bytes_read = self.recv_into(buffer, bufsiz)
|
| 580 |
+
data = buffer[:bytes_read]
|
| 581 |
+
return data
|
| 582 |
+
|
| 583 |
+
def recv_into(self, buffer, nbytes=None):
|
| 584 |
+
# Read short on EOF.
|
| 585 |
+
if self._closed:
|
| 586 |
+
return 0
|
| 587 |
+
|
| 588 |
+
if nbytes is None:
|
| 589 |
+
nbytes = len(buffer)
|
| 590 |
+
|
| 591 |
+
buffer = (ctypes.c_char * nbytes).from_buffer(buffer)
|
| 592 |
+
processed_bytes = ctypes.c_size_t(0)
|
| 593 |
+
|
| 594 |
+
with self._raise_on_error():
|
| 595 |
+
result = Security.SSLRead(
|
| 596 |
+
self.context, buffer, nbytes, ctypes.byref(processed_bytes)
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
# There are some result codes that we want to treat as "not always
|
| 600 |
+
# errors". Specifically, those are errSSLWouldBlock,
|
| 601 |
+
# errSSLClosedGraceful, and errSSLClosedNoNotify.
|
| 602 |
+
if result == SecurityConst.errSSLWouldBlock:
|
| 603 |
+
# If we didn't process any bytes, then this was just a time out.
|
| 604 |
+
# However, we can get errSSLWouldBlock in situations when we *did*
|
| 605 |
+
# read some data, and in those cases we should just read "short"
|
| 606 |
+
# and return.
|
| 607 |
+
if processed_bytes.value == 0:
|
| 608 |
+
# Timed out, no data read.
|
| 609 |
+
raise socket.timeout("recv timed out")
|
| 610 |
+
elif result in (
|
| 611 |
+
SecurityConst.errSSLClosedGraceful,
|
| 612 |
+
SecurityConst.errSSLClosedNoNotify,
|
| 613 |
+
):
|
| 614 |
+
# The remote peer has closed this connection. We should do so as
|
| 615 |
+
# well. Note that we don't actually return here because in
|
| 616 |
+
# principle this could actually be fired along with return data.
|
| 617 |
+
# It's unlikely though.
|
| 618 |
+
self.close()
|
| 619 |
+
else:
|
| 620 |
+
_assert_no_error(result)
|
| 621 |
+
|
| 622 |
+
# Ok, we read and probably succeeded. We should return whatever data
|
| 623 |
+
# was actually read.
|
| 624 |
+
return processed_bytes.value
|
| 625 |
+
|
| 626 |
+
def settimeout(self, timeout):
|
| 627 |
+
self._timeout = timeout
|
| 628 |
+
|
| 629 |
+
def gettimeout(self):
|
| 630 |
+
return self._timeout
|
| 631 |
+
|
| 632 |
+
def send(self, data):
|
| 633 |
+
processed_bytes = ctypes.c_size_t(0)
|
| 634 |
+
|
| 635 |
+
with self._raise_on_error():
|
| 636 |
+
result = Security.SSLWrite(
|
| 637 |
+
self.context, data, len(data), ctypes.byref(processed_bytes)
|
| 638 |
+
)
|
| 639 |
+
|
| 640 |
+
if result == SecurityConst.errSSLWouldBlock and processed_bytes.value == 0:
|
| 641 |
+
# Timed out
|
| 642 |
+
raise socket.timeout("send timed out")
|
| 643 |
+
else:
|
| 644 |
+
_assert_no_error(result)
|
| 645 |
+
|
| 646 |
+
# We sent, and probably succeeded. Tell them how much we sent.
|
| 647 |
+
return processed_bytes.value
|
| 648 |
+
|
| 649 |
+
def sendall(self, data):
|
| 650 |
+
total_sent = 0
|
| 651 |
+
while total_sent < len(data):
|
| 652 |
+
sent = self.send(data[total_sent : total_sent + SSL_WRITE_BLOCKSIZE])
|
| 653 |
+
total_sent += sent
|
| 654 |
+
|
| 655 |
+
def shutdown(self):
|
| 656 |
+
with self._raise_on_error():
|
| 657 |
+
Security.SSLClose(self.context)
|
| 658 |
+
|
| 659 |
+
def close(self):
|
| 660 |
+
# TODO: should I do clean shutdown here? Do I have to?
|
| 661 |
+
if self._makefile_refs < 1:
|
| 662 |
+
self._closed = True
|
| 663 |
+
if self.context:
|
| 664 |
+
CoreFoundation.CFRelease(self.context)
|
| 665 |
+
self.context = None
|
| 666 |
+
if self._client_cert_chain:
|
| 667 |
+
CoreFoundation.CFRelease(self._client_cert_chain)
|
| 668 |
+
self._client_cert_chain = None
|
| 669 |
+
if self._keychain:
|
| 670 |
+
Security.SecKeychainDelete(self._keychain)
|
| 671 |
+
CoreFoundation.CFRelease(self._keychain)
|
| 672 |
+
shutil.rmtree(self._keychain_dir)
|
| 673 |
+
self._keychain = self._keychain_dir = None
|
| 674 |
+
return self.socket.close()
|
| 675 |
+
else:
|
| 676 |
+
self._makefile_refs -= 1
|
| 677 |
+
|
| 678 |
+
def getpeercert(self, binary_form=False):
|
| 679 |
+
# Urgh, annoying.
|
| 680 |
+
#
|
| 681 |
+
# Here's how we do this:
|
| 682 |
+
#
|
| 683 |
+
# 1. Call SSLCopyPeerTrust to get hold of the trust object for this
|
| 684 |
+
# connection.
|
| 685 |
+
# 2. Call SecTrustGetCertificateAtIndex for index 0 to get the leaf.
|
| 686 |
+
# 3. To get the CN, call SecCertificateCopyCommonName and process that
|
| 687 |
+
# string so that it's of the appropriate type.
|
| 688 |
+
# 4. To get the SAN, we need to do something a bit more complex:
|
| 689 |
+
# a. Call SecCertificateCopyValues to get the data, requesting
|
| 690 |
+
# kSecOIDSubjectAltName.
|
| 691 |
+
# b. Mess about with this dictionary to try to get the SANs out.
|
| 692 |
+
#
|
| 693 |
+
# This is gross. Really gross. It's going to be a few hundred LoC extra
|
| 694 |
+
# just to repeat something that SecureTransport can *already do*. So my
|
| 695 |
+
# operating assumption at this time is that what we want to do is
|
| 696 |
+
# instead to just flag to urllib3 that it shouldn't do its own hostname
|
| 697 |
+
# validation when using SecureTransport.
|
| 698 |
+
if not binary_form:
|
| 699 |
+
raise ValueError("SecureTransport only supports dumping binary certs")
|
| 700 |
+
trust = Security.SecTrustRef()
|
| 701 |
+
certdata = None
|
| 702 |
+
der_bytes = None
|
| 703 |
+
|
| 704 |
+
try:
|
| 705 |
+
# Grab the trust store.
|
| 706 |
+
result = Security.SSLCopyPeerTrust(self.context, ctypes.byref(trust))
|
| 707 |
+
_assert_no_error(result)
|
| 708 |
+
if not trust:
|
| 709 |
+
# Probably we haven't done the handshake yet. No biggie.
|
| 710 |
+
return None
|
| 711 |
+
|
| 712 |
+
cert_count = Security.SecTrustGetCertificateCount(trust)
|
| 713 |
+
if not cert_count:
|
| 714 |
+
# Also a case that might happen if we haven't handshaked.
|
| 715 |
+
# Handshook? Handshaken?
|
| 716 |
+
return None
|
| 717 |
+
|
| 718 |
+
leaf = Security.SecTrustGetCertificateAtIndex(trust, 0)
|
| 719 |
+
assert leaf
|
| 720 |
+
|
| 721 |
+
# Ok, now we want the DER bytes.
|
| 722 |
+
certdata = Security.SecCertificateCopyData(leaf)
|
| 723 |
+
assert certdata
|
| 724 |
+
|
| 725 |
+
data_length = CoreFoundation.CFDataGetLength(certdata)
|
| 726 |
+
data_buffer = CoreFoundation.CFDataGetBytePtr(certdata)
|
| 727 |
+
der_bytes = ctypes.string_at(data_buffer, data_length)
|
| 728 |
+
finally:
|
| 729 |
+
if certdata:
|
| 730 |
+
CoreFoundation.CFRelease(certdata)
|
| 731 |
+
if trust:
|
| 732 |
+
CoreFoundation.CFRelease(trust)
|
| 733 |
+
|
| 734 |
+
return der_bytes
|
| 735 |
+
|
| 736 |
+
def version(self):
|
| 737 |
+
protocol = Security.SSLProtocol()
|
| 738 |
+
result = Security.SSLGetNegotiatedProtocolVersion(
|
| 739 |
+
self.context, ctypes.byref(protocol)
|
| 740 |
+
)
|
| 741 |
+
_assert_no_error(result)
|
| 742 |
+
if protocol.value == SecurityConst.kTLSProtocol13:
|
| 743 |
+
raise ssl.SSLError("SecureTransport does not support TLS 1.3")
|
| 744 |
+
elif protocol.value == SecurityConst.kTLSProtocol12:
|
| 745 |
+
return "TLSv1.2"
|
| 746 |
+
elif protocol.value == SecurityConst.kTLSProtocol11:
|
| 747 |
+
return "TLSv1.1"
|
| 748 |
+
elif protocol.value == SecurityConst.kTLSProtocol1:
|
| 749 |
+
return "TLSv1"
|
| 750 |
+
elif protocol.value == SecurityConst.kSSLProtocol3:
|
| 751 |
+
return "SSLv3"
|
| 752 |
+
elif protocol.value == SecurityConst.kSSLProtocol2:
|
| 753 |
+
return "SSLv2"
|
| 754 |
+
else:
|
| 755 |
+
raise ssl.SSLError("Unknown TLS version: %r" % protocol)
|
| 756 |
+
|
| 757 |
+
def _reuse(self):
|
| 758 |
+
self._makefile_refs += 1
|
| 759 |
+
|
| 760 |
+
def _drop(self):
|
| 761 |
+
if self._makefile_refs < 1:
|
| 762 |
+
self.close()
|
| 763 |
+
else:
|
| 764 |
+
self._makefile_refs -= 1
|
| 765 |
+
|
| 766 |
+
|
| 767 |
+
if _fileobject: # Platform-specific: Python 2
|
| 768 |
+
|
| 769 |
+
def makefile(self, mode, bufsize=-1):
|
| 770 |
+
self._makefile_refs += 1
|
| 771 |
+
return _fileobject(self, mode, bufsize, close=True)
|
| 772 |
+
|
| 773 |
+
else: # Platform-specific: Python 3
|
| 774 |
+
|
| 775 |
+
def makefile(self, mode="r", buffering=None, *args, **kwargs):
|
| 776 |
+
# We disable buffering with SecureTransport because it conflicts with
|
| 777 |
+
# the buffering that ST does internally (see issue #1153 for more).
|
| 778 |
+
buffering = 0
|
| 779 |
+
return backport_makefile(self, mode, buffering, *args, **kwargs)
|
| 780 |
+
|
| 781 |
+
|
| 782 |
+
WrappedSocket.makefile = makefile
|
| 783 |
+
|
| 784 |
+
|
| 785 |
+
class SecureTransportContext(object):
|
| 786 |
+
"""
|
| 787 |
+
I am a wrapper class for the SecureTransport library, to translate the
|
| 788 |
+
interface of the standard library ``SSLContext`` object to calls into
|
| 789 |
+
SecureTransport.
|
| 790 |
+
"""
|
| 791 |
+
|
| 792 |
+
def __init__(self, protocol):
|
| 793 |
+
self._min_version, self._max_version = _protocol_to_min_max[protocol]
|
| 794 |
+
self._options = 0
|
| 795 |
+
self._verify = False
|
| 796 |
+
self._trust_bundle = None
|
| 797 |
+
self._client_cert = None
|
| 798 |
+
self._client_key = None
|
| 799 |
+
self._client_key_passphrase = None
|
| 800 |
+
self._alpn_protocols = None
|
| 801 |
+
|
| 802 |
+
@property
|
| 803 |
+
def check_hostname(self):
|
| 804 |
+
"""
|
| 805 |
+
SecureTransport cannot have its hostname checking disabled. For more,
|
| 806 |
+
see the comment on getpeercert() in this file.
|
| 807 |
+
"""
|
| 808 |
+
return True
|
| 809 |
+
|
| 810 |
+
@check_hostname.setter
|
| 811 |
+
def check_hostname(self, value):
|
| 812 |
+
"""
|
| 813 |
+
SecureTransport cannot have its hostname checking disabled. For more,
|
| 814 |
+
see the comment on getpeercert() in this file.
|
| 815 |
+
"""
|
| 816 |
+
pass
|
| 817 |
+
|
| 818 |
+
@property
|
| 819 |
+
def options(self):
|
| 820 |
+
# TODO: Well, crap.
|
| 821 |
+
#
|
| 822 |
+
# So this is the bit of the code that is the most likely to cause us
|
| 823 |
+
# trouble. Essentially we need to enumerate all of the SSL options that
|
| 824 |
+
# users might want to use and try to see if we can sensibly translate
|
| 825 |
+
# them, or whether we should just ignore them.
|
| 826 |
+
return self._options
|
| 827 |
+
|
| 828 |
+
@options.setter
|
| 829 |
+
def options(self, value):
|
| 830 |
+
# TODO: Update in line with above.
|
| 831 |
+
self._options = value
|
| 832 |
+
|
| 833 |
+
@property
|
| 834 |
+
def verify_mode(self):
|
| 835 |
+
return ssl.CERT_REQUIRED if self._verify else ssl.CERT_NONE
|
| 836 |
+
|
| 837 |
+
@verify_mode.setter
|
| 838 |
+
def verify_mode(self, value):
|
| 839 |
+
self._verify = True if value == ssl.CERT_REQUIRED else False
|
| 840 |
+
|
| 841 |
+
def set_default_verify_paths(self):
|
| 842 |
+
# So, this has to do something a bit weird. Specifically, what it does
|
| 843 |
+
# is nothing.
|
| 844 |
+
#
|
| 845 |
+
# This means that, if we had previously had load_verify_locations
|
| 846 |
+
# called, this does not undo that. We need to do that because it turns
|
| 847 |
+
# out that the rest of the urllib3 code will attempt to load the
|
| 848 |
+
# default verify paths if it hasn't been told about any paths, even if
|
| 849 |
+
# the context itself was sometime earlier. We resolve that by just
|
| 850 |
+
# ignoring it.
|
| 851 |
+
pass
|
| 852 |
+
|
| 853 |
+
def load_default_certs(self):
|
| 854 |
+
return self.set_default_verify_paths()
|
| 855 |
+
|
| 856 |
+
def set_ciphers(self, ciphers):
|
| 857 |
+
# For now, we just require the default cipher string.
|
| 858 |
+
if ciphers != util.ssl_.DEFAULT_CIPHERS:
|
| 859 |
+
raise ValueError("SecureTransport doesn't support custom cipher strings")
|
| 860 |
+
|
| 861 |
+
def load_verify_locations(self, cafile=None, capath=None, cadata=None):
|
| 862 |
+
# OK, we only really support cadata and cafile.
|
| 863 |
+
if capath is not None:
|
| 864 |
+
raise ValueError("SecureTransport does not support cert directories")
|
| 865 |
+
|
| 866 |
+
# Raise if cafile does not exist.
|
| 867 |
+
if cafile is not None:
|
| 868 |
+
with open(cafile):
|
| 869 |
+
pass
|
| 870 |
+
|
| 871 |
+
self._trust_bundle = cafile or cadata
|
| 872 |
+
|
| 873 |
+
def load_cert_chain(self, certfile, keyfile=None, password=None):
|
| 874 |
+
self._client_cert = certfile
|
| 875 |
+
self._client_key = keyfile
|
| 876 |
+
self._client_cert_passphrase = password
|
| 877 |
+
|
| 878 |
+
def set_alpn_protocols(self, protocols):
|
| 879 |
+
"""
|
| 880 |
+
Sets the ALPN protocols that will later be set on the context.
|
| 881 |
+
|
| 882 |
+
Raises a NotImplementedError if ALPN is not supported.
|
| 883 |
+
"""
|
| 884 |
+
if not hasattr(Security, "SSLSetALPNProtocols"):
|
| 885 |
+
raise NotImplementedError(
|
| 886 |
+
"SecureTransport supports ALPN only in macOS 10.12+"
|
| 887 |
+
)
|
| 888 |
+
self._alpn_protocols = [six.ensure_binary(p) for p in protocols]
|
| 889 |
+
|
| 890 |
+
def wrap_socket(
|
| 891 |
+
self,
|
| 892 |
+
sock,
|
| 893 |
+
server_side=False,
|
| 894 |
+
do_handshake_on_connect=True,
|
| 895 |
+
suppress_ragged_eofs=True,
|
| 896 |
+
server_hostname=None,
|
| 897 |
+
):
|
| 898 |
+
# So, what do we do here? Firstly, we assert some properties. This is a
|
| 899 |
+
# stripped down shim, so there is some functionality we don't support.
|
| 900 |
+
# See PEP 543 for the real deal.
|
| 901 |
+
assert not server_side
|
| 902 |
+
assert do_handshake_on_connect
|
| 903 |
+
assert suppress_ragged_eofs
|
| 904 |
+
|
| 905 |
+
# Ok, we're good to go. Now we want to create the wrapped socket object
|
| 906 |
+
# and store it in the appropriate place.
|
| 907 |
+
wrapped_socket = WrappedSocket(sock)
|
| 908 |
+
|
| 909 |
+
# Now we can handshake
|
| 910 |
+
wrapped_socket.handshake(
|
| 911 |
+
server_hostname,
|
| 912 |
+
self._verify,
|
| 913 |
+
self._trust_bundle,
|
| 914 |
+
self._min_version,
|
| 915 |
+
self._max_version,
|
| 916 |
+
self._client_cert,
|
| 917 |
+
self._client_key,
|
| 918 |
+
self._client_key_passphrase,
|
| 919 |
+
self._alpn_protocols,
|
| 920 |
+
)
|
| 921 |
+
return wrapped_socket
|
.venv/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""
|
| 3 |
+
This module contains provisional support for SOCKS proxies from within
|
| 4 |
+
urllib3. This module supports SOCKS4, SOCKS4A (an extension of SOCKS4), and
|
| 5 |
+
SOCKS5. To enable its functionality, either install PySocks or install this
|
| 6 |
+
module with the ``socks`` extra.
|
| 7 |
+
|
| 8 |
+
The SOCKS implementation supports the full range of urllib3 features. It also
|
| 9 |
+
supports the following SOCKS features:
|
| 10 |
+
|
| 11 |
+
- SOCKS4A (``proxy_url='socks4a://...``)
|
| 12 |
+
- SOCKS4 (``proxy_url='socks4://...``)
|
| 13 |
+
- SOCKS5 with remote DNS (``proxy_url='socks5h://...``)
|
| 14 |
+
- SOCKS5 with local DNS (``proxy_url='socks5://...``)
|
| 15 |
+
- Usernames and passwords for the SOCKS proxy
|
| 16 |
+
|
| 17 |
+
.. note::
|
| 18 |
+
It is recommended to use ``socks5h://`` or ``socks4a://`` schemes in
|
| 19 |
+
your ``proxy_url`` to ensure that DNS resolution is done from the remote
|
| 20 |
+
server instead of client-side when connecting to a domain name.
|
| 21 |
+
|
| 22 |
+
SOCKS4 supports IPv4 and domain names with the SOCKS4A extension. SOCKS5
|
| 23 |
+
supports IPv4, IPv6, and domain names.
|
| 24 |
+
|
| 25 |
+
When connecting to a SOCKS4 proxy the ``username`` portion of the ``proxy_url``
|
| 26 |
+
will be sent as the ``userid`` section of the SOCKS request:
|
| 27 |
+
|
| 28 |
+
.. code-block:: python
|
| 29 |
+
|
| 30 |
+
proxy_url="socks4a://<userid>@proxy-host"
|
| 31 |
+
|
| 32 |
+
When connecting to a SOCKS5 proxy the ``username`` and ``password`` portion
|
| 33 |
+
of the ``proxy_url`` will be sent as the username/password to authenticate
|
| 34 |
+
with the proxy:
|
| 35 |
+
|
| 36 |
+
.. code-block:: python
|
| 37 |
+
|
| 38 |
+
proxy_url="socks5h://<username>:<password>@proxy-host"
|
| 39 |
+
|
| 40 |
+
"""
|
| 41 |
+
from __future__ import absolute_import
|
| 42 |
+
|
| 43 |
+
try:
|
| 44 |
+
import socks
|
| 45 |
+
except ImportError:
|
| 46 |
+
import warnings
|
| 47 |
+
|
| 48 |
+
from ..exceptions import DependencyWarning
|
| 49 |
+
|
| 50 |
+
warnings.warn(
|
| 51 |
+
(
|
| 52 |
+
"SOCKS support in urllib3 requires the installation of optional "
|
| 53 |
+
"dependencies: specifically, PySocks. For more information, see "
|
| 54 |
+
"https://urllib3.readthedocs.io/en/1.26.x/contrib.html#socks-proxies"
|
| 55 |
+
),
|
| 56 |
+
DependencyWarning,
|
| 57 |
+
)
|
| 58 |
+
raise
|
| 59 |
+
|
| 60 |
+
from socket import error as SocketError
|
| 61 |
+
from socket import timeout as SocketTimeout
|
| 62 |
+
|
| 63 |
+
from ..connection import HTTPConnection, HTTPSConnection
|
| 64 |
+
from ..connectionpool import HTTPConnectionPool, HTTPSConnectionPool
|
| 65 |
+
from ..exceptions import ConnectTimeoutError, NewConnectionError
|
| 66 |
+
from ..poolmanager import PoolManager
|
| 67 |
+
from ..util.url import parse_url
|
| 68 |
+
|
| 69 |
+
try:
|
| 70 |
+
import ssl
|
| 71 |
+
except ImportError:
|
| 72 |
+
ssl = None
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class SOCKSConnection(HTTPConnection):
|
| 76 |
+
"""
|
| 77 |
+
A plain-text HTTP connection that connects via a SOCKS proxy.
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
def __init__(self, *args, **kwargs):
|
| 81 |
+
self._socks_options = kwargs.pop("_socks_options")
|
| 82 |
+
super(SOCKSConnection, self).__init__(*args, **kwargs)
|
| 83 |
+
|
| 84 |
+
def _new_conn(self):
|
| 85 |
+
"""
|
| 86 |
+
Establish a new connection via the SOCKS proxy.
|
| 87 |
+
"""
|
| 88 |
+
extra_kw = {}
|
| 89 |
+
if self.source_address:
|
| 90 |
+
extra_kw["source_address"] = self.source_address
|
| 91 |
+
|
| 92 |
+
if self.socket_options:
|
| 93 |
+
extra_kw["socket_options"] = self.socket_options
|
| 94 |
+
|
| 95 |
+
try:
|
| 96 |
+
conn = socks.create_connection(
|
| 97 |
+
(self.host, self.port),
|
| 98 |
+
proxy_type=self._socks_options["socks_version"],
|
| 99 |
+
proxy_addr=self._socks_options["proxy_host"],
|
| 100 |
+
proxy_port=self._socks_options["proxy_port"],
|
| 101 |
+
proxy_username=self._socks_options["username"],
|
| 102 |
+
proxy_password=self._socks_options["password"],
|
| 103 |
+
proxy_rdns=self._socks_options["rdns"],
|
| 104 |
+
timeout=self.timeout,
|
| 105 |
+
**extra_kw
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
except SocketTimeout:
|
| 109 |
+
raise ConnectTimeoutError(
|
| 110 |
+
self,
|
| 111 |
+
"Connection to %s timed out. (connect timeout=%s)"
|
| 112 |
+
% (self.host, self.timeout),
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
except socks.ProxyError as e:
|
| 116 |
+
# This is fragile as hell, but it seems to be the only way to raise
|
| 117 |
+
# useful errors here.
|
| 118 |
+
if e.socket_err:
|
| 119 |
+
error = e.socket_err
|
| 120 |
+
if isinstance(error, SocketTimeout):
|
| 121 |
+
raise ConnectTimeoutError(
|
| 122 |
+
self,
|
| 123 |
+
"Connection to %s timed out. (connect timeout=%s)"
|
| 124 |
+
% (self.host, self.timeout),
|
| 125 |
+
)
|
| 126 |
+
else:
|
| 127 |
+
raise NewConnectionError(
|
| 128 |
+
self, "Failed to establish a new connection: %s" % error
|
| 129 |
+
)
|
| 130 |
+
else:
|
| 131 |
+
raise NewConnectionError(
|
| 132 |
+
self, "Failed to establish a new connection: %s" % e
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
except SocketError as e: # Defensive: PySocks should catch all these.
|
| 136 |
+
raise NewConnectionError(
|
| 137 |
+
self, "Failed to establish a new connection: %s" % e
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
return conn
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
# We don't need to duplicate the Verified/Unverified distinction from
|
| 144 |
+
# urllib3/connection.py here because the HTTPSConnection will already have been
|
| 145 |
+
# correctly set to either the Verified or Unverified form by that module. This
|
| 146 |
+
# means the SOCKSHTTPSConnection will automatically be the correct type.
|
| 147 |
+
class SOCKSHTTPSConnection(SOCKSConnection, HTTPSConnection):
|
| 148 |
+
pass
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
class SOCKSHTTPConnectionPool(HTTPConnectionPool):
|
| 152 |
+
ConnectionCls = SOCKSConnection
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
class SOCKSHTTPSConnectionPool(HTTPSConnectionPool):
|
| 156 |
+
ConnectionCls = SOCKSHTTPSConnection
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
class SOCKSProxyManager(PoolManager):
|
| 160 |
+
"""
|
| 161 |
+
A version of the urllib3 ProxyManager that routes connections via the
|
| 162 |
+
defined SOCKS proxy.
|
| 163 |
+
"""
|
| 164 |
+
|
| 165 |
+
pool_classes_by_scheme = {
|
| 166 |
+
"http": SOCKSHTTPConnectionPool,
|
| 167 |
+
"https": SOCKSHTTPSConnectionPool,
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
def __init__(
|
| 171 |
+
self,
|
| 172 |
+
proxy_url,
|
| 173 |
+
username=None,
|
| 174 |
+
password=None,
|
| 175 |
+
num_pools=10,
|
| 176 |
+
headers=None,
|
| 177 |
+
**connection_pool_kw
|
| 178 |
+
):
|
| 179 |
+
parsed = parse_url(proxy_url)
|
| 180 |
+
|
| 181 |
+
if username is None and password is None and parsed.auth is not None:
|
| 182 |
+
split = parsed.auth.split(":")
|
| 183 |
+
if len(split) == 2:
|
| 184 |
+
username, password = split
|
| 185 |
+
if parsed.scheme == "socks5":
|
| 186 |
+
socks_version = socks.PROXY_TYPE_SOCKS5
|
| 187 |
+
rdns = False
|
| 188 |
+
elif parsed.scheme == "socks5h":
|
| 189 |
+
socks_version = socks.PROXY_TYPE_SOCKS5
|
| 190 |
+
rdns = True
|
| 191 |
+
elif parsed.scheme == "socks4":
|
| 192 |
+
socks_version = socks.PROXY_TYPE_SOCKS4
|
| 193 |
+
rdns = False
|
| 194 |
+
elif parsed.scheme == "socks4a":
|
| 195 |
+
socks_version = socks.PROXY_TYPE_SOCKS4
|
| 196 |
+
rdns = True
|
| 197 |
+
else:
|
| 198 |
+
raise ValueError("Unable to determine SOCKS version from %s" % proxy_url)
|
| 199 |
+
|
| 200 |
+
self.proxy_url = proxy_url
|
| 201 |
+
|
| 202 |
+
socks_options = {
|
| 203 |
+
"socks_version": socks_version,
|
| 204 |
+
"proxy_host": parsed.host,
|
| 205 |
+
"proxy_port": parsed.port,
|
| 206 |
+
"username": username,
|
| 207 |
+
"password": password,
|
| 208 |
+
"rdns": rdns,
|
| 209 |
+
}
|
| 210 |
+
connection_pool_kw["_socks_options"] = socks_options
|
| 211 |
+
|
| 212 |
+
super(SOCKSProxyManager, self).__init__(
|
| 213 |
+
num_pools, headers, **connection_pool_kw
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
self.pool_classes_by_scheme = SOCKSProxyManager.pool_classes_by_scheme
|
.venv/Lib/site-packages/pip/_vendor/urllib3/exceptions.py
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import absolute_import
|
| 2 |
+
|
| 3 |
+
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
|
| 4 |
+
|
| 5 |
+
# Base Exceptions
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class HTTPError(Exception):
|
| 9 |
+
"""Base exception used by this module."""
|
| 10 |
+
|
| 11 |
+
pass
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class HTTPWarning(Warning):
|
| 15 |
+
"""Base warning used by this module."""
|
| 16 |
+
|
| 17 |
+
pass
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class PoolError(HTTPError):
|
| 21 |
+
"""Base exception for errors caused within a pool."""
|
| 22 |
+
|
| 23 |
+
def __init__(self, pool, message):
|
| 24 |
+
self.pool = pool
|
| 25 |
+
HTTPError.__init__(self, "%s: %s" % (pool, message))
|
| 26 |
+
|
| 27 |
+
def __reduce__(self):
|
| 28 |
+
# For pickling purposes.
|
| 29 |
+
return self.__class__, (None, None)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class RequestError(PoolError):
|
| 33 |
+
"""Base exception for PoolErrors that have associated URLs."""
|
| 34 |
+
|
| 35 |
+
def __init__(self, pool, url, message):
|
| 36 |
+
self.url = url
|
| 37 |
+
PoolError.__init__(self, pool, message)
|
| 38 |
+
|
| 39 |
+
def __reduce__(self):
|
| 40 |
+
# For pickling purposes.
|
| 41 |
+
return self.__class__, (None, self.url, None)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class SSLError(HTTPError):
|
| 45 |
+
"""Raised when SSL certificate fails in an HTTPS connection."""
|
| 46 |
+
|
| 47 |
+
pass
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class ProxyError(HTTPError):
|
| 51 |
+
"""Raised when the connection to a proxy fails."""
|
| 52 |
+
|
| 53 |
+
def __init__(self, message, error, *args):
|
| 54 |
+
super(ProxyError, self).__init__(message, error, *args)
|
| 55 |
+
self.original_error = error
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class DecodeError(HTTPError):
|
| 59 |
+
"""Raised when automatic decoding based on Content-Type fails."""
|
| 60 |
+
|
| 61 |
+
pass
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class ProtocolError(HTTPError):
|
| 65 |
+
"""Raised when something unexpected happens mid-request/response."""
|
| 66 |
+
|
| 67 |
+
pass
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
#: Renamed to ProtocolError but aliased for backwards compatibility.
|
| 71 |
+
ConnectionError = ProtocolError
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
# Leaf Exceptions
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class MaxRetryError(RequestError):
|
| 78 |
+
"""Raised when the maximum number of retries is exceeded.
|
| 79 |
+
|
| 80 |
+
:param pool: The connection pool
|
| 81 |
+
:type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
|
| 82 |
+
:param string url: The requested Url
|
| 83 |
+
:param exceptions.Exception reason: The underlying error
|
| 84 |
+
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
def __init__(self, pool, url, reason=None):
|
| 88 |
+
self.reason = reason
|
| 89 |
+
|
| 90 |
+
message = "Max retries exceeded with url: %s (Caused by %r)" % (url, reason)
|
| 91 |
+
|
| 92 |
+
RequestError.__init__(self, pool, url, message)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
class HostChangedError(RequestError):
|
| 96 |
+
"""Raised when an existing pool gets a request for a foreign host."""
|
| 97 |
+
|
| 98 |
+
def __init__(self, pool, url, retries=3):
|
| 99 |
+
message = "Tried to open a foreign host with url: %s" % url
|
| 100 |
+
RequestError.__init__(self, pool, url, message)
|
| 101 |
+
self.retries = retries
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
class TimeoutStateError(HTTPError):
|
| 105 |
+
"""Raised when passing an invalid state to a timeout"""
|
| 106 |
+
|
| 107 |
+
pass
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
class TimeoutError(HTTPError):
|
| 111 |
+
"""Raised when a socket timeout error occurs.
|
| 112 |
+
|
| 113 |
+
Catching this error will catch both :exc:`ReadTimeoutErrors
|
| 114 |
+
<ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
|
| 115 |
+
"""
|
| 116 |
+
|
| 117 |
+
pass
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class ReadTimeoutError(TimeoutError, RequestError):
|
| 121 |
+
"""Raised when a socket timeout occurs while receiving data from a server"""
|
| 122 |
+
|
| 123 |
+
pass
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
# This timeout error does not have a URL attached and needs to inherit from the
|
| 127 |
+
# base HTTPError
|
| 128 |
+
class ConnectTimeoutError(TimeoutError):
|
| 129 |
+
"""Raised when a socket timeout occurs while connecting to a server"""
|
| 130 |
+
|
| 131 |
+
pass
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
class NewConnectionError(ConnectTimeoutError, PoolError):
|
| 135 |
+
"""Raised when we fail to establish a new connection. Usually ECONNREFUSED."""
|
| 136 |
+
|
| 137 |
+
pass
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class EmptyPoolError(PoolError):
|
| 141 |
+
"""Raised when a pool runs out of connections and no more are allowed."""
|
| 142 |
+
|
| 143 |
+
pass
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
class ClosedPoolError(PoolError):
|
| 147 |
+
"""Raised when a request enters a pool after the pool has been closed."""
|
| 148 |
+
|
| 149 |
+
pass
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
class LocationValueError(ValueError, HTTPError):
|
| 153 |
+
"""Raised when there is something wrong with a given URL input."""
|
| 154 |
+
|
| 155 |
+
pass
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
class LocationParseError(LocationValueError):
|
| 159 |
+
"""Raised when get_host or similar fails to parse the URL input."""
|
| 160 |
+
|
| 161 |
+
def __init__(self, location):
|
| 162 |
+
message = "Failed to parse: %s" % location
|
| 163 |
+
HTTPError.__init__(self, message)
|
| 164 |
+
|
| 165 |
+
self.location = location
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
class URLSchemeUnknown(LocationValueError):
|
| 169 |
+
"""Raised when a URL input has an unsupported scheme."""
|
| 170 |
+
|
| 171 |
+
def __init__(self, scheme):
|
| 172 |
+
message = "Not supported URL scheme %s" % scheme
|
| 173 |
+
super(URLSchemeUnknown, self).__init__(message)
|
| 174 |
+
|
| 175 |
+
self.scheme = scheme
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
class ResponseError(HTTPError):
|
| 179 |
+
"""Used as a container for an error reason supplied in a MaxRetryError."""
|
| 180 |
+
|
| 181 |
+
GENERIC_ERROR = "too many error responses"
|
| 182 |
+
SPECIFIC_ERROR = "too many {status_code} error responses"
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
class SecurityWarning(HTTPWarning):
|
| 186 |
+
"""Warned when performing security reducing actions"""
|
| 187 |
+
|
| 188 |
+
pass
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
class SubjectAltNameWarning(SecurityWarning):
|
| 192 |
+
"""Warned when connecting to a host with a certificate missing a SAN."""
|
| 193 |
+
|
| 194 |
+
pass
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
class InsecureRequestWarning(SecurityWarning):
|
| 198 |
+
"""Warned when making an unverified HTTPS request."""
|
| 199 |
+
|
| 200 |
+
pass
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
class SystemTimeWarning(SecurityWarning):
|
| 204 |
+
"""Warned when system time is suspected to be wrong"""
|
| 205 |
+
|
| 206 |
+
pass
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
class InsecurePlatformWarning(SecurityWarning):
|
| 210 |
+
"""Warned when certain TLS/SSL configuration is not available on a platform."""
|
| 211 |
+
|
| 212 |
+
pass
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
class SNIMissingWarning(HTTPWarning):
|
| 216 |
+
"""Warned when making a HTTPS request without SNI available."""
|
| 217 |
+
|
| 218 |
+
pass
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
class DependencyWarning(HTTPWarning):
|
| 222 |
+
"""
|
| 223 |
+
Warned when an attempt is made to import a module with missing optional
|
| 224 |
+
dependencies.
|
| 225 |
+
"""
|
| 226 |
+
|
| 227 |
+
pass
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
class ResponseNotChunked(ProtocolError, ValueError):
|
| 231 |
+
"""Response needs to be chunked in order to read it as chunks."""
|
| 232 |
+
|
| 233 |
+
pass
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
class BodyNotHttplibCompatible(HTTPError):
|
| 237 |
+
"""
|
| 238 |
+
Body should be :class:`http.client.HTTPResponse` like
|
| 239 |
+
(have an fp attribute which returns raw chunks) for read_chunked().
|
| 240 |
+
"""
|
| 241 |
+
|
| 242 |
+
pass
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
class IncompleteRead(HTTPError, httplib_IncompleteRead):
|
| 246 |
+
"""
|
| 247 |
+
Response length doesn't match expected Content-Length
|
| 248 |
+
|
| 249 |
+
Subclass of :class:`http.client.IncompleteRead` to allow int value
|
| 250 |
+
for ``partial`` to avoid creating large objects on streamed reads.
|
| 251 |
+
"""
|
| 252 |
+
|
| 253 |
+
def __init__(self, partial, expected):
|
| 254 |
+
super(IncompleteRead, self).__init__(partial, expected)
|
| 255 |
+
|
| 256 |
+
def __repr__(self):
|
| 257 |
+
return "IncompleteRead(%i bytes read, %i more expected)" % (
|
| 258 |
+
self.partial,
|
| 259 |
+
self.expected,
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
class InvalidChunkLength(HTTPError, httplib_IncompleteRead):
|
| 264 |
+
"""Invalid chunk length in a chunked response."""
|
| 265 |
+
|
| 266 |
+
def __init__(self, response, length):
|
| 267 |
+
super(InvalidChunkLength, self).__init__(
|
| 268 |
+
response.tell(), response.length_remaining
|
| 269 |
+
)
|
| 270 |
+
self.response = response
|
| 271 |
+
self.length = length
|
| 272 |
+
|
| 273 |
+
def __repr__(self):
|
| 274 |
+
return "InvalidChunkLength(got length %r, %i bytes read)" % (
|
| 275 |
+
self.length,
|
| 276 |
+
self.partial,
|
| 277 |
+
)
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
class InvalidHeader(HTTPError):
|
| 281 |
+
"""The header provided was somehow invalid."""
|
| 282 |
+
|
| 283 |
+
pass
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
class ProxySchemeUnknown(AssertionError, URLSchemeUnknown):
|
| 287 |
+
"""ProxyManager does not support the supplied scheme"""
|
| 288 |
+
|
| 289 |
+
# TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
|
| 290 |
+
|
| 291 |
+
def __init__(self, scheme):
|
| 292 |
+
# 'localhost' is here because our URL parser parses
|
| 293 |
+
# localhost:8080 -> scheme=localhost, remove if we fix this.
|
| 294 |
+
if scheme == "localhost":
|
| 295 |
+
scheme = None
|
| 296 |
+
if scheme is None:
|
| 297 |
+
message = "Proxy URL had no scheme, should start with http:// or https://"
|
| 298 |
+
else:
|
| 299 |
+
message = (
|
| 300 |
+
"Proxy URL had unsupported scheme %s, should use http:// or https://"
|
| 301 |
+
% scheme
|
| 302 |
+
)
|
| 303 |
+
super(ProxySchemeUnknown, self).__init__(message)
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
class ProxySchemeUnsupported(ValueError):
|
| 307 |
+
"""Fetching HTTPS resources through HTTPS proxies is unsupported"""
|
| 308 |
+
|
| 309 |
+
pass
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
class HeaderParsingError(HTTPError):
|
| 313 |
+
"""Raised by assert_header_parsing, but we convert it to a log.warning statement."""
|
| 314 |
+
|
| 315 |
+
def __init__(self, defects, unparsed_data):
|
| 316 |
+
message = "%s, unparsed data: %r" % (defects or "Unknown", unparsed_data)
|
| 317 |
+
super(HeaderParsingError, self).__init__(message)
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
class UnrewindableBodyError(HTTPError):
|
| 321 |
+
"""urllib3 encountered an error when trying to rewind a body"""
|
| 322 |
+
|
| 323 |
+
pass
|
.venv/Lib/site-packages/pip/_vendor/urllib3/fields.py
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import absolute_import
|
| 2 |
+
|
| 3 |
+
import email.utils
|
| 4 |
+
import mimetypes
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
from .packages import six
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def guess_content_type(filename, default="application/octet-stream"):
|
| 11 |
+
"""
|
| 12 |
+
Guess the "Content-Type" of a file.
|
| 13 |
+
|
| 14 |
+
:param filename:
|
| 15 |
+
The filename to guess the "Content-Type" of using :mod:`mimetypes`.
|
| 16 |
+
:param default:
|
| 17 |
+
If no "Content-Type" can be guessed, default to `default`.
|
| 18 |
+
"""
|
| 19 |
+
if filename:
|
| 20 |
+
return mimetypes.guess_type(filename)[0] or default
|
| 21 |
+
return default
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def format_header_param_rfc2231(name, value):
|
| 25 |
+
"""
|
| 26 |
+
Helper function to format and quote a single header parameter using the
|
| 27 |
+
strategy defined in RFC 2231.
|
| 28 |
+
|
| 29 |
+
Particularly useful for header parameters which might contain
|
| 30 |
+
non-ASCII values, like file names. This follows
|
| 31 |
+
`RFC 2388 Section 4.4 <https://tools.ietf.org/html/rfc2388#section-4.4>`_.
|
| 32 |
+
|
| 33 |
+
:param name:
|
| 34 |
+
The name of the parameter, a string expected to be ASCII only.
|
| 35 |
+
:param value:
|
| 36 |
+
The value of the parameter, provided as ``bytes`` or `str``.
|
| 37 |
+
:ret:
|
| 38 |
+
An RFC-2231-formatted unicode string.
|
| 39 |
+
"""
|
| 40 |
+
if isinstance(value, six.binary_type):
|
| 41 |
+
value = value.decode("utf-8")
|
| 42 |
+
|
| 43 |
+
if not any(ch in value for ch in '"\\\r\n'):
|
| 44 |
+
result = u'%s="%s"' % (name, value)
|
| 45 |
+
try:
|
| 46 |
+
result.encode("ascii")
|
| 47 |
+
except (UnicodeEncodeError, UnicodeDecodeError):
|
| 48 |
+
pass
|
| 49 |
+
else:
|
| 50 |
+
return result
|
| 51 |
+
|
| 52 |
+
if six.PY2: # Python 2:
|
| 53 |
+
value = value.encode("utf-8")
|
| 54 |
+
|
| 55 |
+
# encode_rfc2231 accepts an encoded string and returns an ascii-encoded
|
| 56 |
+
# string in Python 2 but accepts and returns unicode strings in Python 3
|
| 57 |
+
value = email.utils.encode_rfc2231(value, "utf-8")
|
| 58 |
+
value = "%s*=%s" % (name, value)
|
| 59 |
+
|
| 60 |
+
if six.PY2: # Python 2:
|
| 61 |
+
value = value.decode("utf-8")
|
| 62 |
+
|
| 63 |
+
return value
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
_HTML5_REPLACEMENTS = {
|
| 67 |
+
u"\u0022": u"%22",
|
| 68 |
+
# Replace "\" with "\\".
|
| 69 |
+
u"\u005C": u"\u005C\u005C",
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
# All control characters from 0x00 to 0x1F *except* 0x1B.
|
| 73 |
+
_HTML5_REPLACEMENTS.update(
|
| 74 |
+
{
|
| 75 |
+
six.unichr(cc): u"%{:02X}".format(cc)
|
| 76 |
+
for cc in range(0x00, 0x1F + 1)
|
| 77 |
+
if cc not in (0x1B,)
|
| 78 |
+
}
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def _replace_multiple(value, needles_and_replacements):
|
| 83 |
+
def replacer(match):
|
| 84 |
+
return needles_and_replacements[match.group(0)]
|
| 85 |
+
|
| 86 |
+
pattern = re.compile(
|
| 87 |
+
r"|".join([re.escape(needle) for needle in needles_and_replacements.keys()])
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
result = pattern.sub(replacer, value)
|
| 91 |
+
|
| 92 |
+
return result
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def format_header_param_html5(name, value):
|
| 96 |
+
"""
|
| 97 |
+
Helper function to format and quote a single header parameter using the
|
| 98 |
+
HTML5 strategy.
|
| 99 |
+
|
| 100 |
+
Particularly useful for header parameters which might contain
|
| 101 |
+
non-ASCII values, like file names. This follows the `HTML5 Working Draft
|
| 102 |
+
Section 4.10.22.7`_ and matches the behavior of curl and modern browsers.
|
| 103 |
+
|
| 104 |
+
.. _HTML5 Working Draft Section 4.10.22.7:
|
| 105 |
+
https://w3c.github.io/html/sec-forms.html#multipart-form-data
|
| 106 |
+
|
| 107 |
+
:param name:
|
| 108 |
+
The name of the parameter, a string expected to be ASCII only.
|
| 109 |
+
:param value:
|
| 110 |
+
The value of the parameter, provided as ``bytes`` or `str``.
|
| 111 |
+
:ret:
|
| 112 |
+
A unicode string, stripped of troublesome characters.
|
| 113 |
+
"""
|
| 114 |
+
if isinstance(value, six.binary_type):
|
| 115 |
+
value = value.decode("utf-8")
|
| 116 |
+
|
| 117 |
+
value = _replace_multiple(value, _HTML5_REPLACEMENTS)
|
| 118 |
+
|
| 119 |
+
return u'%s="%s"' % (name, value)
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
# For backwards-compatibility.
|
| 123 |
+
format_header_param = format_header_param_html5
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
class RequestField(object):
|
| 127 |
+
"""
|
| 128 |
+
A data container for request body parameters.
|
| 129 |
+
|
| 130 |
+
:param name:
|
| 131 |
+
The name of this request field. Must be unicode.
|
| 132 |
+
:param data:
|
| 133 |
+
The data/value body.
|
| 134 |
+
:param filename:
|
| 135 |
+
An optional filename of the request field. Must be unicode.
|
| 136 |
+
:param headers:
|
| 137 |
+
An optional dict-like object of headers to initially use for the field.
|
| 138 |
+
:param header_formatter:
|
| 139 |
+
An optional callable that is used to encode and format the headers. By
|
| 140 |
+
default, this is :func:`format_header_param_html5`.
|
| 141 |
+
"""
|
| 142 |
+
|
| 143 |
+
def __init__(
|
| 144 |
+
self,
|
| 145 |
+
name,
|
| 146 |
+
data,
|
| 147 |
+
filename=None,
|
| 148 |
+
headers=None,
|
| 149 |
+
header_formatter=format_header_param_html5,
|
| 150 |
+
):
|
| 151 |
+
self._name = name
|
| 152 |
+
self._filename = filename
|
| 153 |
+
self.data = data
|
| 154 |
+
self.headers = {}
|
| 155 |
+
if headers:
|
| 156 |
+
self.headers = dict(headers)
|
| 157 |
+
self.header_formatter = header_formatter
|
| 158 |
+
|
| 159 |
+
@classmethod
|
| 160 |
+
def from_tuples(cls, fieldname, value, header_formatter=format_header_param_html5):
|
| 161 |
+
"""
|
| 162 |
+
A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
|
| 163 |
+
|
| 164 |
+
Supports constructing :class:`~urllib3.fields.RequestField` from
|
| 165 |
+
parameter of key/value strings AND key/filetuple. A filetuple is a
|
| 166 |
+
(filename, data, MIME type) tuple where the MIME type is optional.
|
| 167 |
+
For example::
|
| 168 |
+
|
| 169 |
+
'foo': 'bar',
|
| 170 |
+
'fakefile': ('foofile.txt', 'contents of foofile'),
|
| 171 |
+
'realfile': ('barfile.txt', open('realfile').read()),
|
| 172 |
+
'typedfile': ('bazfile.bin', open('bazfile').read(), 'image/jpeg'),
|
| 173 |
+
'nonamefile': 'contents of nonamefile field',
|
| 174 |
+
|
| 175 |
+
Field names and filenames must be unicode.
|
| 176 |
+
"""
|
| 177 |
+
if isinstance(value, tuple):
|
| 178 |
+
if len(value) == 3:
|
| 179 |
+
filename, data, content_type = value
|
| 180 |
+
else:
|
| 181 |
+
filename, data = value
|
| 182 |
+
content_type = guess_content_type(filename)
|
| 183 |
+
else:
|
| 184 |
+
filename = None
|
| 185 |
+
content_type = None
|
| 186 |
+
data = value
|
| 187 |
+
|
| 188 |
+
request_param = cls(
|
| 189 |
+
fieldname, data, filename=filename, header_formatter=header_formatter
|
| 190 |
+
)
|
| 191 |
+
request_param.make_multipart(content_type=content_type)
|
| 192 |
+
|
| 193 |
+
return request_param
|
| 194 |
+
|
| 195 |
+
def _render_part(self, name, value):
|
| 196 |
+
"""
|
| 197 |
+
Overridable helper function to format a single header parameter. By
|
| 198 |
+
default, this calls ``self.header_formatter``.
|
| 199 |
+
|
| 200 |
+
:param name:
|
| 201 |
+
The name of the parameter, a string expected to be ASCII only.
|
| 202 |
+
:param value:
|
| 203 |
+
The value of the parameter, provided as a unicode string.
|
| 204 |
+
"""
|
| 205 |
+
|
| 206 |
+
return self.header_formatter(name, value)
|
| 207 |
+
|
| 208 |
+
def _render_parts(self, header_parts):
|
| 209 |
+
"""
|
| 210 |
+
Helper function to format and quote a single header.
|
| 211 |
+
|
| 212 |
+
Useful for single headers that are composed of multiple items. E.g.,
|
| 213 |
+
'Content-Disposition' fields.
|
| 214 |
+
|
| 215 |
+
:param header_parts:
|
| 216 |
+
A sequence of (k, v) tuples or a :class:`dict` of (k, v) to format
|
| 217 |
+
as `k1="v1"; k2="v2"; ...`.
|
| 218 |
+
"""
|
| 219 |
+
parts = []
|
| 220 |
+
iterable = header_parts
|
| 221 |
+
if isinstance(header_parts, dict):
|
| 222 |
+
iterable = header_parts.items()
|
| 223 |
+
|
| 224 |
+
for name, value in iterable:
|
| 225 |
+
if value is not None:
|
| 226 |
+
parts.append(self._render_part(name, value))
|
| 227 |
+
|
| 228 |
+
return u"; ".join(parts)
|
| 229 |
+
|
| 230 |
+
def render_headers(self):
|
| 231 |
+
"""
|
| 232 |
+
Renders the headers for this request field.
|
| 233 |
+
"""
|
| 234 |
+
lines = []
|
| 235 |
+
|
| 236 |
+
sort_keys = ["Content-Disposition", "Content-Type", "Content-Location"]
|
| 237 |
+
for sort_key in sort_keys:
|
| 238 |
+
if self.headers.get(sort_key, False):
|
| 239 |
+
lines.append(u"%s: %s" % (sort_key, self.headers[sort_key]))
|
| 240 |
+
|
| 241 |
+
for header_name, header_value in self.headers.items():
|
| 242 |
+
if header_name not in sort_keys:
|
| 243 |
+
if header_value:
|
| 244 |
+
lines.append(u"%s: %s" % (header_name, header_value))
|
| 245 |
+
|
| 246 |
+
lines.append(u"\r\n")
|
| 247 |
+
return u"\r\n".join(lines)
|
| 248 |
+
|
| 249 |
+
def make_multipart(
|
| 250 |
+
self, content_disposition=None, content_type=None, content_location=None
|
| 251 |
+
):
|
| 252 |
+
"""
|
| 253 |
+
Makes this request field into a multipart request field.
|
| 254 |
+
|
| 255 |
+
This method overrides "Content-Disposition", "Content-Type" and
|
| 256 |
+
"Content-Location" headers to the request parameter.
|
| 257 |
+
|
| 258 |
+
:param content_type:
|
| 259 |
+
The 'Content-Type' of the request body.
|
| 260 |
+
:param content_location:
|
| 261 |
+
The 'Content-Location' of the request body.
|
| 262 |
+
|
| 263 |
+
"""
|
| 264 |
+
self.headers["Content-Disposition"] = content_disposition or u"form-data"
|
| 265 |
+
self.headers["Content-Disposition"] += u"; ".join(
|
| 266 |
+
[
|
| 267 |
+
u"",
|
| 268 |
+
self._render_parts(
|
| 269 |
+
((u"name", self._name), (u"filename", self._filename))
|
| 270 |
+
),
|
| 271 |
+
]
|
| 272 |
+
)
|
| 273 |
+
self.headers["Content-Type"] = content_type
|
| 274 |
+
self.headers["Content-Location"] = content_location
|
.venv/Lib/site-packages/pip/_vendor/urllib3/filepost.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import absolute_import
|
| 2 |
+
|
| 3 |
+
import binascii
|
| 4 |
+
import codecs
|
| 5 |
+
import os
|
| 6 |
+
from io import BytesIO
|
| 7 |
+
|
| 8 |
+
from .fields import RequestField
|
| 9 |
+
from .packages import six
|
| 10 |
+
from .packages.six import b
|
| 11 |
+
|
| 12 |
+
writer = codecs.lookup("utf-8")[3]
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def choose_boundary():
|
| 16 |
+
"""
|
| 17 |
+
Our embarrassingly-simple replacement for mimetools.choose_boundary.
|
| 18 |
+
"""
|
| 19 |
+
boundary = binascii.hexlify(os.urandom(16))
|
| 20 |
+
if not six.PY2:
|
| 21 |
+
boundary = boundary.decode("ascii")
|
| 22 |
+
return boundary
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def iter_field_objects(fields):
|
| 26 |
+
"""
|
| 27 |
+
Iterate over fields.
|
| 28 |
+
|
| 29 |
+
Supports list of (k, v) tuples and dicts, and lists of
|
| 30 |
+
:class:`~urllib3.fields.RequestField`.
|
| 31 |
+
|
| 32 |
+
"""
|
| 33 |
+
if isinstance(fields, dict):
|
| 34 |
+
i = six.iteritems(fields)
|
| 35 |
+
else:
|
| 36 |
+
i = iter(fields)
|
| 37 |
+
|
| 38 |
+
for field in i:
|
| 39 |
+
if isinstance(field, RequestField):
|
| 40 |
+
yield field
|
| 41 |
+
else:
|
| 42 |
+
yield RequestField.from_tuples(*field)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def iter_fields(fields):
|
| 46 |
+
"""
|
| 47 |
+
.. deprecated:: 1.6
|
| 48 |
+
|
| 49 |
+
Iterate over fields.
|
| 50 |
+
|
| 51 |
+
The addition of :class:`~urllib3.fields.RequestField` makes this function
|
| 52 |
+
obsolete. Instead, use :func:`iter_field_objects`, which returns
|
| 53 |
+
:class:`~urllib3.fields.RequestField` objects.
|
| 54 |
+
|
| 55 |
+
Supports list of (k, v) tuples and dicts.
|
| 56 |
+
"""
|
| 57 |
+
if isinstance(fields, dict):
|
| 58 |
+
return ((k, v) for k, v in six.iteritems(fields))
|
| 59 |
+
|
| 60 |
+
return ((k, v) for k, v in fields)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def encode_multipart_formdata(fields, boundary=None):
|
| 64 |
+
"""
|
| 65 |
+
Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
|
| 66 |
+
|
| 67 |
+
:param fields:
|
| 68 |
+
Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
|
| 69 |
+
|
| 70 |
+
:param boundary:
|
| 71 |
+
If not specified, then a random boundary will be generated using
|
| 72 |
+
:func:`urllib3.filepost.choose_boundary`.
|
| 73 |
+
"""
|
| 74 |
+
body = BytesIO()
|
| 75 |
+
if boundary is None:
|
| 76 |
+
boundary = choose_boundary()
|
| 77 |
+
|
| 78 |
+
for field in iter_field_objects(fields):
|
| 79 |
+
body.write(b("--%s\r\n" % (boundary)))
|
| 80 |
+
|
| 81 |
+
writer(body).write(field.render_headers())
|
| 82 |
+
data = field.data
|
| 83 |
+
|
| 84 |
+
if isinstance(data, int):
|
| 85 |
+
data = str(data) # Backwards compatibility
|
| 86 |
+
|
| 87 |
+
if isinstance(data, six.text_type):
|
| 88 |
+
writer(body).write(data)
|
| 89 |
+
else:
|
| 90 |
+
body.write(data)
|
| 91 |
+
|
| 92 |
+
body.write(b"\r\n")
|
| 93 |
+
|
| 94 |
+
body.write(b("--%s--\r\n" % (boundary)))
|
| 95 |
+
|
| 96 |
+
content_type = str("multipart/form-data; boundary=%s" % boundary)
|
| 97 |
+
|
| 98 |
+
return body.getvalue(), content_type
|
.venv/Lib/site-packages/pip/_vendor/urllib3/packages/__init__.py
ADDED
|
File without changes
|
.venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py
ADDED
|
File without changes
|