com.googler.python 1.0.7 → 1.0.9

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 (354) hide show
  1. package/package.json +4 -2
  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/_vendor/_markerlib/__init__.py +0 -16
  290. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/_markerlib/markers.py +0 -119
  291. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/sanitizer.py +0 -271
  292. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer/__init__.py +0 -16
  293. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/serializer/htmlserializer.py +0 -320
  294. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/html5lib/treewalkers/pulldom.py +0 -63
  295. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/re-vendor.py +0 -34
  296. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/__init__.py +0 -3
  297. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/big5freq.py +0 -925
  298. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py +0 -46
  299. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/charsetgroupprober.py +0 -106
  300. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/charsetprober.py +0 -62
  301. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/codingstatemachine.py +0 -61
  302. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/constants.py +0 -39
  303. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/escprober.py +0 -86
  304. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/escsm.py +0 -242
  305. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/eucjpprober.py +0 -90
  306. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/euckrfreq.py +0 -596
  307. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/mbcharsetprober.py +0 -86
  308. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/mbcssm.py +0 -575
  309. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/sbcharsetprober.py +0 -120
  310. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/sjisprober.py +0 -91
  311. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/chardet/universaldetector.py +0 -170
  312. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py +0 -58
  313. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/_collections.py +0 -205
  314. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connection.py +0 -204
  315. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py +0 -422
  316. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/exceptions.py +0 -126
  317. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/packages/six.py +0 -385
  318. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/poolmanager.py +0 -258
  319. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/response.py +0 -308
  320. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/__init__.py +0 -27
  321. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/connection.py +0 -45
  322. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/request.py +0 -68
  323. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/response.py +0 -13
  324. package/python3.4.2/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py +0 -133
  325. package/python3.4.2/lib/python3.4/site-packages/pip/backwardcompat/__init__.py +0 -138
  326. package/python3.4.2/lib/python3.4/site-packages/pip/basecommand.py +0 -201
  327. package/python3.4.2/lib/python3.4/site-packages/pip/cmdoptions.py +0 -371
  328. package/python3.4.2/lib/python3.4/site-packages/pip/commands/__init__.py +0 -88
  329. package/python3.4.2/lib/python3.4/site-packages/pip/commands/bundle.py +0 -42
  330. package/python3.4.2/lib/python3.4/site-packages/pip/commands/completion.py +0 -59
  331. package/python3.4.2/lib/python3.4/site-packages/pip/commands/freeze.py +0 -114
  332. package/python3.4.2/lib/python3.4/site-packages/pip/commands/install.py +0 -314
  333. package/python3.4.2/lib/python3.4/site-packages/pip/commands/list.py +0 -162
  334. package/python3.4.2/lib/python3.4/site-packages/pip/commands/search.py +0 -132
  335. package/python3.4.2/lib/python3.4/site-packages/pip/commands/show.py +0 -80
  336. package/python3.4.2/lib/python3.4/site-packages/pip/commands/uninstall.py +0 -59
  337. package/python3.4.2/lib/python3.4/site-packages/pip/commands/unzip.py +0 -7
  338. package/python3.4.2/lib/python3.4/site-packages/pip/commands/wheel.py +0 -195
  339. package/python3.4.2/lib/python3.4/site-packages/pip/commands/zip.py +0 -351
  340. package/python3.4.2/lib/python3.4/site-packages/pip/download.py +0 -644
  341. package/python3.4.2/lib/python3.4/site-packages/pip/exceptions.py +0 -46
  342. package/python3.4.2/lib/python3.4/site-packages/pip/index.py +0 -990
  343. package/python3.4.2/lib/python3.4/site-packages/pip/locations.py +0 -171
  344. package/python3.4.2/lib/python3.4/site-packages/pip/log.py +0 -276
  345. package/python3.4.2/lib/python3.4/site-packages/pip/pep425tags.py +0 -102
  346. package/python3.4.2/lib/python3.4/site-packages/pip/req.py +0 -1931
  347. package/python3.4.2/lib/python3.4/site-packages/pip/runner.py +0 -18
  348. package/python3.4.2/lib/python3.4/site-packages/pip/util.py +0 -720
  349. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/__init__.py +0 -251
  350. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/bazaar.py +0 -131
  351. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/git.py +0 -194
  352. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/mercurial.py +0 -151
  353. package/python3.4.2/lib/python3.4/site-packages/pip/vcs/subversion.py +0 -273
  354. package/python3.4.2/lib/python3.4/site-packages/pip/wheel.py +0 -560
@@ -1,454 +1,542 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- """
4
- Compatibility code to be able to use `cookielib.CookieJar` with requests.
5
-
6
- requests.utils imports from here, so be careful with imports.
7
- """
8
-
9
- import time
10
- import collections
11
- from .compat import cookielib, urlparse, urlunparse, Morsel
12
-
13
- try:
14
- import threading
15
- # grr, pyflakes: this fixes "redefinition of unused 'threading'"
16
- threading
17
- except ImportError:
18
- import dummy_threading as threading
19
-
20
-
21
- class MockRequest(object):
22
- """Wraps a `requests.Request` to mimic a `urllib2.Request`.
23
-
24
- The code in `cookielib.CookieJar` expects this interface in order to correctly
25
- manage cookie policies, i.e., determine whether a cookie can be set, given the
26
- domains of the request and the cookie.
27
-
28
- The original request object is read-only. The client is responsible for collecting
29
- the new headers via `get_new_headers()` and interpreting them appropriately. You
30
- probably want `get_cookie_header`, defined below.
31
- """
32
-
33
- def __init__(self, request):
34
- self._r = request
35
- self._new_headers = {}
36
- self.type = urlparse(self._r.url).scheme
37
-
38
- def get_type(self):
39
- return self.type
40
-
41
- def get_host(self):
42
- return urlparse(self._r.url).netloc
43
-
44
- def get_origin_req_host(self):
45
- return self.get_host()
46
-
47
- def get_full_url(self):
48
- # Only return the response's URL if the user hadn't set the Host
49
- # header
50
- if not self._r.headers.get('Host'):
51
- return self._r.url
52
- # If they did set it, retrieve it and reconstruct the expected domain
53
- host = self._r.headers['Host']
54
- parsed = urlparse(self._r.url)
55
- # Reconstruct the URL as we expect it
56
- return urlunparse([
57
- parsed.scheme, host, parsed.path, parsed.params, parsed.query,
58
- parsed.fragment
59
- ])
60
-
61
- def is_unverifiable(self):
62
- return True
63
-
64
- def has_header(self, name):
65
- return name in self._r.headers or name in self._new_headers
66
-
67
- def get_header(self, name, default=None):
68
- return self._r.headers.get(name, self._new_headers.get(name, default))
69
-
70
- def add_header(self, key, val):
71
- """cookielib has no legitimate use for this method; add it back if you find one."""
72
- raise NotImplementedError("Cookie headers should be added with add_unredirected_header()")
73
-
74
- def add_unredirected_header(self, name, value):
75
- self._new_headers[name] = value
76
-
77
- def get_new_headers(self):
78
- return self._new_headers
79
-
80
- @property
81
- def unverifiable(self):
82
- return self.is_unverifiable()
83
-
84
- @property
85
- def origin_req_host(self):
86
- return self.get_origin_req_host()
87
-
88
- @property
89
- def host(self):
90
- return self.get_host()
91
-
92
-
93
- class MockResponse(object):
94
- """Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.
95
-
96
- ...what? Basically, expose the parsed HTTP headers from the server response
97
- the way `cookielib` expects to see them.
98
- """
99
-
100
- def __init__(self, headers):
101
- """Make a MockResponse for `cookielib` to read.
102
-
103
- :param headers: a httplib.HTTPMessage or analogous carrying the headers
104
- """
105
- self._headers = headers
106
-
107
- def info(self):
108
- return self._headers
109
-
110
- def getheaders(self, name):
111
- self._headers.getheaders(name)
112
-
113
-
114
- def extract_cookies_to_jar(jar, request, response):
115
- """Extract the cookies from the response into a CookieJar.
116
-
117
- :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
118
- :param request: our own requests.Request object
119
- :param response: urllib3.HTTPResponse object
120
- """
121
- if not (hasattr(response, '_original_response') and
122
- response._original_response):
123
- return
124
- # the _original_response field is the wrapped httplib.HTTPResponse object,
125
- req = MockRequest(request)
126
- # pull out the HTTPMessage with the headers and put it in the mock:
127
- res = MockResponse(response._original_response.msg)
128
- jar.extract_cookies(res, req)
129
-
130
-
131
- def get_cookie_header(jar, request):
132
- """Produce an appropriate Cookie header string to be sent with `request`, or None."""
133
- r = MockRequest(request)
134
- jar.add_cookie_header(r)
135
- return r.get_new_headers().get('Cookie')
136
-
137
-
138
- def remove_cookie_by_name(cookiejar, name, domain=None, path=None):
139
- """Unsets a cookie by name, by default over all domains and paths.
140
-
141
- Wraps CookieJar.clear(), is O(n).
142
- """
143
- clearables = []
144
- for cookie in cookiejar:
145
- if cookie.name == name:
146
- if domain is None or domain == cookie.domain:
147
- if path is None or path == cookie.path:
148
- clearables.append((cookie.domain, cookie.path, cookie.name))
149
-
150
- for domain, path, name in clearables:
151
- cookiejar.clear(domain, path, name)
152
-
153
-
154
- class CookieConflictError(RuntimeError):
155
- """There are two cookies that meet the criteria specified in the cookie jar.
156
- Use .get and .set and include domain and path args in order to be more specific."""
157
-
158
-
159
- class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
160
- """Compatibility class; is a cookielib.CookieJar, but exposes a dict interface.
161
-
162
- This is the CookieJar we create by default for requests and sessions that
163
- don't specify one, since some clients may expect response.cookies and
164
- session.cookies to support dict operations.
165
-
166
- Don't use the dict interface internally; it's just for compatibility with
167
- with external client code. All `requests` code should work out of the box
168
- with externally provided instances of CookieJar, e.g., LWPCookieJar and
169
- FileCookieJar.
170
-
171
- Caution: dictionary operations that are normally O(1) may be O(n).
172
-
173
- Unlike a regular CookieJar, this class is pickleable.
174
- """
175
-
176
- def get(self, name, default=None, domain=None, path=None):
177
- """Dict-like get() that also supports optional domain and path args in
178
- order to resolve naming collisions from using one cookie jar over
179
- multiple domains. Caution: operation is O(n), not O(1)."""
180
- try:
181
- return self._find_no_duplicates(name, domain, path)
182
- except KeyError:
183
- return default
184
-
185
- def set(self, name, value, **kwargs):
186
- """Dict-like set() that also supports optional domain and path args in
187
- order to resolve naming collisions from using one cookie jar over
188
- multiple domains."""
189
- # support client code that unsets cookies by assignment of a None value:
190
- if value is None:
191
- remove_cookie_by_name(self, name, domain=kwargs.get('domain'), path=kwargs.get('path'))
192
- return
193
-
194
- if isinstance(value, Morsel):
195
- c = morsel_to_cookie(value)
196
- else:
197
- c = create_cookie(name, value, **kwargs)
198
- self.set_cookie(c)
199
- return c
200
-
201
- def iterkeys(self):
202
- """Dict-like iterkeys() that returns an iterator of names of cookies from the jar.
203
- See itervalues() and iteritems()."""
204
- for cookie in iter(self):
205
- yield cookie.name
206
-
207
- def keys(self):
208
- """Dict-like keys() that returns a list of names of cookies from the jar.
209
- See values() and items()."""
210
- return list(self.iterkeys())
211
-
212
- def itervalues(self):
213
- """Dict-like itervalues() that returns an iterator of values of cookies from the jar.
214
- See iterkeys() and iteritems()."""
215
- for cookie in iter(self):
216
- yield cookie.value
217
-
218
- def values(self):
219
- """Dict-like values() that returns a list of values of cookies from the jar.
220
- See keys() and items()."""
221
- return list(self.itervalues())
222
-
223
- def iteritems(self):
224
- """Dict-like iteritems() that returns an iterator of name-value tuples from the jar.
225
- See iterkeys() and itervalues()."""
226
- for cookie in iter(self):
227
- yield cookie.name, cookie.value
228
-
229
- def items(self):
230
- """Dict-like items() that returns a list of name-value tuples from the jar.
231
- See keys() and values(). Allows client-code to call "dict(RequestsCookieJar)
232
- and get a vanilla python dict of key value pairs."""
233
- return list(self.iteritems())
234
-
235
- def list_domains(self):
236
- """Utility method to list all the domains in the jar."""
237
- domains = []
238
- for cookie in iter(self):
239
- if cookie.domain not in domains:
240
- domains.append(cookie.domain)
241
- return domains
242
-
243
- def list_paths(self):
244
- """Utility method to list all the paths in the jar."""
245
- paths = []
246
- for cookie in iter(self):
247
- if cookie.path not in paths:
248
- paths.append(cookie.path)
249
- return paths
250
-
251
- def multiple_domains(self):
252
- """Returns True if there are multiple domains in the jar.
253
- Returns False otherwise."""
254
- domains = []
255
- for cookie in iter(self):
256
- if cookie.domain is not None and cookie.domain in domains:
257
- return True
258
- domains.append(cookie.domain)
259
- return False # there is only one domain in jar
260
-
261
- def get_dict(self, domain=None, path=None):
262
- """Takes as an argument an optional domain and path and returns a plain old
263
- Python dict of name-value pairs of cookies that meet the requirements."""
264
- dictionary = {}
265
- for cookie in iter(self):
266
- if (domain is None or cookie.domain == domain) and (path is None
267
- or cookie.path == path):
268
- dictionary[cookie.name] = cookie.value
269
- return dictionary
270
-
271
- def __getitem__(self, name):
272
- """Dict-like __getitem__() for compatibility with client code. Throws exception
273
- if there are more than one cookie with name. In that case, use the more
274
- explicit get() method instead. Caution: operation is O(n), not O(1)."""
275
-
276
- return self._find_no_duplicates(name)
277
-
278
- def __setitem__(self, name, value):
279
- """Dict-like __setitem__ for compatibility with client code. Throws exception
280
- if there is already a cookie of that name in the jar. In that case, use the more
281
- explicit set() method instead."""
282
-
283
- self.set(name, value)
284
-
285
- def __delitem__(self, name):
286
- """Deletes a cookie given a name. Wraps cookielib.CookieJar's remove_cookie_by_name()."""
287
- remove_cookie_by_name(self, name)
288
-
289
- def set_cookie(self, cookie, *args, **kwargs):
290
- if hasattr(cookie.value, 'startswith') and cookie.value.startswith('"') and cookie.value.endswith('"'):
291
- cookie.value = cookie.value.replace('\\"', '')
292
- return super(RequestsCookieJar, self).set_cookie(cookie, *args, **kwargs)
293
-
294
- def update(self, other):
295
- """Updates this jar with cookies from another CookieJar or dict-like"""
296
- if isinstance(other, cookielib.CookieJar):
297
- for cookie in other:
298
- self.set_cookie(cookie)
299
- else:
300
- super(RequestsCookieJar, self).update(other)
301
-
302
- def _find(self, name, domain=None, path=None):
303
- """Requests uses this method internally to get cookie values. Takes as args name
304
- and optional domain and path. Returns a cookie.value. If there are conflicting cookies,
305
- _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown
306
- if there are conflicting cookies."""
307
- for cookie in iter(self):
308
- if cookie.name == name:
309
- if domain is None or cookie.domain == domain:
310
- if path is None or cookie.path == path:
311
- return cookie.value
312
-
313
- raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
314
-
315
- def _find_no_duplicates(self, name, domain=None, path=None):
316
- """__get_item__ and get call _find_no_duplicates -- never used in Requests internally.
317
- Takes as args name and optional domain and path. Returns a cookie.value.
318
- Throws KeyError if cookie is not found and CookieConflictError if there are
319
- multiple cookies that match name and optionally domain and path."""
320
- toReturn = None
321
- for cookie in iter(self):
322
- if cookie.name == name:
323
- if domain is None or cookie.domain == domain:
324
- if path is None or cookie.path == path:
325
- if toReturn is not None: # if there are multiple cookies that meet passed in criteria
326
- raise CookieConflictError('There are multiple cookies with name, %r' % (name))
327
- toReturn = cookie.value # we will eventually return this as long as no cookie conflict
328
-
329
- if toReturn:
330
- return toReturn
331
- raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
332
-
333
- def __getstate__(self):
334
- """Unlike a normal CookieJar, this class is pickleable."""
335
- state = self.__dict__.copy()
336
- # remove the unpickleable RLock object
337
- state.pop('_cookies_lock')
338
- return state
339
-
340
- def __setstate__(self, state):
341
- """Unlike a normal CookieJar, this class is pickleable."""
342
- self.__dict__.update(state)
343
- if '_cookies_lock' not in self.__dict__:
344
- self._cookies_lock = threading.RLock()
345
-
346
- def copy(self):
347
- """Return a copy of this RequestsCookieJar."""
348
- new_cj = RequestsCookieJar()
349
- new_cj.update(self)
350
- return new_cj
351
-
352
-
353
- def create_cookie(name, value, **kwargs):
354
- """Make a cookie from underspecified parameters.
355
-
356
- By default, the pair of `name` and `value` will be set for the domain ''
357
- and sent on every request (this is sometimes called a "supercookie").
358
- """
359
- result = dict(
360
- version=0,
361
- name=name,
362
- value=value,
363
- port=None,
364
- domain='',
365
- path='/',
366
- secure=False,
367
- expires=None,
368
- discard=True,
369
- comment=None,
370
- comment_url=None,
371
- rest={'HttpOnly': None},
372
- rfc2109=False,)
373
-
374
- badargs = set(kwargs) - set(result)
375
- if badargs:
376
- err = 'create_cookie() got unexpected keyword arguments: %s'
377
- raise TypeError(err % list(badargs))
378
-
379
- result.update(kwargs)
380
- result['port_specified'] = bool(result['port'])
381
- result['domain_specified'] = bool(result['domain'])
382
- result['domain_initial_dot'] = result['domain'].startswith('.')
383
- result['path_specified'] = bool(result['path'])
384
-
385
- return cookielib.Cookie(**result)
386
-
387
-
388
- def morsel_to_cookie(morsel):
389
- """Convert a Morsel object into a Cookie containing the one k/v pair."""
390
-
391
- expires = None
392
- if morsel['max-age']:
393
- expires = time.time() + morsel['max-age']
394
- elif morsel['expires']:
395
- time_template = '%a, %d-%b-%Y %H:%M:%S GMT'
396
- expires = time.mktime(
397
- time.strptime(morsel['expires'], time_template)) - time.timezone
398
- return create_cookie(
399
- comment=morsel['comment'],
400
- comment_url=bool(morsel['comment']),
401
- discard=False,
402
- domain=morsel['domain'],
403
- expires=expires,
404
- name=morsel.key,
405
- path=morsel['path'],
406
- port=None,
407
- rest={'HttpOnly': morsel['httponly']},
408
- rfc2109=False,
409
- secure=bool(morsel['secure']),
410
- value=morsel.value,
411
- version=morsel['version'] or 0,
412
- )
413
-
414
-
415
- def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
416
- """Returns a CookieJar from a key/value dictionary.
417
-
418
- :param cookie_dict: Dict of key/values to insert into CookieJar.
419
- :param cookiejar: (optional) A cookiejar to add the cookies to.
420
- :param overwrite: (optional) If False, will not replace cookies
421
- already in the jar with new ones.
422
- """
423
- if cookiejar is None:
424
- cookiejar = RequestsCookieJar()
425
-
426
- if cookie_dict is not None:
427
- names_from_jar = [cookie.name for cookie in cookiejar]
428
- for name in cookie_dict:
429
- if overwrite or (name not in names_from_jar):
430
- cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
431
-
432
- return cookiejar
433
-
434
-
435
- def merge_cookies(cookiejar, cookies):
436
- """Add cookies to cookiejar and returns a merged CookieJar.
437
-
438
- :param cookiejar: CookieJar object to add the cookies to.
439
- :param cookies: Dictionary or CookieJar object to be added.
440
- """
441
- if not isinstance(cookiejar, cookielib.CookieJar):
442
- raise ValueError('You can only merge into CookieJar')
443
-
444
- if isinstance(cookies, dict):
445
- cookiejar = cookiejar_from_dict(
446
- cookies, cookiejar=cookiejar, overwrite=False)
447
- elif isinstance(cookies, cookielib.CookieJar):
448
- try:
449
- cookiejar.update(cookies)
450
- except AttributeError:
451
- for cookie_in_jar in cookies:
452
- cookiejar.set_cookie(cookie_in_jar)
453
-
454
- return cookiejar
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ requests.cookies
5
+ ~~~~~~~~~~~~~~~~
6
+
7
+ Compatibility code to be able to use `cookielib.CookieJar` with requests.
8
+
9
+ requests.utils imports from here, so be careful with imports.
10
+ """
11
+
12
+ import copy
13
+ import time
14
+ import calendar
15
+ import collections
16
+
17
+ from ._internal_utils import to_native_string
18
+ from .compat import cookielib, urlparse, urlunparse, Morsel
19
+
20
+ try:
21
+ import threading
22
+ except ImportError:
23
+ import dummy_threading as threading
24
+
25
+
26
+ class MockRequest(object):
27
+ """Wraps a `requests.Request` to mimic a `urllib2.Request`.
28
+
29
+ The code in `cookielib.CookieJar` expects this interface in order to correctly
30
+ manage cookie policies, i.e., determine whether a cookie can be set, given the
31
+ domains of the request and the cookie.
32
+
33
+ The original request object is read-only. The client is responsible for collecting
34
+ the new headers via `get_new_headers()` and interpreting them appropriately. You
35
+ probably want `get_cookie_header`, defined below.
36
+ """
37
+
38
+ def __init__(self, request):
39
+ self._r = request
40
+ self._new_headers = {}
41
+ self.type = urlparse(self._r.url).scheme
42
+
43
+ def get_type(self):
44
+ return self.type
45
+
46
+ def get_host(self):
47
+ return urlparse(self._r.url).netloc
48
+
49
+ def get_origin_req_host(self):
50
+ return self.get_host()
51
+
52
+ def get_full_url(self):
53
+ # Only return the response's URL if the user hadn't set the Host
54
+ # header
55
+ if not self._r.headers.get('Host'):
56
+ return self._r.url
57
+ # If they did set it, retrieve it and reconstruct the expected domain
58
+ host = to_native_string(self._r.headers['Host'], encoding='utf-8')
59
+ parsed = urlparse(self._r.url)
60
+ # Reconstruct the URL as we expect it
61
+ return urlunparse([
62
+ parsed.scheme, host, parsed.path, parsed.params, parsed.query,
63
+ parsed.fragment
64
+ ])
65
+
66
+ def is_unverifiable(self):
67
+ return True
68
+
69
+ def has_header(self, name):
70
+ return name in self._r.headers or name in self._new_headers
71
+
72
+ def get_header(self, name, default=None):
73
+ return self._r.headers.get(name, self._new_headers.get(name, default))
74
+
75
+ def add_header(self, key, val):
76
+ """cookielib has no legitimate use for this method; add it back if you find one."""
77
+ raise NotImplementedError("Cookie headers should be added with add_unredirected_header()")
78
+
79
+ def add_unredirected_header(self, name, value):
80
+ self._new_headers[name] = value
81
+
82
+ def get_new_headers(self):
83
+ return self._new_headers
84
+
85
+ @property
86
+ def unverifiable(self):
87
+ return self.is_unverifiable()
88
+
89
+ @property
90
+ def origin_req_host(self):
91
+ return self.get_origin_req_host()
92
+
93
+ @property
94
+ def host(self):
95
+ return self.get_host()
96
+
97
+
98
+ class MockResponse(object):
99
+ """Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.
100
+
101
+ ...what? Basically, expose the parsed HTTP headers from the server response
102
+ the way `cookielib` expects to see them.
103
+ """
104
+
105
+ def __init__(self, headers):
106
+ """Make a MockResponse for `cookielib` to read.
107
+
108
+ :param headers: a httplib.HTTPMessage or analogous carrying the headers
109
+ """
110
+ self._headers = headers
111
+
112
+ def info(self):
113
+ return self._headers
114
+
115
+ def getheaders(self, name):
116
+ self._headers.getheaders(name)
117
+
118
+
119
+ def extract_cookies_to_jar(jar, request, response):
120
+ """Extract the cookies from the response into a CookieJar.
121
+
122
+ :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
123
+ :param request: our own requests.Request object
124
+ :param response: urllib3.HTTPResponse object
125
+ """
126
+ if not (hasattr(response, '_original_response') and
127
+ response._original_response):
128
+ return
129
+ # the _original_response field is the wrapped httplib.HTTPResponse object,
130
+ req = MockRequest(request)
131
+ # pull out the HTTPMessage with the headers and put it in the mock:
132
+ res = MockResponse(response._original_response.msg)
133
+ jar.extract_cookies(res, req)
134
+
135
+
136
+ def get_cookie_header(jar, request):
137
+ """
138
+ Produce an appropriate Cookie header string to be sent with `request`, or None.
139
+
140
+ :rtype: str
141
+ """
142
+ r = MockRequest(request)
143
+ jar.add_cookie_header(r)
144
+ return r.get_new_headers().get('Cookie')
145
+
146
+
147
+ def remove_cookie_by_name(cookiejar, name, domain=None, path=None):
148
+ """Unsets a cookie by name, by default over all domains and paths.
149
+
150
+ Wraps CookieJar.clear(), is O(n).
151
+ """
152
+ clearables = []
153
+ for cookie in cookiejar:
154
+ if cookie.name != name:
155
+ continue
156
+ if domain is not None and domain != cookie.domain:
157
+ continue
158
+ if path is not None and path != cookie.path:
159
+ continue
160
+ clearables.append((cookie.domain, cookie.path, cookie.name))
161
+
162
+ for domain, path, name in clearables:
163
+ cookiejar.clear(domain, path, name)
164
+
165
+
166
+ class CookieConflictError(RuntimeError):
167
+ """There are two cookies that meet the criteria specified in the cookie jar.
168
+ Use .get and .set and include domain and path args in order to be more specific.
169
+ """
170
+
171
+
172
+ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
173
+ """Compatibility class; is a cookielib.CookieJar, but exposes a dict
174
+ interface.
175
+
176
+ This is the CookieJar we create by default for requests and sessions that
177
+ don't specify one, since some clients may expect response.cookies and
178
+ session.cookies to support dict operations.
179
+
180
+ Requests does not use the dict interface internally; it's just for
181
+ compatibility with external client code. All requests code should work
182
+ out of the box with externally provided instances of ``CookieJar``, e.g.
183
+ ``LWPCookieJar`` and ``FileCookieJar``.
184
+
185
+ Unlike a regular CookieJar, this class is pickleable.
186
+
187
+ .. warning:: dictionary operations that are normally O(1) may be O(n).
188
+ """
189
+
190
+ def get(self, name, default=None, domain=None, path=None):
191
+ """Dict-like get() that also supports optional domain and path args in
192
+ order to resolve naming collisions from using one cookie jar over
193
+ multiple domains.
194
+
195
+ .. warning:: operation is O(n), not O(1).
196
+ """
197
+ try:
198
+ return self._find_no_duplicates(name, domain, path)
199
+ except KeyError:
200
+ return default
201
+
202
+ def set(self, name, value, **kwargs):
203
+ """Dict-like set() that also supports optional domain and path args in
204
+ order to resolve naming collisions from using one cookie jar over
205
+ multiple domains.
206
+ """
207
+ # support client code that unsets cookies by assignment of a None value:
208
+ if value is None:
209
+ remove_cookie_by_name(self, name, domain=kwargs.get('domain'), path=kwargs.get('path'))
210
+ return
211
+
212
+ if isinstance(value, Morsel):
213
+ c = morsel_to_cookie(value)
214
+ else:
215
+ c = create_cookie(name, value, **kwargs)
216
+ self.set_cookie(c)
217
+ return c
218
+
219
+ def iterkeys(self):
220
+ """Dict-like iterkeys() that returns an iterator of names of cookies
221
+ from the jar.
222
+
223
+ .. seealso:: itervalues() and iteritems().
224
+ """
225
+ for cookie in iter(self):
226
+ yield cookie.name
227
+
228
+ def keys(self):
229
+ """Dict-like keys() that returns a list of names of cookies from the
230
+ jar.
231
+
232
+ .. seealso:: values() and items().
233
+ """
234
+ return list(self.iterkeys())
235
+
236
+ def itervalues(self):
237
+ """Dict-like itervalues() that returns an iterator of values of cookies
238
+ from the jar.
239
+
240
+ .. seealso:: iterkeys() and iteritems().
241
+ """
242
+ for cookie in iter(self):
243
+ yield cookie.value
244
+
245
+ def values(self):
246
+ """Dict-like values() that returns a list of values of cookies from the
247
+ jar.
248
+
249
+ .. seealso:: keys() and items().
250
+ """
251
+ return list(self.itervalues())
252
+
253
+ def iteritems(self):
254
+ """Dict-like iteritems() that returns an iterator of name-value tuples
255
+ from the jar.
256
+
257
+ .. seealso:: iterkeys() and itervalues().
258
+ """
259
+ for cookie in iter(self):
260
+ yield cookie.name, cookie.value
261
+
262
+ def items(self):
263
+ """Dict-like items() that returns a list of name-value tuples from the
264
+ jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a
265
+ vanilla python dict of key value pairs.
266
+
267
+ .. seealso:: keys() and values().
268
+ """
269
+ return list(self.iteritems())
270
+
271
+ def list_domains(self):
272
+ """Utility method to list all the domains in the jar."""
273
+ domains = []
274
+ for cookie in iter(self):
275
+ if cookie.domain not in domains:
276
+ domains.append(cookie.domain)
277
+ return domains
278
+
279
+ def list_paths(self):
280
+ """Utility method to list all the paths in the jar."""
281
+ paths = []
282
+ for cookie in iter(self):
283
+ if cookie.path not in paths:
284
+ paths.append(cookie.path)
285
+ return paths
286
+
287
+ def multiple_domains(self):
288
+ """Returns True if there are multiple domains in the jar.
289
+ Returns False otherwise.
290
+
291
+ :rtype: bool
292
+ """
293
+ domains = []
294
+ for cookie in iter(self):
295
+ if cookie.domain is not None and cookie.domain in domains:
296
+ return True
297
+ domains.append(cookie.domain)
298
+ return False # there is only one domain in jar
299
+
300
+ def get_dict(self, domain=None, path=None):
301
+ """Takes as an argument an optional domain and path and returns a plain
302
+ old Python dict of name-value pairs of cookies that meet the
303
+ requirements.
304
+
305
+ :rtype: dict
306
+ """
307
+ dictionary = {}
308
+ for cookie in iter(self):
309
+ if (
310
+ (domain is None or cookie.domain == domain) and
311
+ (path is None or cookie.path == path)
312
+ ):
313
+ dictionary[cookie.name] = cookie.value
314
+ return dictionary
315
+
316
+ def __contains__(self, name):
317
+ try:
318
+ return super(RequestsCookieJar, self).__contains__(name)
319
+ except CookieConflictError:
320
+ return True
321
+
322
+ def __getitem__(self, name):
323
+ """Dict-like __getitem__() for compatibility with client code. Throws
324
+ exception if there are more than one cookie with name. In that case,
325
+ use the more explicit get() method instead.
326
+
327
+ .. warning:: operation is O(n), not O(1).
328
+ """
329
+ return self._find_no_duplicates(name)
330
+
331
+ def __setitem__(self, name, value):
332
+ """Dict-like __setitem__ for compatibility with client code. Throws
333
+ exception if there is already a cookie of that name in the jar. In that
334
+ case, use the more explicit set() method instead.
335
+ """
336
+ self.set(name, value)
337
+
338
+ def __delitem__(self, name):
339
+ """Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s
340
+ ``remove_cookie_by_name()``.
341
+ """
342
+ remove_cookie_by_name(self, name)
343
+
344
+ def set_cookie(self, cookie, *args, **kwargs):
345
+ if hasattr(cookie.value, 'startswith') and cookie.value.startswith('"') and cookie.value.endswith('"'):
346
+ cookie.value = cookie.value.replace('\\"', '')
347
+ return super(RequestsCookieJar, self).set_cookie(cookie, *args, **kwargs)
348
+
349
+ def update(self, other):
350
+ """Updates this jar with cookies from another CookieJar or dict-like"""
351
+ if isinstance(other, cookielib.CookieJar):
352
+ for cookie in other:
353
+ self.set_cookie(copy.copy(cookie))
354
+ else:
355
+ super(RequestsCookieJar, self).update(other)
356
+
357
+ def _find(self, name, domain=None, path=None):
358
+ """Requests uses this method internally to get cookie values.
359
+
360
+ If there are conflicting cookies, _find arbitrarily chooses one.
361
+ See _find_no_duplicates if you want an exception thrown if there are
362
+ conflicting cookies.
363
+
364
+ :param name: a string containing name of cookie
365
+ :param domain: (optional) string containing domain of cookie
366
+ :param path: (optional) string containing path of cookie
367
+ :return: cookie.value
368
+ """
369
+ for cookie in iter(self):
370
+ if cookie.name == name:
371
+ if domain is None or cookie.domain == domain:
372
+ if path is None or cookie.path == path:
373
+ return cookie.value
374
+
375
+ raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
376
+
377
+ def _find_no_duplicates(self, name, domain=None, path=None):
378
+ """Both ``__get_item__`` and ``get`` call this function: it's never
379
+ used elsewhere in Requests.
380
+
381
+ :param name: a string containing name of cookie
382
+ :param domain: (optional) string containing domain of cookie
383
+ :param path: (optional) string containing path of cookie
384
+ :raises KeyError: if cookie is not found
385
+ :raises CookieConflictError: if there are multiple cookies
386
+ that match name and optionally domain and path
387
+ :return: cookie.value
388
+ """
389
+ toReturn = None
390
+ for cookie in iter(self):
391
+ if cookie.name == name:
392
+ if domain is None or cookie.domain == domain:
393
+ if path is None or cookie.path == path:
394
+ if toReturn is not None: # if there are multiple cookies that meet passed in criteria
395
+ raise CookieConflictError('There are multiple cookies with name, %r' % (name))
396
+ toReturn = cookie.value # we will eventually return this as long as no cookie conflict
397
+
398
+ if toReturn:
399
+ return toReturn
400
+ raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
401
+
402
+ def __getstate__(self):
403
+ """Unlike a normal CookieJar, this class is pickleable."""
404
+ state = self.__dict__.copy()
405
+ # remove the unpickleable RLock object
406
+ state.pop('_cookies_lock')
407
+ return state
408
+
409
+ def __setstate__(self, state):
410
+ """Unlike a normal CookieJar, this class is pickleable."""
411
+ self.__dict__.update(state)
412
+ if '_cookies_lock' not in self.__dict__:
413
+ self._cookies_lock = threading.RLock()
414
+
415
+ def copy(self):
416
+ """Return a copy of this RequestsCookieJar."""
417
+ new_cj = RequestsCookieJar()
418
+ new_cj.update(self)
419
+ return new_cj
420
+
421
+
422
+ def _copy_cookie_jar(jar):
423
+ if jar is None:
424
+ return None
425
+
426
+ if hasattr(jar, 'copy'):
427
+ # We're dealing with an instance of RequestsCookieJar
428
+ return jar.copy()
429
+ # We're dealing with a generic CookieJar instance
430
+ new_jar = copy.copy(jar)
431
+ new_jar.clear()
432
+ for cookie in jar:
433
+ new_jar.set_cookie(copy.copy(cookie))
434
+ return new_jar
435
+
436
+
437
+ def create_cookie(name, value, **kwargs):
438
+ """Make a cookie from underspecified parameters.
439
+
440
+ By default, the pair of `name` and `value` will be set for the domain ''
441
+ and sent on every request (this is sometimes called a "supercookie").
442
+ """
443
+ result = dict(
444
+ version=0,
445
+ name=name,
446
+ value=value,
447
+ port=None,
448
+ domain='',
449
+ path='/',
450
+ secure=False,
451
+ expires=None,
452
+ discard=True,
453
+ comment=None,
454
+ comment_url=None,
455
+ rest={'HttpOnly': None},
456
+ rfc2109=False,)
457
+
458
+ badargs = set(kwargs) - set(result)
459
+ if badargs:
460
+ err = 'create_cookie() got unexpected keyword arguments: %s'
461
+ raise TypeError(err % list(badargs))
462
+
463
+ result.update(kwargs)
464
+ result['port_specified'] = bool(result['port'])
465
+ result['domain_specified'] = bool(result['domain'])
466
+ result['domain_initial_dot'] = result['domain'].startswith('.')
467
+ result['path_specified'] = bool(result['path'])
468
+
469
+ return cookielib.Cookie(**result)
470
+
471
+
472
+ def morsel_to_cookie(morsel):
473
+ """Convert a Morsel object into a Cookie containing the one k/v pair."""
474
+
475
+ expires = None
476
+ if morsel['max-age']:
477
+ try:
478
+ expires = int(time.time() + int(morsel['max-age']))
479
+ except ValueError:
480
+ raise TypeError('max-age: %s must be integer' % morsel['max-age'])
481
+ elif morsel['expires']:
482
+ time_template = '%a, %d-%b-%Y %H:%M:%S GMT'
483
+ expires = calendar.timegm(
484
+ time.strptime(morsel['expires'], time_template)
485
+ )
486
+ return create_cookie(
487
+ comment=morsel['comment'],
488
+ comment_url=bool(morsel['comment']),
489
+ discard=False,
490
+ domain=morsel['domain'],
491
+ expires=expires,
492
+ name=morsel.key,
493
+ path=morsel['path'],
494
+ port=None,
495
+ rest={'HttpOnly': morsel['httponly']},
496
+ rfc2109=False,
497
+ secure=bool(morsel['secure']),
498
+ value=morsel.value,
499
+ version=morsel['version'] or 0,
500
+ )
501
+
502
+
503
+ def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
504
+ """Returns a CookieJar from a key/value dictionary.
505
+
506
+ :param cookie_dict: Dict of key/values to insert into CookieJar.
507
+ :param cookiejar: (optional) A cookiejar to add the cookies to.
508
+ :param overwrite: (optional) If False, will not replace cookies
509
+ already in the jar with new ones.
510
+ """
511
+ if cookiejar is None:
512
+ cookiejar = RequestsCookieJar()
513
+
514
+ if cookie_dict is not None:
515
+ names_from_jar = [cookie.name for cookie in cookiejar]
516
+ for name in cookie_dict:
517
+ if overwrite or (name not in names_from_jar):
518
+ cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
519
+
520
+ return cookiejar
521
+
522
+
523
+ def merge_cookies(cookiejar, cookies):
524
+ """Add cookies to cookiejar and returns a merged CookieJar.
525
+
526
+ :param cookiejar: CookieJar object to add the cookies to.
527
+ :param cookies: Dictionary or CookieJar object to be added.
528
+ """
529
+ if not isinstance(cookiejar, cookielib.CookieJar):
530
+ raise ValueError('You can only merge into CookieJar')
531
+
532
+ if isinstance(cookies, dict):
533
+ cookiejar = cookiejar_from_dict(
534
+ cookies, cookiejar=cookiejar, overwrite=False)
535
+ elif isinstance(cookies, cookielib.CookieJar):
536
+ try:
537
+ cookiejar.update(cookies)
538
+ except AttributeError:
539
+ for cookie_in_jar in cookies:
540
+ cookiejar.set_cookie(cookie_in_jar)
541
+
542
+ return cookiejar