com.googler.python 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/package.json +1 -1
  2. package/python3.4.2/lib/python3.4/site-packages/pip/__init__.py +1 -277
  3. package/python3.4.2/lib/python3.4/site-packages/pip/__main__.py +19 -7
  4. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/__init__.py +246 -0
  5. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/basecommand.py +373 -0
  6. package/python3.4.2/lib/python3.4/site-packages/pip/{baseparser.py → _internal/baseparser.py} +240 -224
  7. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/build_env.py +92 -0
  8. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/cache.py +202 -0
  9. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/cmdoptions.py +609 -0
  10. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/__init__.py +79 -0
  11. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/check.py +42 -0
  12. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/completion.py +94 -0
  13. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/configuration.py +227 -0
  14. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/download.py +233 -0
  15. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/freeze.py +96 -0
  16. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/hash.py +57 -0
  17. package/python3.4.2/lib/python3.4/site-packages/pip/{commands → _internal/commands}/help.py +36 -33
  18. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/install.py +477 -0
  19. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/list.py +343 -0
  20. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/search.py +135 -0
  21. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/show.py +164 -0
  22. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/uninstall.py +71 -0
  23. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/commands/wheel.py +179 -0
  24. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/compat.py +235 -0
  25. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/configuration.py +378 -0
  26. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/download.py +922 -0
  27. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/exceptions.py +249 -0
  28. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/index.py +1117 -0
  29. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/locations.py +194 -0
  30. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/models/__init__.py +4 -0
  31. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/models/index.py +15 -0
  32. package/python3.4.2/lib/python3.4/site-packages/pip/{_vendor/requests/packages/urllib3/contrib → _internal/operations}/__init__.py +0 -0
  33. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/operations/check.py +106 -0
  34. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/operations/freeze.py +252 -0
  35. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/operations/prepare.py +378 -0
  36. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/pep425tags.py +317 -0
  37. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/__init__.py +69 -0
  38. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_file.py +338 -0
  39. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_install.py +1115 -0
  40. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_set.py +164 -0
  41. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/req/req_uninstall.py +455 -0
  42. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/resolve.py +354 -0
  43. package/python3.4.2/lib/python3.4/site-packages/pip/{status_codes.py → _internal/status_codes.py} +8 -6
  44. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/__init__.py +0 -0
  45. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/appdirs.py +258 -0
  46. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/deprecation.py +77 -0
  47. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/encoding.py +33 -0
  48. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/filesystem.py +28 -0
  49. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/glibc.py +84 -0
  50. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/hashes.py +94 -0
  51. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/logging.py +132 -0
  52. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/misc.py +851 -0
  53. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/outdated.py +163 -0
  54. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/packaging.py +70 -0
  55. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/setuptools_build.py +8 -0
  56. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/temp_dir.py +82 -0
  57. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/typing.py +29 -0
  58. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/utils/ui.py +421 -0
  59. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/__init__.py +471 -0
  60. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/bazaar.py +113 -0
  61. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/git.py +311 -0
  62. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/mercurial.py +105 -0
  63. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/vcs/subversion.py +271 -0
  64. package/python3.4.2/lib/python3.4/site-packages/pip/_internal/wheel.py +817 -0
  65. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/__init__.py +109 -8
  66. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/appdirs.py +604 -0
  67. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/__init__.py +11 -0
  68. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/_cmd.py +60 -0
  69. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/adapter.py +134 -0
  70. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/cache.py +39 -0
  71. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +2 -0
  72. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +133 -0
  73. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +43 -0
  74. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/compat.py +29 -0
  75. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/controller.py +373 -0
  76. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/filewrapper.py +78 -0
  77. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/heuristics.py +138 -0
  78. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/serialize.py +194 -0
  79. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/cachecontrol/wrapper.py +27 -0
  80. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/certifi/__init__.py +3 -0
  81. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/certifi/__main__.py +2 -0
  82. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests → certifi}/cacert.pem +1765 -2358
  83. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/certifi/core.py +37 -0
  84. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/__init__.py +39 -32
  85. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/big5freq.py +386 -0
  86. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/big5prober.py +47 -42
  87. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/chardistribution.py +233 -231
  88. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/charsetgroupprober.py +106 -0
  89. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/charsetprober.py +145 -0
  90. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/cli/__init__.py +1 -0
  91. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/cli/chardetect.py +85 -0
  92. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/codingstatemachine.py +88 -0
  93. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/compat.py +34 -34
  94. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/cp949prober.py +49 -44
  95. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/enums.py +76 -0
  96. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/escprober.py +101 -0
  97. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/escsm.py +246 -0
  98. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/eucjpprober.py +92 -0
  99. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/euckrfreq.py +195 -0
  100. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/euckrprober.py +47 -42
  101. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/euctwfreq.py +387 -428
  102. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/euctwprober.py +46 -41
  103. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/gb2312freq.py +283 -472
  104. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/gb2312prober.py +46 -41
  105. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/hebrewprober.py +292 -283
  106. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/jisfreq.py +325 -569
  107. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/jpcntx.py +233 -219
  108. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langbulgarianmodel.py +228 -229
  109. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langcyrillicmodel.py +333 -329
  110. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langgreekmodel.py +225 -225
  111. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langhebrewmodel.py +200 -201
  112. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langhungarianmodel.py +225 -225
  113. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/langthaimodel.py +199 -200
  114. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/langturkishmodel.py +193 -0
  115. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/latin1prober.py +145 -139
  116. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/mbcharsetprober.py +91 -0
  117. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/mbcsgroupprober.py +54 -54
  118. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/mbcssm.py +572 -0
  119. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/sbcharsetprober.py +132 -0
  120. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/sbcsgroupprober.py +73 -69
  121. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/sjisprober.py +92 -0
  122. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/universaldetector.py +286 -0
  123. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/chardet → chardet}/utf8prober.py +82 -76
  124. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/chardet/version.py +9 -0
  125. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/__init__.py +7 -7
  126. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/ansi.py +102 -50
  127. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/ansitowin32.py +236 -190
  128. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/initialise.py +82 -56
  129. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/win32.py +156 -137
  130. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/colorama/winterm.py +162 -120
  131. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/__init__.py +23 -23
  132. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/__init__.py +6 -6
  133. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/misc.py +41 -41
  134. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/shutil.py +761 -761
  135. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/sysconfig.cfg +84 -84
  136. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/sysconfig.py +788 -788
  137. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/_backport/tarfile.py +2607 -2607
  138. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/compat.py +1117 -1064
  139. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/database.py +1318 -1301
  140. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/index.py +516 -488
  141. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/locators.py +1292 -1194
  142. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/manifest.py +393 -364
  143. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/markers.py +131 -190
  144. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/metadata.py +1068 -1026
  145. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/resources.py +355 -317
  146. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py +415 -323
  147. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/t32.exe +0 -0
  148. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/t64.exe +0 -0
  149. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/util.py +1755 -1575
  150. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/version.py +736 -721
  151. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/w32.exe +0 -0
  152. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/w64.exe +0 -0
  153. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distlib/wheel.py +984 -958
  154. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/distro.py +1104 -0
  155. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/__init__.py +35 -23
  156. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{ihatexml.py → _ihatexml.py} +288 -285
  157. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{inputstream.py → _inputstream.py} +923 -881
  158. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{tokenizer.py → _tokenizer.py} +1721 -1731
  159. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/__init__.py +14 -12
  160. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/_base.py +37 -37
  161. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/datrie.py +44 -44
  162. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{trie → _trie}/py.py +67 -67
  163. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/{utils.py → _utils.py} +124 -82
  164. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/constants.py +2947 -3104
  165. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.py +29 -20
  166. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/{_base.py → base.py} +12 -12
  167. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/inject_meta_charset.py +73 -65
  168. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/lint.py +93 -93
  169. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/optionaltags.py +207 -205
  170. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/sanitizer.py +896 -12
  171. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/filters/whitespace.py +38 -38
  172. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/html5parser.py +2791 -2713
  173. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer.py +409 -0
  174. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treeadapters/__init__.py +30 -0
  175. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treeadapters/genshi.py +54 -0
  176. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treeadapters/sax.py +50 -44
  177. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/__init__.py +88 -76
  178. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/{_base.py → base.py} +417 -377
  179. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/dom.py +236 -227
  180. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/etree.py +340 -337
  181. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.py +366 -369
  182. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/__init__.py +154 -57
  183. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/{_base.py → base.py} +252 -200
  184. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/dom.py +43 -46
  185. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/etree.py +130 -138
  186. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/{lxmletree.py → etree_lxml.py} +213 -208
  187. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/{genshistream.py → genshi.py} +69 -69
  188. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/__init__.py +2 -0
  189. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/codec.py +118 -0
  190. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/compat.py +12 -0
  191. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/core.py +387 -0
  192. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/idnadata.py +1585 -0
  193. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/intranges.py +53 -0
  194. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/package_data.py +2 -0
  195. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/idna/uts46data.py +7634 -0
  196. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/ipaddress.py +2419 -0
  197. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/__init__.py +347 -0
  198. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/linklockfile.py +73 -0
  199. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/mkdirlockfile.py +84 -0
  200. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/pidlockfile.py +190 -0
  201. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/sqlitelockfile.py +156 -0
  202. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/lockfile/symlinklockfile.py +70 -0
  203. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/__init__.py +66 -0
  204. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/_version.py +1 -0
  205. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/exceptions.py +41 -0
  206. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/msgpack/fallback.py +971 -0
  207. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/__about__.py +21 -0
  208. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/__init__.py +14 -0
  209. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/_compat.py +30 -0
  210. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/_structures.py +70 -0
  211. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/markers.py +301 -0
  212. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/requirements.py +130 -0
  213. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/specifiers.py +774 -0
  214. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/utils.py +63 -0
  215. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/packaging/version.py +441 -0
  216. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{pkg_resources.py → pkg_resources/__init__.py} +3125 -2762
  217. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pkg_resources/py31compat.py +22 -0
  218. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/__init__.py +127 -0
  219. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/bar.py +88 -0
  220. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/counter.py +48 -0
  221. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/helpers.py +91 -0
  222. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/progress/spinner.py +44 -0
  223. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pyparsing.py +5720 -0
  224. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/__init__.py +3 -0
  225. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/core.py +13 -0
  226. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/parser.py +374 -0
  227. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/pytoml/writer.py +127 -0
  228. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/__init__.py +123 -77
  229. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/__version__.py +14 -0
  230. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/_internal_utils.py +42 -0
  231. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/adapters.py +525 -388
  232. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/api.py +152 -120
  233. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/auth.py +293 -193
  234. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/certs.py +18 -24
  235. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/compat.py +73 -115
  236. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/cookies.py +542 -454
  237. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/exceptions.py +122 -75
  238. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/help.py +120 -0
  239. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/hooks.py +34 -45
  240. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/models.py +948 -803
  241. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages.py +16 -0
  242. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/sessions.py +737 -637
  243. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/status_codes.py +91 -88
  244. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/structures.py +105 -127
  245. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/utils.py +904 -673
  246. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/retrying.py +267 -0
  247. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/six.py +891 -646
  248. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/__init__.py +97 -0
  249. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/_collections.py +319 -0
  250. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/connection.py +373 -0
  251. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/connectionpool.py +905 -710
  252. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
  253. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
  254. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +593 -0
  255. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +343 -0
  256. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/appengine.py +296 -0
  257. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/contrib/ntlmpool.py +112 -120
  258. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +455 -0
  259. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +810 -0
  260. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/contrib/socks.py +188 -0
  261. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/exceptions.py +246 -0
  262. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/fields.py +178 -177
  263. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/filepost.py +94 -100
  264. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/__init__.py +5 -4
  265. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
  266. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +53 -0
  267. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/ordered_dict.py +259 -260
  268. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/packages/six.py +868 -0
  269. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/ssl_match_hostname/__init__.py +19 -13
  270. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/packages/ssl_match_hostname/_implementation.py +157 -105
  271. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/poolmanager.py +440 -0
  272. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/request.py +148 -141
  273. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/response.py +626 -0
  274. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/__init__.py +54 -0
  275. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/connection.py +130 -0
  276. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/request.py +118 -0
  277. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/response.py +81 -0
  278. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/retry.py +401 -0
  279. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/selectors.py +581 -0
  280. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/ssl_.py +341 -0
  281. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/util/timeout.py +242 -234
  282. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/{requests/packages/urllib3 → urllib3}/util/url.py +230 -162
  283. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/urllib3/util/wait.py +40 -0
  284. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/__init__.py +342 -0
  285. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/labels.py +231 -0
  286. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/mklabels.py +59 -0
  287. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/tests.py +153 -0
  288. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/webencodings/x_user_defined.py +325 -0
  289. package/python3.4.2/lib/python3.4/site-packages/pip-10.0.0.dist-info/LICENSE.txt +20 -0
  290. package/python3.4.2/lib/python3.4/site-packages/pip-10.0.0.dist-info/METADATA +78 -0
  291. package/python3.4.2/lib/python3.4/site-packages/pip-10.0.0.dist-info/RECORD +294 -0
  292. package/python3.4.2/lib/python3.4/site-packages/{pip-1.5.6.dist-info → pip-10.0.0.dist-info}/WHEEL +6 -6
  293. package/python3.4.2/lib/python3.4/site-packages/pip-10.0.0.dist-info/entry_points.txt +5 -0
  294. package/python3.4.2/lib/python3.4/site-packages/{pip-1.5.6.dist-info → pip-10.0.0.dist-info}/top_level.txt +0 -0
  295. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/_markerlib/__init__.py +0 -16
  296. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/_markerlib/markers.py +0 -119
  297. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/sanitizer.py +0 -271
  298. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer/__init__.py +0 -16
  299. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer/htmlserializer.py +0 -320
  300. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/pulldom.py +0 -63
  301. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/re-vendor.py +0 -34
  302. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/__init__.py +0 -3
  303. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/big5freq.py +0 -925
  304. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py +0 -46
  305. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/charsetgroupprober.py +0 -106
  306. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/charsetprober.py +0 -62
  307. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/codingstatemachine.py +0 -61
  308. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/constants.py +0 -39
  309. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/escprober.py +0 -86
  310. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/escsm.py +0 -242
  311. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/eucjpprober.py +0 -90
  312. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/euckrfreq.py +0 -596
  313. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/mbcharsetprober.py +0 -86
  314. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/mbcssm.py +0 -575
  315. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/sbcharsetprober.py +0 -120
  316. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/sjisprober.py +0 -91
  317. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/universaldetector.py +0 -170
  318. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py +0 -58
  319. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/_collections.py +0 -205
  320. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connection.py +0 -204
  321. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py +0 -422
  322. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/exceptions.py +0 -126
  323. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/packages/six.py +0 -385
  324. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/poolmanager.py +0 -258
  325. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/response.py +0 -308
  326. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/__init__.py +0 -27
  327. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/connection.py +0 -45
  328. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/request.py +0 -68
  329. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/response.py +0 -13
  330. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py +0 -133
  331. package/python3.4.2/lib/python3.4/site-packages/pip/backwardcompat/__init__.py +0 -138
  332. package/python3.4.2/lib/python3.4/site-packages/pip/basecommand.py +0 -201
  333. package/python3.4.2/lib/python3.4/site-packages/pip/cmdoptions.py +0 -371
  334. package/python3.4.2/lib/python3.4/site-packages/pip/commands/__init__.py +0 -88
  335. package/python3.4.2/lib/python3.4/site-packages/pip/commands/bundle.py +0 -42
  336. package/python3.4.2/lib/python3.4/site-packages/pip/commands/completion.py +0 -59
  337. package/python3.4.2/lib/python3.4/site-packages/pip/commands/freeze.py +0 -114
  338. package/python3.4.2/lib/python3.4/site-packages/pip/commands/install.py +0 -314
  339. package/python3.4.2/lib/python3.4/site-packages/pip/commands/list.py +0 -162
  340. package/python3.4.2/lib/python3.4/site-packages/pip/commands/search.py +0 -132
  341. package/python3.4.2/lib/python3.4/site-packages/pip/commands/show.py +0 -80
  342. package/python3.4.2/lib/python3.4/site-packages/pip/commands/uninstall.py +0 -59
  343. package/python3.4.2/lib/python3.4/site-packages/pip/commands/unzip.py +0 -7
  344. package/python3.4.2/lib/python3.4/site-packages/pip/commands/wheel.py +0 -195
  345. package/python3.4.2/lib/python3.4/site-packages/pip/commands/zip.py +0 -351
  346. package/python3.4.2/lib/python3.4/site-packages/pip/download.py +0 -644
  347. package/python3.4.2/lib/python3.4/site-packages/pip/exceptions.py +0 -46
  348. package/python3.4.2/lib/python3.4/site-packages/pip/index.py +0 -990
  349. package/python3.4.2/lib/python3.4/site-packages/pip/locations.py +0 -171
  350. package/python3.4.2/lib/python3.4/site-packages/pip/log.py +0 -276
  351. package/python3.4.2/lib/python3.4/site-packages/pip/pep425tags.py +0 -102
  352. package/python3.4.2/lib/python3.4/site-packages/pip/req.py +0 -1931
  353. package/python3.4.2/lib/python3.4/site-packages/pip/runner.py +0 -18
  354. package/python3.4.2/lib/python3.4/site-packages/pip/util.py +0 -720
  355. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/__init__.py +0 -251
  356. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/bazaar.py +0 -131
  357. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/git.py +0 -194
  358. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/mercurial.py +0 -151
  359. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/subversion.py +0 -273
  360. package/python3.4.2/lib/python3.4/site-packages/pip/wheel.py +0 -560
  361. package/python3.4.2/lib/python3.4/site-packages/pip-1.5.6.dist-info/DESCRIPTION.rst +0 -71
  362. package/python3.4.2/lib/python3.4/site-packages/pip-1.5.6.dist-info/METADATA +0 -98
  363. package/python3.4.2/lib/python3.4/site-packages/pip-1.5.6.dist-info/RECORD +0 -373
  364. package/python3.4.2/lib/python3.4/site-packages/pip-1.5.6.dist-info/entry_points.txt +0 -5
  365. package/python3.4.2/lib/python3.4/site-packages/pip-1.5.6.dist-info/metadata.json +0 -1
@@ -1,673 +1,904 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- """
4
- requests.utils
5
- ~~~~~~~~~~~~~~
6
-
7
- This module provides utility functions that are used within Requests
8
- that are also useful for external consumption.
9
-
10
- """
11
-
12
- import cgi
13
- import codecs
14
- import collections
15
- import io
16
- import os
17
- import platform
18
- import re
19
- import sys
20
- import socket
21
- import struct
22
-
23
- from . import __version__
24
- from . import certs
25
- from .compat import parse_http_list as _parse_list_header
26
- from .compat import (quote, urlparse, bytes, str, OrderedDict, unquote, is_py2,
27
- builtin_str, getproxies, proxy_bypass, urlunparse)
28
- from .cookies import RequestsCookieJar, cookiejar_from_dict
29
- from .structures import CaseInsensitiveDict
30
- from .exceptions import InvalidURL
31
-
32
- _hush_pyflakes = (RequestsCookieJar,)
33
-
34
- NETRC_FILES = ('.netrc', '_netrc')
35
-
36
- DEFAULT_CA_BUNDLE_PATH = certs.where()
37
-
38
-
39
- def dict_to_sequence(d):
40
- """Returns an internal sequence dictionary update."""
41
-
42
- if hasattr(d, 'items'):
43
- d = d.items()
44
-
45
- return d
46
-
47
-
48
- def super_len(o):
49
- if hasattr(o, '__len__'):
50
- return len(o)
51
-
52
- if hasattr(o, 'len'):
53
- return o.len
54
-
55
- if hasattr(o, 'fileno'):
56
- try:
57
- fileno = o.fileno()
58
- except io.UnsupportedOperation:
59
- pass
60
- else:
61
- return os.fstat(fileno).st_size
62
-
63
- if hasattr(o, 'getvalue'):
64
- # e.g. BytesIO, cStringIO.StringIO
65
- return len(o.getvalue())
66
-
67
-
68
- def get_netrc_auth(url):
69
- """Returns the Requests tuple auth for a given url from netrc."""
70
-
71
- try:
72
- from netrc import netrc, NetrcParseError
73
-
74
- netrc_path = None
75
-
76
- for f in NETRC_FILES:
77
- try:
78
- loc = os.path.expanduser('~/{0}'.format(f))
79
- except KeyError:
80
- # os.path.expanduser can fail when $HOME is undefined and
81
- # getpwuid fails. See http://bugs.python.org/issue20164 &
82
- # https://github.com/kennethreitz/requests/issues/1846
83
- return
84
-
85
- if os.path.exists(loc):
86
- netrc_path = loc
87
- break
88
-
89
- # Abort early if there isn't one.
90
- if netrc_path is None:
91
- return
92
-
93
- ri = urlparse(url)
94
-
95
- # Strip port numbers from netloc
96
- host = ri.netloc.split(':')[0]
97
-
98
- try:
99
- _netrc = netrc(netrc_path).authenticators(host)
100
- if _netrc:
101
- # Return with login / password
102
- login_i = (0 if _netrc[0] else 1)
103
- return (_netrc[login_i], _netrc[2])
104
- except (NetrcParseError, IOError):
105
- # If there was a parsing error or a permissions issue reading the file,
106
- # we'll just skip netrc auth
107
- pass
108
-
109
- # AppEngine hackiness.
110
- except (ImportError, AttributeError):
111
- pass
112
-
113
-
114
- def guess_filename(obj):
115
- """Tries to guess the filename of the given object."""
116
- name = getattr(obj, 'name', None)
117
- if name and name[0] != '<' and name[-1] != '>':
118
- return os.path.basename(name)
119
-
120
-
121
- def from_key_val_list(value):
122
- """Take an object and test to see if it can be represented as a
123
- dictionary. Unless it can not be represented as such, return an
124
- OrderedDict, e.g.,
125
-
126
- ::
127
-
128
- >>> from_key_val_list([('key', 'val')])
129
- OrderedDict([('key', 'val')])
130
- >>> from_key_val_list('string')
131
- ValueError: need more than 1 value to unpack
132
- >>> from_key_val_list({'key': 'val'})
133
- OrderedDict([('key', 'val')])
134
- """
135
- if value is None:
136
- return None
137
-
138
- if isinstance(value, (str, bytes, bool, int)):
139
- raise ValueError('cannot encode objects that are not 2-tuples')
140
-
141
- return OrderedDict(value)
142
-
143
-
144
- def to_key_val_list(value):
145
- """Take an object and test to see if it can be represented as a
146
- dictionary. If it can be, return a list of tuples, e.g.,
147
-
148
- ::
149
-
150
- >>> to_key_val_list([('key', 'val')])
151
- [('key', 'val')]
152
- >>> to_key_val_list({'key': 'val'})
153
- [('key', 'val')]
154
- >>> to_key_val_list('string')
155
- ValueError: cannot encode objects that are not 2-tuples.
156
- """
157
- if value is None:
158
- return None
159
-
160
- if isinstance(value, (str, bytes, bool, int)):
161
- raise ValueError('cannot encode objects that are not 2-tuples')
162
-
163
- if isinstance(value, collections.Mapping):
164
- value = value.items()
165
-
166
- return list(value)
167
-
168
-
169
- # From mitsuhiko/werkzeug (used with permission).
170
- def parse_list_header(value):
171
- """Parse lists as described by RFC 2068 Section 2.
172
-
173
- In particular, parse comma-separated lists where the elements of
174
- the list may include quoted-strings. A quoted-string could
175
- contain a comma. A non-quoted string could have quotes in the
176
- middle. Quotes are removed automatically after parsing.
177
-
178
- It basically works like :func:`parse_set_header` just that items
179
- may appear multiple times and case sensitivity is preserved.
180
-
181
- The return value is a standard :class:`list`:
182
-
183
- >>> parse_list_header('token, "quoted value"')
184
- ['token', 'quoted value']
185
-
186
- To create a header from the :class:`list` again, use the
187
- :func:`dump_header` function.
188
-
189
- :param value: a string with a list header.
190
- :return: :class:`list`
191
- """
192
- result = []
193
- for item in _parse_list_header(value):
194
- if item[:1] == item[-1:] == '"':
195
- item = unquote_header_value(item[1:-1])
196
- result.append(item)
197
- return result
198
-
199
-
200
- # From mitsuhiko/werkzeug (used with permission).
201
- def parse_dict_header(value):
202
- """Parse lists of key, value pairs as described by RFC 2068 Section 2 and
203
- convert them into a python dict:
204
-
205
- >>> d = parse_dict_header('foo="is a fish", bar="as well"')
206
- >>> type(d) is dict
207
- True
208
- >>> sorted(d.items())
209
- [('bar', 'as well'), ('foo', 'is a fish')]
210
-
211
- If there is no value for a key it will be `None`:
212
-
213
- >>> parse_dict_header('key_without_value')
214
- {'key_without_value': None}
215
-
216
- To create a header from the :class:`dict` again, use the
217
- :func:`dump_header` function.
218
-
219
- :param value: a string with a dict header.
220
- :return: :class:`dict`
221
- """
222
- result = {}
223
- for item in _parse_list_header(value):
224
- if '=' not in item:
225
- result[item] = None
226
- continue
227
- name, value = item.split('=', 1)
228
- if value[:1] == value[-1:] == '"':
229
- value = unquote_header_value(value[1:-1])
230
- result[name] = value
231
- return result
232
-
233
-
234
- # From mitsuhiko/werkzeug (used with permission).
235
- def unquote_header_value(value, is_filename=False):
236
- r"""Unquotes a header value. (Reversal of :func:`quote_header_value`).
237
- This does not use the real unquoting but what browsers are actually
238
- using for quoting.
239
-
240
- :param value: the header value to unquote.
241
- """
242
- if value and value[0] == value[-1] == '"':
243
- # this is not the real unquoting, but fixing this so that the
244
- # RFC is met will result in bugs with internet explorer and
245
- # probably some other browsers as well. IE for example is
246
- # uploading files with "C:\foo\bar.txt" as filename
247
- value = value[1:-1]
248
-
249
- # if this is a filename and the starting characters look like
250
- # a UNC path, then just return the value without quotes. Using the
251
- # replace sequence below on a UNC path has the effect of turning
252
- # the leading double slash into a single slash and then
253
- # _fix_ie_filename() doesn't work correctly. See #458.
254
- if not is_filename or value[:2] != '\\\\':
255
- return value.replace('\\\\', '\\').replace('\\"', '"')
256
- return value
257
-
258
-
259
- def dict_from_cookiejar(cj):
260
- """Returns a key/value dictionary from a CookieJar.
261
-
262
- :param cj: CookieJar object to extract cookies from.
263
- """
264
-
265
- cookie_dict = {}
266
-
267
- for cookie in cj:
268
- cookie_dict[cookie.name] = cookie.value
269
-
270
- return cookie_dict
271
-
272
-
273
- def add_dict_to_cookiejar(cj, cookie_dict):
274
- """Returns a CookieJar from a key/value dictionary.
275
-
276
- :param cj: CookieJar to insert cookies into.
277
- :param cookie_dict: Dict of key/values to insert into CookieJar.
278
- """
279
-
280
- cj2 = cookiejar_from_dict(cookie_dict)
281
- cj.update(cj2)
282
- return cj
283
-
284
-
285
- def get_encodings_from_content(content):
286
- """Returns encodings from given content string.
287
-
288
- :param content: bytestring to extract encodings from.
289
- """
290
-
291
- charset_re = re.compile(r'<meta.*?charset=["\']*(.+?)["\'>]', flags=re.I)
292
- pragma_re = re.compile(r'<meta.*?content=["\']*;?charset=(.+?)["\'>]', flags=re.I)
293
- xml_re = re.compile(r'^<\?xml.*?encoding=["\']*(.+?)["\'>]')
294
-
295
- return (charset_re.findall(content) +
296
- pragma_re.findall(content) +
297
- xml_re.findall(content))
298
-
299
-
300
- def get_encoding_from_headers(headers):
301
- """Returns encodings from given HTTP Header Dict.
302
-
303
- :param headers: dictionary to extract encoding from.
304
- """
305
-
306
- content_type = headers.get('content-type')
307
-
308
- if not content_type:
309
- return None
310
-
311
- content_type, params = cgi.parse_header(content_type)
312
-
313
- if 'charset' in params:
314
- return params['charset'].strip("'\"")
315
-
316
- if 'text' in content_type:
317
- return 'ISO-8859-1'
318
-
319
-
320
- def stream_decode_response_unicode(iterator, r):
321
- """Stream decodes a iterator."""
322
-
323
- if r.encoding is None:
324
- for item in iterator:
325
- yield item
326
- return
327
-
328
- decoder = codecs.getincrementaldecoder(r.encoding)(errors='replace')
329
- for chunk in iterator:
330
- rv = decoder.decode(chunk)
331
- if rv:
332
- yield rv
333
- rv = decoder.decode(b'', final=True)
334
- if rv:
335
- yield rv
336
-
337
-
338
- def iter_slices(string, slice_length):
339
- """Iterate over slices of a string."""
340
- pos = 0
341
- while pos < len(string):
342
- yield string[pos:pos + slice_length]
343
- pos += slice_length
344
-
345
-
346
- def get_unicode_from_response(r):
347
- """Returns the requested content back in unicode.
348
-
349
- :param r: Response object to get unicode content from.
350
-
351
- Tried:
352
-
353
- 1. charset from content-type
354
-
355
- 2. every encodings from ``<meta ... charset=XXX>``
356
-
357
- 3. fall back and replace all unicode characters
358
-
359
- """
360
-
361
- tried_encodings = []
362
-
363
- # Try charset from content-type
364
- encoding = get_encoding_from_headers(r.headers)
365
-
366
- if encoding:
367
- try:
368
- return str(r.content, encoding)
369
- except UnicodeError:
370
- tried_encodings.append(encoding)
371
-
372
- # Fall back:
373
- try:
374
- return str(r.content, encoding, errors='replace')
375
- except TypeError:
376
- return r.content
377
-
378
-
379
- # The unreserved URI characters (RFC 3986)
380
- UNRESERVED_SET = frozenset(
381
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
382
- + "0123456789-._~")
383
-
384
-
385
- def unquote_unreserved(uri):
386
- """Un-escape any percent-escape sequences in a URI that are unreserved
387
- characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
388
- """
389
- parts = uri.split('%')
390
- for i in range(1, len(parts)):
391
- h = parts[i][0:2]
392
- if len(h) == 2 and h.isalnum():
393
- try:
394
- c = chr(int(h, 16))
395
- except ValueError:
396
- raise InvalidURL("Invalid percent-escape sequence: '%s'" % h)
397
-
398
- if c in UNRESERVED_SET:
399
- parts[i] = c + parts[i][2:]
400
- else:
401
- parts[i] = '%' + parts[i]
402
- else:
403
- parts[i] = '%' + parts[i]
404
- return ''.join(parts)
405
-
406
-
407
- def requote_uri(uri):
408
- """Re-quote the given URI.
409
-
410
- This function passes the given URI through an unquote/quote cycle to
411
- ensure that it is fully and consistently quoted.
412
- """
413
- # Unquote only the unreserved characters
414
- # Then quote only illegal characters (do not quote reserved, unreserved,
415
- # or '%')
416
- return quote(unquote_unreserved(uri), safe="!#$%&'()*+,/:;=?@[]~")
417
-
418
-
419
- def address_in_network(ip, net):
420
- """
421
- This function allows you to check if on IP belongs to a network subnet
422
- Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
423
- returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
424
- """
425
- ipaddr = struct.unpack('=L', socket.inet_aton(ip))[0]
426
- netaddr, bits = net.split('/')
427
- netmask = struct.unpack('=L', socket.inet_aton(dotted_netmask(int(bits))))[0]
428
- network = struct.unpack('=L', socket.inet_aton(netaddr))[0] & netmask
429
- return (ipaddr & netmask) == (network & netmask)
430
-
431
-
432
- def dotted_netmask(mask):
433
- """
434
- Converts mask from /xx format to xxx.xxx.xxx.xxx
435
- Example: if mask is 24 function returns 255.255.255.0
436
- """
437
- bits = 0xffffffff ^ (1 << 32 - mask) - 1
438
- return socket.inet_ntoa(struct.pack('>I', bits))
439
-
440
-
441
- def is_ipv4_address(string_ip):
442
- try:
443
- socket.inet_aton(string_ip)
444
- except socket.error:
445
- return False
446
- return True
447
-
448
-
449
- def is_valid_cidr(string_network):
450
- """Very simple check of the cidr format in no_proxy variable"""
451
- if string_network.count('/') == 1:
452
- try:
453
- mask = int(string_network.split('/')[1])
454
- except ValueError:
455
- return False
456
-
457
- if mask < 1 or mask > 32:
458
- return False
459
-
460
- try:
461
- socket.inet_aton(string_network.split('/')[0])
462
- except socket.error:
463
- return False
464
- else:
465
- return False
466
- return True
467
-
468
-
469
- def should_bypass_proxies(url):
470
- """
471
- Returns whether we should bypass proxies or not.
472
- """
473
- get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper())
474
-
475
- # First check whether no_proxy is defined. If it is, check that the URL
476
- # we're getting isn't in the no_proxy list.
477
- no_proxy = get_proxy('no_proxy')
478
- netloc = urlparse(url).netloc
479
-
480
- if no_proxy:
481
- # We need to check whether we match here. We need to see if we match
482
- # the end of the netloc, both with and without the port.
483
- no_proxy = no_proxy.replace(' ', '').split(',')
484
-
485
- ip = netloc.split(':')[0]
486
- if is_ipv4_address(ip):
487
- for proxy_ip in no_proxy:
488
- if is_valid_cidr(proxy_ip):
489
- if address_in_network(ip, proxy_ip):
490
- return True
491
- else:
492
- for host in no_proxy:
493
- if netloc.endswith(host) or netloc.split(':')[0].endswith(host):
494
- # The URL does match something in no_proxy, so we don't want
495
- # to apply the proxies on this URL.
496
- return True
497
-
498
- # If the system proxy settings indicate that this URL should be bypassed,
499
- # don't proxy.
500
- # The proxy_bypass function is incredibly buggy on OS X in early versions
501
- # of Python 2.6, so allow this call to fail. Only catch the specific
502
- # exceptions we've seen, though: this call failing in other ways can reveal
503
- # legitimate problems.
504
- try:
505
- bypass = proxy_bypass(netloc)
506
- except (TypeError, socket.gaierror):
507
- bypass = False
508
-
509
- if bypass:
510
- return True
511
-
512
- return False
513
-
514
- def get_environ_proxies(url):
515
- """Return a dict of environment proxies."""
516
- if should_bypass_proxies(url):
517
- return {}
518
- else:
519
- return getproxies()
520
-
521
-
522
- def default_user_agent(name="python-requests"):
523
- """Return a string representing the default user agent."""
524
- _implementation = platform.python_implementation()
525
-
526
- if _implementation == 'CPython':
527
- _implementation_version = platform.python_version()
528
- elif _implementation == 'PyPy':
529
- _implementation_version = '%s.%s.%s' % (sys.pypy_version_info.major,
530
- sys.pypy_version_info.minor,
531
- sys.pypy_version_info.micro)
532
- if sys.pypy_version_info.releaselevel != 'final':
533
- _implementation_version = ''.join([_implementation_version, sys.pypy_version_info.releaselevel])
534
- elif _implementation == 'Jython':
535
- _implementation_version = platform.python_version() # Complete Guess
536
- elif _implementation == 'IronPython':
537
- _implementation_version = platform.python_version() # Complete Guess
538
- else:
539
- _implementation_version = 'Unknown'
540
-
541
- try:
542
- p_system = platform.system()
543
- p_release = platform.release()
544
- except IOError:
545
- p_system = 'Unknown'
546
- p_release = 'Unknown'
547
-
548
- return " ".join(['%s/%s' % (name, __version__),
549
- '%s/%s' % (_implementation, _implementation_version),
550
- '%s/%s' % (p_system, p_release)])
551
-
552
-
553
- def default_headers():
554
- return CaseInsensitiveDict({
555
- 'User-Agent': default_user_agent(),
556
- 'Accept-Encoding': ', '.join(('gzip', 'deflate')),
557
- 'Accept': '*/*'
558
- })
559
-
560
-
561
- def parse_header_links(value):
562
- """Return a dict of parsed link headers proxies.
563
-
564
- i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
565
-
566
- """
567
-
568
- links = []
569
-
570
- replace_chars = " '\""
571
-
572
- for val in value.split(","):
573
- try:
574
- url, params = val.split(";", 1)
575
- except ValueError:
576
- url, params = val, ''
577
-
578
- link = {}
579
-
580
- link["url"] = url.strip("<> '\"")
581
-
582
- for param in params.split(";"):
583
- try:
584
- key, value = param.split("=")
585
- except ValueError:
586
- break
587
-
588
- link[key.strip(replace_chars)] = value.strip(replace_chars)
589
-
590
- links.append(link)
591
-
592
- return links
593
-
594
-
595
- # Null bytes; no need to recreate these on each call to guess_json_utf
596
- _null = '\x00'.encode('ascii') # encoding to ASCII for Python 3
597
- _null2 = _null * 2
598
- _null3 = _null * 3
599
-
600
-
601
- def guess_json_utf(data):
602
- # JSON always starts with two ASCII characters, so detection is as
603
- # easy as counting the nulls and from their location and count
604
- # determine the encoding. Also detect a BOM, if present.
605
- sample = data[:4]
606
- if sample in (codecs.BOM_UTF32_LE, codecs.BOM32_BE):
607
- return 'utf-32' # BOM included
608
- if sample[:3] == codecs.BOM_UTF8:
609
- return 'utf-8-sig' # BOM included, MS style (discouraged)
610
- if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE):
611
- return 'utf-16' # BOM included
612
- nullcount = sample.count(_null)
613
- if nullcount == 0:
614
- return 'utf-8'
615
- if nullcount == 2:
616
- if sample[::2] == _null2: # 1st and 3rd are null
617
- return 'utf-16-be'
618
- if sample[1::2] == _null2: # 2nd and 4th are null
619
- return 'utf-16-le'
620
- # Did not detect 2 valid UTF-16 ascii-range characters
621
- if nullcount == 3:
622
- if sample[:3] == _null3:
623
- return 'utf-32-be'
624
- if sample[1:] == _null3:
625
- return 'utf-32-le'
626
- # Did not detect a valid UTF-32 ascii-range character
627
- return None
628
-
629
-
630
- def prepend_scheme_if_needed(url, new_scheme):
631
- '''Given a URL that may or may not have a scheme, prepend the given scheme.
632
- Does not replace a present scheme with the one provided as an argument.'''
633
- scheme, netloc, path, params, query, fragment = urlparse(url, new_scheme)
634
-
635
- # urlparse is a finicky beast, and sometimes decides that there isn't a
636
- # netloc present. Assume that it's being over-cautious, and switch netloc
637
- # and path if urlparse decided there was no netloc.
638
- if not netloc:
639
- netloc, path = path, netloc
640
-
641
- return urlunparse((scheme, netloc, path, params, query, fragment))
642
-
643
-
644
- def get_auth_from_url(url):
645
- """Given a url with authentication components, extract them into a tuple of
646
- username,password."""
647
- parsed = urlparse(url)
648
-
649
- try:
650
- auth = (unquote(parsed.username), unquote(parsed.password))
651
- except (AttributeError, TypeError):
652
- auth = ('', '')
653
-
654
- return auth
655
-
656
-
657
- def to_native_string(string, encoding='ascii'):
658
- """
659
- Given a string object, regardless of type, returns a representation of that
660
- string in the native string type, encoding and decoding where necessary.
661
- This assumes ASCII unless told otherwise.
662
- """
663
- out = None
664
-
665
- if isinstance(string, builtin_str):
666
- out = string
667
- else:
668
- if is_py2:
669
- out = string.encode(encoding)
670
- else:
671
- out = string.decode(encoding)
672
-
673
- return out
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ requests.utils
5
+ ~~~~~~~~~~~~~~
6
+
7
+ This module provides utility functions that are used within Requests
8
+ that are also useful for external consumption.
9
+ """
10
+
11
+ import cgi
12
+ import codecs
13
+ import collections
14
+ import contextlib
15
+ import io
16
+ import os
17
+ import platform
18
+ import re
19
+ import socket
20
+ import struct
21
+ import warnings
22
+
23
+ from .__version__ import __version__
24
+ from . import certs
25
+ # to_native_string is unused here, but imported here for backwards compatibility
26
+ from ._internal_utils import to_native_string
27
+ from .compat import parse_http_list as _parse_list_header
28
+ from .compat import (
29
+ quote, urlparse, bytes, str, OrderedDict, unquote, getproxies,
30
+ proxy_bypass, urlunparse, basestring, integer_types, is_py3,
31
+ proxy_bypass_environment, getproxies_environment)
32
+ from .cookies import cookiejar_from_dict
33
+ from .structures import CaseInsensitiveDict
34
+ from .exceptions import (
35
+ InvalidURL, InvalidHeader, FileModeWarning, UnrewindableBodyError)
36
+
37
+ NETRC_FILES = ('.netrc', '_netrc')
38
+
39
+ DEFAULT_CA_BUNDLE_PATH = certs.where()
40
+
41
+
42
+ if platform.system() == 'Windows':
43
+ # provide a proxy_bypass version on Windows without DNS lookups
44
+
45
+ def proxy_bypass_registry(host):
46
+ if is_py3:
47
+ import winreg
48
+ else:
49
+ import _winreg as winreg
50
+ try:
51
+ internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
52
+ r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
53
+ proxyEnable = winreg.QueryValueEx(internetSettings,
54
+ 'ProxyEnable')[0]
55
+ proxyOverride = winreg.QueryValueEx(internetSettings,
56
+ 'ProxyOverride')[0]
57
+ except OSError:
58
+ return False
59
+ if not proxyEnable or not proxyOverride:
60
+ return False
61
+
62
+ # make a check value list from the registry entry: replace the
63
+ # '<local>' string by the localhost entry and the corresponding
64
+ # canonical entry.
65
+ proxyOverride = proxyOverride.split(';')
66
+ # now check if we match one of the registry values.
67
+ for test in proxyOverride:
68
+ if test == '<local>':
69
+ if '.' not in host:
70
+ return True
71
+ test = test.replace(".", r"\.") # mask dots
72
+ test = test.replace("*", r".*") # change glob sequence
73
+ test = test.replace("?", r".") # change glob char
74
+ if re.match(test, host, re.I):
75
+ return True
76
+ return False
77
+
78
+ def proxy_bypass(host): # noqa
79
+ """Return True, if the host should be bypassed.
80
+
81
+ Checks proxy settings gathered from the environment, if specified,
82
+ or the registry.
83
+ """
84
+ if getproxies_environment():
85
+ return proxy_bypass_environment(host)
86
+ else:
87
+ return proxy_bypass_registry(host)
88
+
89
+
90
+ def dict_to_sequence(d):
91
+ """Returns an internal sequence dictionary update."""
92
+
93
+ if hasattr(d, 'items'):
94
+ d = d.items()
95
+
96
+ return d
97
+
98
+
99
+ def super_len(o):
100
+ total_length = None
101
+ current_position = 0
102
+
103
+ if hasattr(o, '__len__'):
104
+ total_length = len(o)
105
+
106
+ elif hasattr(o, 'len'):
107
+ total_length = o.len
108
+
109
+ elif hasattr(o, 'fileno'):
110
+ try:
111
+ fileno = o.fileno()
112
+ except io.UnsupportedOperation:
113
+ pass
114
+ else:
115
+ total_length = os.fstat(fileno).st_size
116
+
117
+ # Having used fstat to determine the file length, we need to
118
+ # confirm that this file was opened up in binary mode.
119
+ if 'b' not in o.mode:
120
+ warnings.warn((
121
+ "Requests has determined the content-length for this "
122
+ "request using the binary size of the file: however, the "
123
+ "file has been opened in text mode (i.e. without the 'b' "
124
+ "flag in the mode). This may lead to an incorrect "
125
+ "content-length. In Requests 3.0, support will be removed "
126
+ "for files in text mode."),
127
+ FileModeWarning
128
+ )
129
+
130
+ if hasattr(o, 'tell'):
131
+ try:
132
+ current_position = o.tell()
133
+ except (OSError, IOError):
134
+ # This can happen in some weird situations, such as when the file
135
+ # is actually a special file descriptor like stdin. In this
136
+ # instance, we don't know what the length is, so set it to zero and
137
+ # let requests chunk it instead.
138
+ if total_length is not None:
139
+ current_position = total_length
140
+ else:
141
+ if hasattr(o, 'seek') and total_length is None:
142
+ # StringIO and BytesIO have seek but no useable fileno
143
+ try:
144
+ # seek to end of file
145
+ o.seek(0, 2)
146
+ total_length = o.tell()
147
+
148
+ # seek back to current position to support
149
+ # partially read file-like objects
150
+ o.seek(current_position or 0)
151
+ except (OSError, IOError):
152
+ total_length = 0
153
+
154
+ if total_length is None:
155
+ total_length = 0
156
+
157
+ return max(0, total_length - current_position)
158
+
159
+
160
+ def get_netrc_auth(url, raise_errors=False):
161
+ """Returns the Requests tuple auth for a given url from netrc."""
162
+
163
+ try:
164
+ from netrc import netrc, NetrcParseError
165
+
166
+ netrc_path = None
167
+
168
+ for f in NETRC_FILES:
169
+ try:
170
+ loc = os.path.expanduser('~/{0}'.format(f))
171
+ except KeyError:
172
+ # os.path.expanduser can fail when $HOME is undefined and
173
+ # getpwuid fails. See http://bugs.python.org/issue20164 &
174
+ # https://github.com/requests/requests/issues/1846
175
+ return
176
+
177
+ if os.path.exists(loc):
178
+ netrc_path = loc
179
+ break
180
+
181
+ # Abort early if there isn't one.
182
+ if netrc_path is None:
183
+ return
184
+
185
+ ri = urlparse(url)
186
+
187
+ # Strip port numbers from netloc. This weird `if...encode`` dance is
188
+ # used for Python 3.2, which doesn't support unicode literals.
189
+ splitstr = b':'
190
+ if isinstance(url, str):
191
+ splitstr = splitstr.decode('ascii')
192
+ host = ri.netloc.split(splitstr)[0]
193
+
194
+ try:
195
+ _netrc = netrc(netrc_path).authenticators(host)
196
+ if _netrc:
197
+ # Return with login / password
198
+ login_i = (0 if _netrc[0] else 1)
199
+ return (_netrc[login_i], _netrc[2])
200
+ except (NetrcParseError, IOError):
201
+ # If there was a parsing error or a permissions issue reading the file,
202
+ # we'll just skip netrc auth unless explicitly asked to raise errors.
203
+ if raise_errors:
204
+ raise
205
+
206
+ # AppEngine hackiness.
207
+ except (ImportError, AttributeError):
208
+ pass
209
+
210
+
211
+ def guess_filename(obj):
212
+ """Tries to guess the filename of the given object."""
213
+ name = getattr(obj, 'name', None)
214
+ if (name and isinstance(name, basestring) and name[0] != '<' and
215
+ name[-1] != '>'):
216
+ return os.path.basename(name)
217
+
218
+
219
+ def from_key_val_list(value):
220
+ """Take an object and test to see if it can be represented as a
221
+ dictionary. Unless it can not be represented as such, return an
222
+ OrderedDict, e.g.,
223
+
224
+ ::
225
+
226
+ >>> from_key_val_list([('key', 'val')])
227
+ OrderedDict([('key', 'val')])
228
+ >>> from_key_val_list('string')
229
+ ValueError: need more than 1 value to unpack
230
+ >>> from_key_val_list({'key': 'val'})
231
+ OrderedDict([('key', 'val')])
232
+
233
+ :rtype: OrderedDict
234
+ """
235
+ if value is None:
236
+ return None
237
+
238
+ if isinstance(value, (str, bytes, bool, int)):
239
+ raise ValueError('cannot encode objects that are not 2-tuples')
240
+
241
+ return OrderedDict(value)
242
+
243
+
244
+ def to_key_val_list(value):
245
+ """Take an object and test to see if it can be represented as a
246
+ dictionary. If it can be, return a list of tuples, e.g.,
247
+
248
+ ::
249
+
250
+ >>> to_key_val_list([('key', 'val')])
251
+ [('key', 'val')]
252
+ >>> to_key_val_list({'key': 'val'})
253
+ [('key', 'val')]
254
+ >>> to_key_val_list('string')
255
+ ValueError: cannot encode objects that are not 2-tuples.
256
+
257
+ :rtype: list
258
+ """
259
+ if value is None:
260
+ return None
261
+
262
+ if isinstance(value, (str, bytes, bool, int)):
263
+ raise ValueError('cannot encode objects that are not 2-tuples')
264
+
265
+ if isinstance(value, collections.Mapping):
266
+ value = value.items()
267
+
268
+ return list(value)
269
+
270
+
271
+ # From mitsuhiko/werkzeug (used with permission).
272
+ def parse_list_header(value):
273
+ """Parse lists as described by RFC 2068 Section 2.
274
+
275
+ In particular, parse comma-separated lists where the elements of
276
+ the list may include quoted-strings. A quoted-string could
277
+ contain a comma. A non-quoted string could have quotes in the
278
+ middle. Quotes are removed automatically after parsing.
279
+
280
+ It basically works like :func:`parse_set_header` just that items
281
+ may appear multiple times and case sensitivity is preserved.
282
+
283
+ The return value is a standard :class:`list`:
284
+
285
+ >>> parse_list_header('token, "quoted value"')
286
+ ['token', 'quoted value']
287
+
288
+ To create a header from the :class:`list` again, use the
289
+ :func:`dump_header` function.
290
+
291
+ :param value: a string with a list header.
292
+ :return: :class:`list`
293
+ :rtype: list
294
+ """
295
+ result = []
296
+ for item in _parse_list_header(value):
297
+ if item[:1] == item[-1:] == '"':
298
+ item = unquote_header_value(item[1:-1])
299
+ result.append(item)
300
+ return result
301
+
302
+
303
+ # From mitsuhiko/werkzeug (used with permission).
304
+ def parse_dict_header(value):
305
+ """Parse lists of key, value pairs as described by RFC 2068 Section 2 and
306
+ convert them into a python dict:
307
+
308
+ >>> d = parse_dict_header('foo="is a fish", bar="as well"')
309
+ >>> type(d) is dict
310
+ True
311
+ >>> sorted(d.items())
312
+ [('bar', 'as well'), ('foo', 'is a fish')]
313
+
314
+ If there is no value for a key it will be `None`:
315
+
316
+ >>> parse_dict_header('key_without_value')
317
+ {'key_without_value': None}
318
+
319
+ To create a header from the :class:`dict` again, use the
320
+ :func:`dump_header` function.
321
+
322
+ :param value: a string with a dict header.
323
+ :return: :class:`dict`
324
+ :rtype: dict
325
+ """
326
+ result = {}
327
+ for item in _parse_list_header(value):
328
+ if '=' not in item:
329
+ result[item] = None
330
+ continue
331
+ name, value = item.split('=', 1)
332
+ if value[:1] == value[-1:] == '"':
333
+ value = unquote_header_value(value[1:-1])
334
+ result[name] = value
335
+ return result
336
+
337
+
338
+ # From mitsuhiko/werkzeug (used with permission).
339
+ def unquote_header_value(value, is_filename=False):
340
+ r"""Unquotes a header value. (Reversal of :func:`quote_header_value`).
341
+ This does not use the real unquoting but what browsers are actually
342
+ using for quoting.
343
+
344
+ :param value: the header value to unquote.
345
+ :rtype: str
346
+ """
347
+ if value and value[0] == value[-1] == '"':
348
+ # this is not the real unquoting, but fixing this so that the
349
+ # RFC is met will result in bugs with internet explorer and
350
+ # probably some other browsers as well. IE for example is
351
+ # uploading files with "C:\foo\bar.txt" as filename
352
+ value = value[1:-1]
353
+
354
+ # if this is a filename and the starting characters look like
355
+ # a UNC path, then just return the value without quotes. Using the
356
+ # replace sequence below on a UNC path has the effect of turning
357
+ # the leading double slash into a single slash and then
358
+ # _fix_ie_filename() doesn't work correctly. See #458.
359
+ if not is_filename or value[:2] != '\\\\':
360
+ return value.replace('\\\\', '\\').replace('\\"', '"')
361
+ return value
362
+
363
+
364
+ def dict_from_cookiejar(cj):
365
+ """Returns a key/value dictionary from a CookieJar.
366
+
367
+ :param cj: CookieJar object to extract cookies from.
368
+ :rtype: dict
369
+ """
370
+
371
+ cookie_dict = {}
372
+
373
+ for cookie in cj:
374
+ cookie_dict[cookie.name] = cookie.value
375
+
376
+ return cookie_dict
377
+
378
+
379
+ def add_dict_to_cookiejar(cj, cookie_dict):
380
+ """Returns a CookieJar from a key/value dictionary.
381
+
382
+ :param cj: CookieJar to insert cookies into.
383
+ :param cookie_dict: Dict of key/values to insert into CookieJar.
384
+ :rtype: CookieJar
385
+ """
386
+
387
+ return cookiejar_from_dict(cookie_dict, cj)
388
+
389
+
390
+ def get_encodings_from_content(content):
391
+ """Returns encodings from given content string.
392
+
393
+ :param content: bytestring to extract encodings from.
394
+ """
395
+ warnings.warn((
396
+ 'In requests 3.0, get_encodings_from_content will be removed. For '
397
+ 'more information, please see the discussion on issue #2266. (This'
398
+ ' warning should only appear once.)'),
399
+ DeprecationWarning)
400
+
401
+ charset_re = re.compile(r'<meta.*?charset=["\']*(.+?)["\'>]', flags=re.I)
402
+ pragma_re = re.compile(r'<meta.*?content=["\']*;?charset=(.+?)["\'>]', flags=re.I)
403
+ xml_re = re.compile(r'^<\?xml.*?encoding=["\']*(.+?)["\'>]')
404
+
405
+ return (charset_re.findall(content) +
406
+ pragma_re.findall(content) +
407
+ xml_re.findall(content))
408
+
409
+
410
+ def get_encoding_from_headers(headers):
411
+ """Returns encodings from given HTTP Header Dict.
412
+
413
+ :param headers: dictionary to extract encoding from.
414
+ :rtype: str
415
+ """
416
+
417
+ content_type = headers.get('content-type')
418
+
419
+ if not content_type:
420
+ return None
421
+
422
+ content_type, params = cgi.parse_header(content_type)
423
+
424
+ if 'charset' in params:
425
+ return params['charset'].strip("'\"")
426
+
427
+ if 'text' in content_type:
428
+ return 'ISO-8859-1'
429
+
430
+
431
+ def stream_decode_response_unicode(iterator, r):
432
+ """Stream decodes a iterator."""
433
+
434
+ if r.encoding is None:
435
+ for item in iterator:
436
+ yield item
437
+ return
438
+
439
+ decoder = codecs.getincrementaldecoder(r.encoding)(errors='replace')
440
+ for chunk in iterator:
441
+ rv = decoder.decode(chunk)
442
+ if rv:
443
+ yield rv
444
+ rv = decoder.decode(b'', final=True)
445
+ if rv:
446
+ yield rv
447
+
448
+
449
+ def iter_slices(string, slice_length):
450
+ """Iterate over slices of a string."""
451
+ pos = 0
452
+ if slice_length is None or slice_length <= 0:
453
+ slice_length = len(string)
454
+ while pos < len(string):
455
+ yield string[pos:pos + slice_length]
456
+ pos += slice_length
457
+
458
+
459
+ def get_unicode_from_response(r):
460
+ """Returns the requested content back in unicode.
461
+
462
+ :param r: Response object to get unicode content from.
463
+
464
+ Tried:
465
+
466
+ 1. charset from content-type
467
+ 2. fall back and replace all unicode characters
468
+
469
+ :rtype: str
470
+ """
471
+ warnings.warn((
472
+ 'In requests 3.0, get_unicode_from_response will be removed. For '
473
+ 'more information, please see the discussion on issue #2266. (This'
474
+ ' warning should only appear once.)'),
475
+ DeprecationWarning)
476
+
477
+ tried_encodings = []
478
+
479
+ # Try charset from content-type
480
+ encoding = get_encoding_from_headers(r.headers)
481
+
482
+ if encoding:
483
+ try:
484
+ return str(r.content, encoding)
485
+ except UnicodeError:
486
+ tried_encodings.append(encoding)
487
+
488
+ # Fall back:
489
+ try:
490
+ return str(r.content, encoding, errors='replace')
491
+ except TypeError:
492
+ return r.content
493
+
494
+
495
+ # The unreserved URI characters (RFC 3986)
496
+ UNRESERVED_SET = frozenset(
497
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789-._~")
498
+
499
+
500
+ def unquote_unreserved(uri):
501
+ """Un-escape any percent-escape sequences in a URI that are unreserved
502
+ characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
503
+
504
+ :rtype: str
505
+ """
506
+ parts = uri.split('%')
507
+ for i in range(1, len(parts)):
508
+ h = parts[i][0:2]
509
+ if len(h) == 2 and h.isalnum():
510
+ try:
511
+ c = chr(int(h, 16))
512
+ except ValueError:
513
+ raise InvalidURL("Invalid percent-escape sequence: '%s'" % h)
514
+
515
+ if c in UNRESERVED_SET:
516
+ parts[i] = c + parts[i][2:]
517
+ else:
518
+ parts[i] = '%' + parts[i]
519
+ else:
520
+ parts[i] = '%' + parts[i]
521
+ return ''.join(parts)
522
+
523
+
524
+ def requote_uri(uri):
525
+ """Re-quote the given URI.
526
+
527
+ This function passes the given URI through an unquote/quote cycle to
528
+ ensure that it is fully and consistently quoted.
529
+
530
+ :rtype: str
531
+ """
532
+ safe_with_percent = "!#$%&'()*+,/:;=?@[]~"
533
+ safe_without_percent = "!#$&'()*+,/:;=?@[]~"
534
+ try:
535
+ # Unquote only the unreserved characters
536
+ # Then quote only illegal characters (do not quote reserved,
537
+ # unreserved, or '%')
538
+ return quote(unquote_unreserved(uri), safe=safe_with_percent)
539
+ except InvalidURL:
540
+ # We couldn't unquote the given URI, so let's try quoting it, but
541
+ # there may be unquoted '%'s in the URI. We need to make sure they're
542
+ # properly quoted so they do not cause issues elsewhere.
543
+ return quote(uri, safe=safe_without_percent)
544
+
545
+
546
+ def address_in_network(ip, net):
547
+ """This function allows you to check if an IP belongs to a network subnet
548
+
549
+ Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
550
+ returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
551
+
552
+ :rtype: bool
553
+ """
554
+ ipaddr = struct.unpack('=L', socket.inet_aton(ip))[0]
555
+ netaddr, bits = net.split('/')
556
+ netmask = struct.unpack('=L', socket.inet_aton(dotted_netmask(int(bits))))[0]
557
+ network = struct.unpack('=L', socket.inet_aton(netaddr))[0] & netmask
558
+ return (ipaddr & netmask) == (network & netmask)
559
+
560
+
561
+ def dotted_netmask(mask):
562
+ """Converts mask from /xx format to xxx.xxx.xxx.xxx
563
+
564
+ Example: if mask is 24 function returns 255.255.255.0
565
+
566
+ :rtype: str
567
+ """
568
+ bits = 0xffffffff ^ (1 << 32 - mask) - 1
569
+ return socket.inet_ntoa(struct.pack('>I', bits))
570
+
571
+
572
+ def is_ipv4_address(string_ip):
573
+ """
574
+ :rtype: bool
575
+ """
576
+ try:
577
+ socket.inet_aton(string_ip)
578
+ except socket.error:
579
+ return False
580
+ return True
581
+
582
+
583
+ def is_valid_cidr(string_network):
584
+ """
585
+ Very simple check of the cidr format in no_proxy variable.
586
+
587
+ :rtype: bool
588
+ """
589
+ if string_network.count('/') == 1:
590
+ try:
591
+ mask = int(string_network.split('/')[1])
592
+ except ValueError:
593
+ return False
594
+
595
+ if mask < 1 or mask > 32:
596
+ return False
597
+
598
+ try:
599
+ socket.inet_aton(string_network.split('/')[0])
600
+ except socket.error:
601
+ return False
602
+ else:
603
+ return False
604
+ return True
605
+
606
+
607
+ @contextlib.contextmanager
608
+ def set_environ(env_name, value):
609
+ """Set the environment variable 'env_name' to 'value'
610
+
611
+ Save previous value, yield, and then restore the previous value stored in
612
+ the environment variable 'env_name'.
613
+
614
+ If 'value' is None, do nothing"""
615
+ value_changed = value is not None
616
+ if value_changed:
617
+ old_value = os.environ.get(env_name)
618
+ os.environ[env_name] = value
619
+ try:
620
+ yield
621
+ finally:
622
+ if value_changed:
623
+ if old_value is None:
624
+ del os.environ[env_name]
625
+ else:
626
+ os.environ[env_name] = old_value
627
+
628
+
629
+ def should_bypass_proxies(url, no_proxy):
630
+ """
631
+ Returns whether we should bypass proxies or not.
632
+
633
+ :rtype: bool
634
+ """
635
+ get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper())
636
+
637
+ # First check whether no_proxy is defined. If it is, check that the URL
638
+ # we're getting isn't in the no_proxy list.
639
+ no_proxy_arg = no_proxy
640
+ if no_proxy is None:
641
+ no_proxy = get_proxy('no_proxy')
642
+ netloc = urlparse(url).netloc
643
+
644
+ if no_proxy:
645
+ # We need to check whether we match here. We need to see if we match
646
+ # the end of the netloc, both with and without the port.
647
+ no_proxy = (
648
+ host for host in no_proxy.replace(' ', '').split(',') if host
649
+ )
650
+
651
+ ip = netloc.split(':')[0]
652
+ if is_ipv4_address(ip):
653
+ for proxy_ip in no_proxy:
654
+ if is_valid_cidr(proxy_ip):
655
+ if address_in_network(ip, proxy_ip):
656
+ return True
657
+ elif ip == proxy_ip:
658
+ # If no_proxy ip was defined in plain IP notation instead of cidr notation &
659
+ # matches the IP of the index
660
+ return True
661
+ else:
662
+ for host in no_proxy:
663
+ if netloc.endswith(host) or netloc.split(':')[0].endswith(host):
664
+ # The URL does match something in no_proxy, so we don't want
665
+ # to apply the proxies on this URL.
666
+ return True
667
+
668
+ # If the system proxy settings indicate that this URL should be bypassed,
669
+ # don't proxy.
670
+ # The proxy_bypass function is incredibly buggy on OS X in early versions
671
+ # of Python 2.6, so allow this call to fail. Only catch the specific
672
+ # exceptions we've seen, though: this call failing in other ways can reveal
673
+ # legitimate problems.
674
+ with set_environ('no_proxy', no_proxy_arg):
675
+ try:
676
+ bypass = proxy_bypass(netloc)
677
+ except (TypeError, socket.gaierror):
678
+ bypass = False
679
+
680
+ if bypass:
681
+ return True
682
+
683
+ return False
684
+
685
+
686
+ def get_environ_proxies(url, no_proxy=None):
687
+ """
688
+ Return a dict of environment proxies.
689
+
690
+ :rtype: dict
691
+ """
692
+ if should_bypass_proxies(url, no_proxy=no_proxy):
693
+ return {}
694
+ else:
695
+ return getproxies()
696
+
697
+
698
+ def select_proxy(url, proxies):
699
+ """Select a proxy for the url, if applicable.
700
+
701
+ :param url: The url being for the request
702
+ :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
703
+ """
704
+ proxies = proxies or {}
705
+ urlparts = urlparse(url)
706
+ if urlparts.hostname is None:
707
+ return proxies.get(urlparts.scheme, proxies.get('all'))
708
+
709
+ proxy_keys = [
710
+ urlparts.scheme + '://' + urlparts.hostname,
711
+ urlparts.scheme,
712
+ 'all://' + urlparts.hostname,
713
+ 'all',
714
+ ]
715
+ proxy = None
716
+ for proxy_key in proxy_keys:
717
+ if proxy_key in proxies:
718
+ proxy = proxies[proxy_key]
719
+ break
720
+
721
+ return proxy
722
+
723
+
724
+ def default_user_agent(name="python-requests"):
725
+ """
726
+ Return a string representing the default user agent.
727
+
728
+ :rtype: str
729
+ """
730
+ return '%s/%s' % (name, __version__)
731
+
732
+
733
+ def default_headers():
734
+ """
735
+ :rtype: requests.structures.CaseInsensitiveDict
736
+ """
737
+ return CaseInsensitiveDict({
738
+ 'User-Agent': default_user_agent(),
739
+ 'Accept-Encoding': ', '.join(('gzip', 'deflate')),
740
+ 'Accept': '*/*',
741
+ 'Connection': 'keep-alive',
742
+ })
743
+
744
+
745
+ def parse_header_links(value):
746
+ """Return a dict of parsed link headers proxies.
747
+
748
+ i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
749
+
750
+ :rtype: list
751
+ """
752
+
753
+ links = []
754
+
755
+ replace_chars = ' \'"'
756
+
757
+ for val in re.split(', *<', value):
758
+ try:
759
+ url, params = val.split(';', 1)
760
+ except ValueError:
761
+ url, params = val, ''
762
+
763
+ link = {'url': url.strip('<> \'"')}
764
+
765
+ for param in params.split(';'):
766
+ try:
767
+ key, value = param.split('=')
768
+ except ValueError:
769
+ break
770
+
771
+ link[key.strip(replace_chars)] = value.strip(replace_chars)
772
+
773
+ links.append(link)
774
+
775
+ return links
776
+
777
+
778
+ # Null bytes; no need to recreate these on each call to guess_json_utf
779
+ _null = '\x00'.encode('ascii') # encoding to ASCII for Python 3
780
+ _null2 = _null * 2
781
+ _null3 = _null * 3
782
+
783
+
784
+ def guess_json_utf(data):
785
+ """
786
+ :rtype: str
787
+ """
788
+ # JSON always starts with two ASCII characters, so detection is as
789
+ # easy as counting the nulls and from their location and count
790
+ # determine the encoding. Also detect a BOM, if present.
791
+ sample = data[:4]
792
+ if sample in (codecs.BOM_UTF32_LE, codecs.BOM_UTF32_BE):
793
+ return 'utf-32' # BOM included
794
+ if sample[:3] == codecs.BOM_UTF8:
795
+ return 'utf-8-sig' # BOM included, MS style (discouraged)
796
+ if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE):
797
+ return 'utf-16' # BOM included
798
+ nullcount = sample.count(_null)
799
+ if nullcount == 0:
800
+ return 'utf-8'
801
+ if nullcount == 2:
802
+ if sample[::2] == _null2: # 1st and 3rd are null
803
+ return 'utf-16-be'
804
+ if sample[1::2] == _null2: # 2nd and 4th are null
805
+ return 'utf-16-le'
806
+ # Did not detect 2 valid UTF-16 ascii-range characters
807
+ if nullcount == 3:
808
+ if sample[:3] == _null3:
809
+ return 'utf-32-be'
810
+ if sample[1:] == _null3:
811
+ return 'utf-32-le'
812
+ # Did not detect a valid UTF-32 ascii-range character
813
+ return None
814
+
815
+
816
+ def prepend_scheme_if_needed(url, new_scheme):
817
+ """Given a URL that may or may not have a scheme, prepend the given scheme.
818
+ Does not replace a present scheme with the one provided as an argument.
819
+
820
+ :rtype: str
821
+ """
822
+ scheme, netloc, path, params, query, fragment = urlparse(url, new_scheme)
823
+
824
+ # urlparse is a finicky beast, and sometimes decides that there isn't a
825
+ # netloc present. Assume that it's being over-cautious, and switch netloc
826
+ # and path if urlparse decided there was no netloc.
827
+ if not netloc:
828
+ netloc, path = path, netloc
829
+
830
+ return urlunparse((scheme, netloc, path, params, query, fragment))
831
+
832
+
833
+ def get_auth_from_url(url):
834
+ """Given a url with authentication components, extract them into a tuple of
835
+ username,password.
836
+
837
+ :rtype: (str,str)
838
+ """
839
+ parsed = urlparse(url)
840
+
841
+ try:
842
+ auth = (unquote(parsed.username), unquote(parsed.password))
843
+ except (AttributeError, TypeError):
844
+ auth = ('', '')
845
+
846
+ return auth
847
+
848
+
849
+ # Moved outside of function to avoid recompile every call
850
+ _CLEAN_HEADER_REGEX_BYTE = re.compile(b'^\\S[^\\r\\n]*$|^$')
851
+ _CLEAN_HEADER_REGEX_STR = re.compile(r'^\S[^\r\n]*$|^$')
852
+
853
+
854
+ def check_header_validity(header):
855
+ """Verifies that header value is a string which doesn't contain
856
+ leading whitespace or return characters. This prevents unintended
857
+ header injection.
858
+
859
+ :param header: tuple, in the format (name, value).
860
+ """
861
+ name, value = header
862
+
863
+ if isinstance(value, bytes):
864
+ pat = _CLEAN_HEADER_REGEX_BYTE
865
+ else:
866
+ pat = _CLEAN_HEADER_REGEX_STR
867
+ try:
868
+ if not pat.match(value):
869
+ raise InvalidHeader("Invalid return character or leading space in header: %s" % name)
870
+ except TypeError:
871
+ raise InvalidHeader("Value for header {%s: %s} must be of type str or "
872
+ "bytes, not %s" % (name, value, type(value)))
873
+
874
+
875
+ def urldefragauth(url):
876
+ """
877
+ Given a url remove the fragment and the authentication part.
878
+
879
+ :rtype: str
880
+ """
881
+ scheme, netloc, path, params, query, fragment = urlparse(url)
882
+
883
+ # see func:`prepend_scheme_if_needed`
884
+ if not netloc:
885
+ netloc, path = path, netloc
886
+
887
+ netloc = netloc.rsplit('@', 1)[-1]
888
+
889
+ return urlunparse((scheme, netloc, path, params, query, ''))
890
+
891
+
892
+ def rewind_body(prepared_request):
893
+ """Move file pointer back to its recorded starting position
894
+ so it can be read again on redirect.
895
+ """
896
+ body_seek = getattr(prepared_request.body, 'seek', None)
897
+ if body_seek is not None and isinstance(prepared_request._body_position, integer_types):
898
+ try:
899
+ body_seek(prepared_request._body_position)
900
+ except (IOError, OSError):
901
+ raise UnrewindableBodyError("An error occurred when rewinding request "
902
+ "body for redirect.")
903
+ else:
904
+ raise UnrewindableBodyError("Unable to rewind request body for redirect.")