rigid 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (364) hide show
  1. checksums.yaml +7 -0
  2. data/bin/rigid +4 -0
  3. data/rigid +16 -0
  4. data/vendor/PyYAML-3.12.dist-info/DESCRIPTION.rst +12 -0
  5. data/vendor/PyYAML-3.12.dist-info/INSTALLER +1 -0
  6. data/vendor/PyYAML-3.12.dist-info/METADATA +35 -0
  7. data/vendor/PyYAML-3.12.dist-info/RECORD +42 -0
  8. data/vendor/PyYAML-3.12.dist-info/WHEEL +5 -0
  9. data/vendor/PyYAML-3.12.dist-info/metadata.json +1 -0
  10. data/vendor/PyYAML-3.12.dist-info/top_level.txt +2 -0
  11. data/vendor/_yaml.so +0 -0
  12. data/vendor/click/__init__.py +98 -0
  13. data/vendor/click/__init__.pyc +0 -0
  14. data/vendor/click/_bashcomplete.py +83 -0
  15. data/vendor/click/_bashcomplete.pyc +0 -0
  16. data/vendor/click/_compat.py +642 -0
  17. data/vendor/click/_compat.pyc +0 -0
  18. data/vendor/click/_termui_impl.py +547 -0
  19. data/vendor/click/_termui_impl.pyc +0 -0
  20. data/vendor/click/_textwrap.py +38 -0
  21. data/vendor/click/_textwrap.pyc +0 -0
  22. data/vendor/click/_unicodefun.py +119 -0
  23. data/vendor/click/_unicodefun.pyc +0 -0
  24. data/vendor/click/_winconsole.py +273 -0
  25. data/vendor/click/_winconsole.pyc +0 -0
  26. data/vendor/click/core.py +1738 -0
  27. data/vendor/click/core.pyc +0 -0
  28. data/vendor/click/decorators.py +304 -0
  29. data/vendor/click/decorators.pyc +0 -0
  30. data/vendor/click/exceptions.py +201 -0
  31. data/vendor/click/exceptions.pyc +0 -0
  32. data/vendor/click/formatting.py +256 -0
  33. data/vendor/click/formatting.pyc +0 -0
  34. data/vendor/click/globals.py +48 -0
  35. data/vendor/click/globals.pyc +0 -0
  36. data/vendor/click/parser.py +426 -0
  37. data/vendor/click/parser.pyc +0 -0
  38. data/vendor/click/termui.py +539 -0
  39. data/vendor/click/termui.pyc +0 -0
  40. data/vendor/click/testing.py +322 -0
  41. data/vendor/click/testing.pyc +0 -0
  42. data/vendor/click/types.py +550 -0
  43. data/vendor/click/types.pyc +0 -0
  44. data/vendor/click/utils.py +415 -0
  45. data/vendor/click/utils.pyc +0 -0
  46. data/vendor/click-6.6.dist-info/DESCRIPTION.rst +3 -0
  47. data/vendor/click-6.6.dist-info/INSTALLER +1 -0
  48. data/vendor/click-6.6.dist-info/METADATA +16 -0
  49. data/vendor/click-6.6.dist-info/RECORD +41 -0
  50. data/vendor/click-6.6.dist-info/WHEEL +6 -0
  51. data/vendor/click-6.6.dist-info/metadata.json +1 -0
  52. data/vendor/click-6.6.dist-info/top_level.txt +1 -0
  53. data/vendor/easy_install.py +5 -0
  54. data/vendor/easy_install.pyc +0 -0
  55. data/vendor/pip-9.0.1.dist-info/DESCRIPTION.rst +39 -0
  56. data/vendor/pip-9.0.1.dist-info/INSTALLER +1 -0
  57. data/vendor/pip-9.0.1.dist-info/METADATA +69 -0
  58. data/vendor/pip-9.0.1.dist-info/RECORD +501 -0
  59. data/vendor/pip-9.0.1.dist-info/WHEEL +6 -0
  60. data/vendor/pip-9.0.1.dist-info/entry_points.txt +5 -0
  61. data/vendor/pip-9.0.1.dist-info/metadata.json +1 -0
  62. data/vendor/pip-9.0.1.dist-info/top_level.txt +1 -0
  63. data/vendor/pkg_resources/__init__.py +3051 -0
  64. data/vendor/pkg_resources/__init__.pyc +0 -0
  65. data/vendor/pkg_resources/_vendor/__init__.py +0 -0
  66. data/vendor/pkg_resources/_vendor/__init__.pyc +0 -0
  67. data/vendor/pkg_resources/_vendor/appdirs.py +552 -0
  68. data/vendor/pkg_resources/_vendor/appdirs.pyc +0 -0
  69. data/vendor/pkg_resources/_vendor/packaging/__about__.py +21 -0
  70. data/vendor/pkg_resources/_vendor/packaging/__about__.pyc +0 -0
  71. data/vendor/pkg_resources/_vendor/packaging/__init__.py +14 -0
  72. data/vendor/pkg_resources/_vendor/packaging/__init__.pyc +0 -0
  73. data/vendor/pkg_resources/_vendor/packaging/_compat.py +30 -0
  74. data/vendor/pkg_resources/_vendor/packaging/_compat.pyc +0 -0
  75. data/vendor/pkg_resources/_vendor/packaging/_structures.py +68 -0
  76. data/vendor/pkg_resources/_vendor/packaging/_structures.pyc +0 -0
  77. data/vendor/pkg_resources/_vendor/packaging/markers.py +287 -0
  78. data/vendor/pkg_resources/_vendor/packaging/markers.pyc +0 -0
  79. data/vendor/pkg_resources/_vendor/packaging/requirements.py +127 -0
  80. data/vendor/pkg_resources/_vendor/packaging/requirements.pyc +0 -0
  81. data/vendor/pkg_resources/_vendor/packaging/specifiers.py +774 -0
  82. data/vendor/pkg_resources/_vendor/packaging/specifiers.pyc +0 -0
  83. data/vendor/pkg_resources/_vendor/packaging/utils.py +14 -0
  84. data/vendor/pkg_resources/_vendor/packaging/utils.pyc +0 -0
  85. data/vendor/pkg_resources/_vendor/packaging/version.py +393 -0
  86. data/vendor/pkg_resources/_vendor/packaging/version.pyc +0 -0
  87. data/vendor/pkg_resources/_vendor/pyparsing.py +5696 -0
  88. data/vendor/pkg_resources/_vendor/pyparsing.pyc +0 -0
  89. data/vendor/pkg_resources/_vendor/six.py +868 -0
  90. data/vendor/pkg_resources/_vendor/six.pyc +0 -0
  91. data/vendor/pkg_resources/extern/__init__.py +73 -0
  92. data/vendor/pkg_resources/extern/__init__.pyc +0 -0
  93. data/vendor/requests/__init__.py +86 -0
  94. data/vendor/requests/__init__.pyc +0 -0
  95. data/vendor/requests/adapters.py +503 -0
  96. data/vendor/requests/adapters.pyc +0 -0
  97. data/vendor/requests/api.py +148 -0
  98. data/vendor/requests/api.pyc +0 -0
  99. data/vendor/requests/auth.py +252 -0
  100. data/vendor/requests/auth.pyc +0 -0
  101. data/vendor/requests/cacert.pem +5616 -0
  102. data/vendor/requests/certs.py +25 -0
  103. data/vendor/requests/certs.pyc +0 -0
  104. data/vendor/requests/compat.py +66 -0
  105. data/vendor/requests/compat.pyc +0 -0
  106. data/vendor/requests/cookies.py +540 -0
  107. data/vendor/requests/cookies.pyc +0 -0
  108. data/vendor/requests/exceptions.py +114 -0
  109. data/vendor/requests/exceptions.pyc +0 -0
  110. data/vendor/requests/hooks.py +34 -0
  111. data/vendor/requests/hooks.pyc +0 -0
  112. data/vendor/requests/models.py +873 -0
  113. data/vendor/requests/models.pyc +0 -0
  114. data/vendor/requests/packages/__init__.py +36 -0
  115. data/vendor/requests/packages/__init__.pyc +0 -0
  116. data/vendor/requests/packages/chardet/__init__.py +32 -0
  117. data/vendor/requests/packages/chardet/__init__.pyc +0 -0
  118. data/vendor/requests/packages/chardet/big5freq.py +925 -0
  119. data/vendor/requests/packages/chardet/big5freq.pyc +0 -0
  120. data/vendor/requests/packages/chardet/big5prober.py +42 -0
  121. data/vendor/requests/packages/chardet/big5prober.pyc +0 -0
  122. data/vendor/requests/packages/chardet/chardetect.py +80 -0
  123. data/vendor/requests/packages/chardet/chardetect.pyc +0 -0
  124. data/vendor/requests/packages/chardet/chardistribution.py +231 -0
  125. data/vendor/requests/packages/chardet/chardistribution.pyc +0 -0
  126. data/vendor/requests/packages/chardet/charsetgroupprober.py +106 -0
  127. data/vendor/requests/packages/chardet/charsetgroupprober.pyc +0 -0
  128. data/vendor/requests/packages/chardet/charsetprober.py +62 -0
  129. data/vendor/requests/packages/chardet/charsetprober.pyc +0 -0
  130. data/vendor/requests/packages/chardet/codingstatemachine.py +61 -0
  131. data/vendor/requests/packages/chardet/codingstatemachine.pyc +0 -0
  132. data/vendor/requests/packages/chardet/compat.py +34 -0
  133. data/vendor/requests/packages/chardet/compat.pyc +0 -0
  134. data/vendor/requests/packages/chardet/constants.py +39 -0
  135. data/vendor/requests/packages/chardet/constants.pyc +0 -0
  136. data/vendor/requests/packages/chardet/cp949prober.py +44 -0
  137. data/vendor/requests/packages/chardet/cp949prober.pyc +0 -0
  138. data/vendor/requests/packages/chardet/escprober.py +86 -0
  139. data/vendor/requests/packages/chardet/escprober.pyc +0 -0
  140. data/vendor/requests/packages/chardet/escsm.py +242 -0
  141. data/vendor/requests/packages/chardet/escsm.pyc +0 -0
  142. data/vendor/requests/packages/chardet/eucjpprober.py +90 -0
  143. data/vendor/requests/packages/chardet/eucjpprober.pyc +0 -0
  144. data/vendor/requests/packages/chardet/euckrfreq.py +596 -0
  145. data/vendor/requests/packages/chardet/euckrfreq.pyc +0 -0
  146. data/vendor/requests/packages/chardet/euckrprober.py +42 -0
  147. data/vendor/requests/packages/chardet/euckrprober.pyc +0 -0
  148. data/vendor/requests/packages/chardet/euctwfreq.py +428 -0
  149. data/vendor/requests/packages/chardet/euctwfreq.pyc +0 -0
  150. data/vendor/requests/packages/chardet/euctwprober.py +41 -0
  151. data/vendor/requests/packages/chardet/euctwprober.pyc +0 -0
  152. data/vendor/requests/packages/chardet/gb2312freq.py +472 -0
  153. data/vendor/requests/packages/chardet/gb2312freq.pyc +0 -0
  154. data/vendor/requests/packages/chardet/gb2312prober.py +41 -0
  155. data/vendor/requests/packages/chardet/gb2312prober.pyc +0 -0
  156. data/vendor/requests/packages/chardet/hebrewprober.py +283 -0
  157. data/vendor/requests/packages/chardet/hebrewprober.pyc +0 -0
  158. data/vendor/requests/packages/chardet/jisfreq.py +569 -0
  159. data/vendor/requests/packages/chardet/jisfreq.pyc +0 -0
  160. data/vendor/requests/packages/chardet/jpcntx.py +227 -0
  161. data/vendor/requests/packages/chardet/jpcntx.pyc +0 -0
  162. data/vendor/requests/packages/chardet/langbulgarianmodel.py +229 -0
  163. data/vendor/requests/packages/chardet/langbulgarianmodel.pyc +0 -0
  164. data/vendor/requests/packages/chardet/langcyrillicmodel.py +329 -0
  165. data/vendor/requests/packages/chardet/langcyrillicmodel.pyc +0 -0
  166. data/vendor/requests/packages/chardet/langgreekmodel.py +225 -0
  167. data/vendor/requests/packages/chardet/langgreekmodel.pyc +0 -0
  168. data/vendor/requests/packages/chardet/langhebrewmodel.py +201 -0
  169. data/vendor/requests/packages/chardet/langhebrewmodel.pyc +0 -0
  170. data/vendor/requests/packages/chardet/langhungarianmodel.py +225 -0
  171. data/vendor/requests/packages/chardet/langhungarianmodel.pyc +0 -0
  172. data/vendor/requests/packages/chardet/langthaimodel.py +200 -0
  173. data/vendor/requests/packages/chardet/langthaimodel.pyc +0 -0
  174. data/vendor/requests/packages/chardet/latin1prober.py +139 -0
  175. data/vendor/requests/packages/chardet/latin1prober.pyc +0 -0
  176. data/vendor/requests/packages/chardet/mbcharsetprober.py +86 -0
  177. data/vendor/requests/packages/chardet/mbcharsetprober.pyc +0 -0
  178. data/vendor/requests/packages/chardet/mbcsgroupprober.py +54 -0
  179. data/vendor/requests/packages/chardet/mbcsgroupprober.pyc +0 -0
  180. data/vendor/requests/packages/chardet/mbcssm.py +572 -0
  181. data/vendor/requests/packages/chardet/mbcssm.pyc +0 -0
  182. data/vendor/requests/packages/chardet/sbcharsetprober.py +120 -0
  183. data/vendor/requests/packages/chardet/sbcharsetprober.pyc +0 -0
  184. data/vendor/requests/packages/chardet/sbcsgroupprober.py +69 -0
  185. data/vendor/requests/packages/chardet/sbcsgroupprober.pyc +0 -0
  186. data/vendor/requests/packages/chardet/sjisprober.py +91 -0
  187. data/vendor/requests/packages/chardet/sjisprober.pyc +0 -0
  188. data/vendor/requests/packages/chardet/universaldetector.py +170 -0
  189. data/vendor/requests/packages/chardet/universaldetector.pyc +0 -0
  190. data/vendor/requests/packages/chardet/utf8prober.py +76 -0
  191. data/vendor/requests/packages/chardet/utf8prober.pyc +0 -0
  192. data/vendor/requests/packages/urllib3/__init__.py +96 -0
  193. data/vendor/requests/packages/urllib3/__init__.pyc +0 -0
  194. data/vendor/requests/packages/urllib3/_collections.py +324 -0
  195. data/vendor/requests/packages/urllib3/_collections.pyc +0 -0
  196. data/vendor/requests/packages/urllib3/connection.py +330 -0
  197. data/vendor/requests/packages/urllib3/connection.pyc +0 -0
  198. data/vendor/requests/packages/urllib3/connectionpool.py +866 -0
  199. data/vendor/requests/packages/urllib3/connectionpool.pyc +0 -0
  200. data/vendor/requests/packages/urllib3/contrib/__init__.py +0 -0
  201. data/vendor/requests/packages/urllib3/contrib/__init__.pyc +0 -0
  202. data/vendor/requests/packages/urllib3/contrib/appengine.py +231 -0
  203. data/vendor/requests/packages/urllib3/contrib/appengine.pyc +0 -0
  204. data/vendor/requests/packages/urllib3/contrib/ntlmpool.py +115 -0
  205. data/vendor/requests/packages/urllib3/contrib/ntlmpool.pyc +0 -0
  206. data/vendor/requests/packages/urllib3/contrib/pyopenssl.py +358 -0
  207. data/vendor/requests/packages/urllib3/contrib/pyopenssl.pyc +0 -0
  208. data/vendor/requests/packages/urllib3/contrib/socks.py +172 -0
  209. data/vendor/requests/packages/urllib3/contrib/socks.pyc +0 -0
  210. data/vendor/requests/packages/urllib3/exceptions.py +209 -0
  211. data/vendor/requests/packages/urllib3/exceptions.pyc +0 -0
  212. data/vendor/requests/packages/urllib3/fields.py +178 -0
  213. data/vendor/requests/packages/urllib3/fields.pyc +0 -0
  214. data/vendor/requests/packages/urllib3/filepost.py +94 -0
  215. data/vendor/requests/packages/urllib3/filepost.pyc +0 -0
  216. data/vendor/requests/packages/urllib3/packages/__init__.py +5 -0
  217. data/vendor/requests/packages/urllib3/packages/__init__.pyc +0 -0
  218. data/vendor/requests/packages/urllib3/packages/ordered_dict.py +259 -0
  219. data/vendor/requests/packages/urllib3/packages/ordered_dict.pyc +0 -0
  220. data/vendor/requests/packages/urllib3/packages/six.py +868 -0
  221. data/vendor/requests/packages/urllib3/packages/six.pyc +0 -0
  222. data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py +13 -0
  223. data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc +0 -0
  224. data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py +105 -0
  225. data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyc +0 -0
  226. data/vendor/requests/packages/urllib3/poolmanager.py +367 -0
  227. data/vendor/requests/packages/urllib3/poolmanager.pyc +0 -0
  228. data/vendor/requests/packages/urllib3/request.py +151 -0
  229. data/vendor/requests/packages/urllib3/request.pyc +0 -0
  230. data/vendor/requests/packages/urllib3/response.py +530 -0
  231. data/vendor/requests/packages/urllib3/response.pyc +0 -0
  232. data/vendor/requests/packages/urllib3/util/__init__.py +46 -0
  233. data/vendor/requests/packages/urllib3/util/__init__.pyc +0 -0
  234. data/vendor/requests/packages/urllib3/util/connection.py +144 -0
  235. data/vendor/requests/packages/urllib3/util/connection.pyc +0 -0
  236. data/vendor/requests/packages/urllib3/util/request.py +72 -0
  237. data/vendor/requests/packages/urllib3/util/request.pyc +0 -0
  238. data/vendor/requests/packages/urllib3/util/response.py +74 -0
  239. data/vendor/requests/packages/urllib3/util/response.pyc +0 -0
  240. data/vendor/requests/packages/urllib3/util/retry.py +300 -0
  241. data/vendor/requests/packages/urllib3/util/retry.pyc +0 -0
  242. data/vendor/requests/packages/urllib3/util/ssl_.py +320 -0
  243. data/vendor/requests/packages/urllib3/util/ssl_.pyc +0 -0
  244. data/vendor/requests/packages/urllib3/util/timeout.py +242 -0
  245. data/vendor/requests/packages/urllib3/util/timeout.pyc +0 -0
  246. data/vendor/requests/packages/urllib3/util/url.py +217 -0
  247. data/vendor/requests/packages/urllib3/util/url.pyc +0 -0
  248. data/vendor/requests/sessions.py +712 -0
  249. data/vendor/requests/sessions.pyc +0 -0
  250. data/vendor/requests/status_codes.py +91 -0
  251. data/vendor/requests/status_codes.pyc +0 -0
  252. data/vendor/requests/structures.py +105 -0
  253. data/vendor/requests/structures.pyc +0 -0
  254. data/vendor/requests/utils.py +817 -0
  255. data/vendor/requests/utils.pyc +0 -0
  256. data/vendor/requests-2.11.1.dist-info/DESCRIPTION.rst +1294 -0
  257. data/vendor/requests-2.11.1.dist-info/INSTALLER +1 -0
  258. data/vendor/requests-2.11.1.dist-info/METADATA +1323 -0
  259. data/vendor/requests-2.11.1.dist-info/RECORD +170 -0
  260. data/vendor/requests-2.11.1.dist-info/WHEEL +6 -0
  261. data/vendor/requests-2.11.1.dist-info/metadata.json +1 -0
  262. data/vendor/requests-2.11.1.dist-info/top_level.txt +1 -0
  263. data/vendor/rigid/__init__.py +1 -0
  264. data/vendor/rigid/__init__.pyc +0 -0
  265. data/vendor/rigid/api.py +129 -0
  266. data/vendor/rigid/api.pyc +0 -0
  267. data/vendor/rigid/commands/__init__.py +260 -0
  268. data/vendor/rigid/commands/__init__.pyc +0 -0
  269. data/vendor/rigid/commands/deploy.py +0 -0
  270. data/vendor/rigid/commands/deploy.pyc +0 -0
  271. data/vendor/rigid/deploy.py +70 -0
  272. data/vendor/rigid/deploy.pyc +0 -0
  273. data/vendor/rigid/file_scanner.py +63 -0
  274. data/vendor/rigid/file_scanner.pyc +0 -0
  275. data/vendor/rigid/utils.py +17 -0
  276. data/vendor/rigid/utils.pyc +0 -0
  277. data/vendor/rigid-0.2.0.dist-info/DESCRIPTION.rst +3 -0
  278. data/vendor/rigid-0.2.0.dist-info/INSTALLER +1 -0
  279. data/vendor/rigid-0.2.0.dist-info/METADATA +23 -0
  280. data/vendor/rigid-0.2.0.dist-info/RECORD +49 -0
  281. data/vendor/rigid-0.2.0.dist-info/WHEEL +5 -0
  282. data/vendor/rigid-0.2.0.dist-info/entry_points.txt +3 -0
  283. data/vendor/rigid-0.2.0.dist-info/metadata.json +1 -0
  284. data/vendor/rigid-0.2.0.dist-info/top_level.txt +2 -0
  285. data/vendor/setuptools-28.8.0.dist-info/DESCRIPTION.rst +243 -0
  286. data/vendor/setuptools-28.8.0.dist-info/INSTALLER +1 -0
  287. data/vendor/setuptools-28.8.0.dist-info/METADATA +272 -0
  288. data/vendor/setuptools-28.8.0.dist-info/RECORD +143 -0
  289. data/vendor/setuptools-28.8.0.dist-info/WHEEL +6 -0
  290. data/vendor/setuptools-28.8.0.dist-info/dependency_links.txt +2 -0
  291. data/vendor/setuptools-28.8.0.dist-info/entry_points.txt +63 -0
  292. data/vendor/setuptools-28.8.0.dist-info/metadata.json +1 -0
  293. data/vendor/setuptools-28.8.0.dist-info/top_level.txt +3 -0
  294. data/vendor/setuptools-28.8.0.dist-info/zip-safe +1 -0
  295. data/vendor/tests/__init__.py +0 -0
  296. data/vendor/tests/__init__.pyc +0 -0
  297. data/vendor/tests/integration/__init__.py +0 -0
  298. data/vendor/tests/integration/__init__.pyc +0 -0
  299. data/vendor/tests/integration/test_app.py +63 -0
  300. data/vendor/tests/integration/test_app.pyc +0 -0
  301. data/vendor/tests/integration/test_apps.py +27 -0
  302. data/vendor/tests/integration/test_apps.pyc +0 -0
  303. data/vendor/tests/integration/test_deploy.py +128 -0
  304. data/vendor/tests/integration/test_deploy.pyc +0 -0
  305. data/vendor/tests/integration/test_domains.py +35 -0
  306. data/vendor/tests/integration/test_domains.pyc +0 -0
  307. data/vendor/tests/integration/test_login.py +37 -0
  308. data/vendor/tests/integration/test_login.pyc +0 -0
  309. data/vendor/tests/integration/test_promote.py +24 -0
  310. data/vendor/tests/integration/test_promote.pyc +0 -0
  311. data/vendor/tests/integration/test_token.py +33 -0
  312. data/vendor/tests/integration/test_token.pyc +0 -0
  313. data/vendor/tests/integration/test_whoami.py +24 -0
  314. data/vendor/tests/integration/test_whoami.pyc +0 -0
  315. data/vendor/tests/test_deploy.py +33 -0
  316. data/vendor/tests/test_deploy.pyc +0 -0
  317. data/vendor/tests/test_file_scanner.py +89 -0
  318. data/vendor/tests/test_file_scanner.pyc +0 -0
  319. data/vendor/tests/utils.py +78 -0
  320. data/vendor/tests/utils.pyc +0 -0
  321. data/vendor/wheel-0.30.0a0.dist-info/DESCRIPTION.rst +325 -0
  322. data/vendor/wheel-0.30.0a0.dist-info/INSTALLER +1 -0
  323. data/vendor/wheel-0.30.0a0.dist-info/LICENSE.txt +22 -0
  324. data/vendor/wheel-0.30.0a0.dist-info/METADATA +357 -0
  325. data/vendor/wheel-0.30.0a0.dist-info/RECORD +86 -0
  326. data/vendor/wheel-0.30.0a0.dist-info/WHEEL +6 -0
  327. data/vendor/wheel-0.30.0a0.dist-info/entry_points.txt +6 -0
  328. data/vendor/wheel-0.30.0a0.dist-info/metadata.json +1 -0
  329. data/vendor/wheel-0.30.0a0.dist-info/top_level.txt +1 -0
  330. data/vendor/yaml/__init__.py +315 -0
  331. data/vendor/yaml/__init__.pyc +0 -0
  332. data/vendor/yaml/composer.py +139 -0
  333. data/vendor/yaml/composer.pyc +0 -0
  334. data/vendor/yaml/constructor.py +675 -0
  335. data/vendor/yaml/constructor.pyc +0 -0
  336. data/vendor/yaml/cyaml.py +85 -0
  337. data/vendor/yaml/cyaml.pyc +0 -0
  338. data/vendor/yaml/dumper.py +62 -0
  339. data/vendor/yaml/dumper.pyc +0 -0
  340. data/vendor/yaml/emitter.py +1140 -0
  341. data/vendor/yaml/emitter.pyc +0 -0
  342. data/vendor/yaml/error.py +75 -0
  343. data/vendor/yaml/error.pyc +0 -0
  344. data/vendor/yaml/events.py +86 -0
  345. data/vendor/yaml/events.pyc +0 -0
  346. data/vendor/yaml/loader.py +40 -0
  347. data/vendor/yaml/loader.pyc +0 -0
  348. data/vendor/yaml/nodes.py +49 -0
  349. data/vendor/yaml/nodes.pyc +0 -0
  350. data/vendor/yaml/parser.py +589 -0
  351. data/vendor/yaml/parser.pyc +0 -0
  352. data/vendor/yaml/reader.py +190 -0
  353. data/vendor/yaml/reader.pyc +0 -0
  354. data/vendor/yaml/representer.py +486 -0
  355. data/vendor/yaml/representer.pyc +0 -0
  356. data/vendor/yaml/resolver.py +227 -0
  357. data/vendor/yaml/resolver.pyc +0 -0
  358. data/vendor/yaml/scanner.py +1453 -0
  359. data/vendor/yaml/scanner.pyc +0 -0
  360. data/vendor/yaml/serializer.py +111 -0
  361. data/vendor/yaml/serializer.pyc +0 -0
  362. data/vendor/yaml/tokens.py +104 -0
  363. data/vendor/yaml/tokens.pyc +0 -0
  364. metadata +407 -0
@@ -0,0 +1,712 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ requests.session
5
+ ~~~~~~~~~~~~~~~~
6
+
7
+ This module provides a Session object to manage and persist settings across
8
+ requests (cookies, auth, proxies).
9
+ """
10
+ import os
11
+ from collections import Mapping
12
+ from datetime import datetime
13
+
14
+ from .auth import _basic_auth_str
15
+ from .compat import cookielib, OrderedDict, urljoin, urlparse
16
+ from .cookies import (
17
+ cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies)
18
+ from .models import Request, PreparedRequest, DEFAULT_REDIRECT_LIMIT
19
+ from .hooks import default_hooks, dispatch_hook
20
+ from .utils import to_key_val_list, default_headers, to_native_string
21
+ from .exceptions import (
22
+ TooManyRedirects, InvalidSchema, ChunkedEncodingError, ContentDecodingError)
23
+ from .packages.urllib3._collections import RecentlyUsedContainer
24
+ from .structures import CaseInsensitiveDict
25
+
26
+ from .adapters import HTTPAdapter
27
+
28
+ from .utils import (
29
+ requote_uri, get_environ_proxies, get_netrc_auth, should_bypass_proxies,
30
+ get_auth_from_url
31
+ )
32
+
33
+ from .status_codes import codes
34
+
35
+ # formerly defined here, reexposed here for backward compatibility
36
+ from .models import REDIRECT_STATI
37
+
38
+ REDIRECT_CACHE_SIZE = 1000
39
+
40
+
41
+ def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
42
+ """Determines appropriate setting for a given request, taking into account
43
+ the explicit setting on that request, and the setting in the session. If a
44
+ setting is a dictionary, they will be merged together using `dict_class`
45
+ """
46
+
47
+ if session_setting is None:
48
+ return request_setting
49
+
50
+ if request_setting is None:
51
+ return session_setting
52
+
53
+ # Bypass if not a dictionary (e.g. verify)
54
+ if not (
55
+ isinstance(session_setting, Mapping) and
56
+ isinstance(request_setting, Mapping)
57
+ ):
58
+ return request_setting
59
+
60
+ merged_setting = dict_class(to_key_val_list(session_setting))
61
+ merged_setting.update(to_key_val_list(request_setting))
62
+
63
+ # Remove keys that are set to None. Extract keys first to avoid altering
64
+ # the dictionary during iteration.
65
+ none_keys = [k for (k, v) in merged_setting.items() if v is None]
66
+ for key in none_keys:
67
+ del merged_setting[key]
68
+
69
+ return merged_setting
70
+
71
+
72
+ def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
73
+ """Properly merges both requests and session hooks.
74
+
75
+ This is necessary because when request_hooks == {'response': []}, the
76
+ merge breaks Session hooks entirely.
77
+ """
78
+ if session_hooks is None or session_hooks.get('response') == []:
79
+ return request_hooks
80
+
81
+ if request_hooks is None or request_hooks.get('response') == []:
82
+ return session_hooks
83
+
84
+ return merge_setting(request_hooks, session_hooks, dict_class)
85
+
86
+
87
+ class SessionRedirectMixin(object):
88
+ def resolve_redirects(self, resp, req, stream=False, timeout=None,
89
+ verify=True, cert=None, proxies=None, **adapter_kwargs):
90
+ """Receives a Response. Returns a generator of Responses."""
91
+
92
+ i = 0
93
+ hist = [] # keep track of history
94
+
95
+ while resp.is_redirect:
96
+ prepared_request = req.copy()
97
+
98
+ if i > 0:
99
+ # Update history and keep track of redirects.
100
+ hist.append(resp)
101
+ new_hist = list(hist)
102
+ resp.history = new_hist
103
+
104
+ try:
105
+ resp.content # Consume socket so it can be released
106
+ except (ChunkedEncodingError, ContentDecodingError, RuntimeError):
107
+ resp.raw.read(decode_content=False)
108
+
109
+ if i >= self.max_redirects:
110
+ raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
111
+
112
+ # Release the connection back into the pool.
113
+ resp.close()
114
+
115
+ url = resp.headers['location']
116
+
117
+ # Handle redirection without scheme (see: RFC 1808 Section 4)
118
+ if url.startswith('//'):
119
+ parsed_rurl = urlparse(resp.url)
120
+ url = '%s:%s' % (parsed_rurl.scheme, url)
121
+
122
+ # The scheme should be lower case...
123
+ parsed = urlparse(url)
124
+ url = parsed.geturl()
125
+
126
+ # Facilitate relative 'location' headers, as allowed by RFC 7231.
127
+ # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
128
+ # Compliant with RFC3986, we percent encode the url.
129
+ if not parsed.netloc:
130
+ url = urljoin(resp.url, requote_uri(url))
131
+ else:
132
+ url = requote_uri(url)
133
+
134
+ prepared_request.url = to_native_string(url)
135
+ # Cache the url, unless it redirects to itself.
136
+ if resp.is_permanent_redirect and req.url != prepared_request.url:
137
+ self.redirect_cache[req.url] = prepared_request.url
138
+
139
+ self.rebuild_method(prepared_request, resp)
140
+
141
+ # https://github.com/kennethreitz/requests/issues/1084
142
+ if resp.status_code not in (codes.temporary_redirect, codes.permanent_redirect):
143
+ # https://github.com/kennethreitz/requests/issues/3490
144
+ purged_headers = ('Content-Length', 'Content-Type', 'Transfer-Encoding')
145
+ for header in purged_headers:
146
+ prepared_request.headers.pop(header, None)
147
+ prepared_request.body = None
148
+
149
+ headers = prepared_request.headers
150
+ try:
151
+ del headers['Cookie']
152
+ except KeyError:
153
+ pass
154
+
155
+ # Extract any cookies sent on the response to the cookiejar
156
+ # in the new request. Because we've mutated our copied prepared
157
+ # request, use the old one that we haven't yet touched.
158
+ extract_cookies_to_jar(prepared_request._cookies, req, resp.raw)
159
+ prepared_request._cookies.update(self.cookies)
160
+ prepared_request.prepare_cookies(prepared_request._cookies)
161
+
162
+ # Rebuild auth and proxy information.
163
+ proxies = self.rebuild_proxies(prepared_request, proxies)
164
+ self.rebuild_auth(prepared_request, resp)
165
+
166
+ # Override the original request.
167
+ req = prepared_request
168
+
169
+ resp = self.send(
170
+ req,
171
+ stream=stream,
172
+ timeout=timeout,
173
+ verify=verify,
174
+ cert=cert,
175
+ proxies=proxies,
176
+ allow_redirects=False,
177
+ **adapter_kwargs
178
+ )
179
+
180
+ extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)
181
+
182
+ i += 1
183
+ yield resp
184
+
185
+ def rebuild_auth(self, prepared_request, response):
186
+ """When being redirected we may want to strip authentication from the
187
+ request to avoid leaking credentials. This method intelligently removes
188
+ and reapplies authentication where possible to avoid credential loss.
189
+ """
190
+ headers = prepared_request.headers
191
+ url = prepared_request.url
192
+
193
+ if 'Authorization' in headers:
194
+ # If we get redirected to a new host, we should strip out any
195
+ # authentication headers.
196
+ original_parsed = urlparse(response.request.url)
197
+ redirect_parsed = urlparse(url)
198
+
199
+ if (original_parsed.hostname != redirect_parsed.hostname):
200
+ del headers['Authorization']
201
+
202
+ # .netrc might have more auth for us on our new host.
203
+ new_auth = get_netrc_auth(url) if self.trust_env else None
204
+ if new_auth is not None:
205
+ prepared_request.prepare_auth(new_auth)
206
+
207
+ return
208
+
209
+ def rebuild_proxies(self, prepared_request, proxies):
210
+ """This method re-evaluates the proxy configuration by considering the
211
+ environment variables. If we are redirected to a URL covered by
212
+ NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
213
+ proxy keys for this URL (in case they were stripped by a previous
214
+ redirect).
215
+
216
+ This method also replaces the Proxy-Authorization header where
217
+ necessary.
218
+
219
+ :rtype: dict
220
+ """
221
+ headers = prepared_request.headers
222
+ url = prepared_request.url
223
+ scheme = urlparse(url).scheme
224
+ new_proxies = proxies.copy() if proxies is not None else {}
225
+
226
+ if self.trust_env and not should_bypass_proxies(url):
227
+ environ_proxies = get_environ_proxies(url)
228
+
229
+ proxy = environ_proxies.get('all', environ_proxies.get(scheme))
230
+
231
+ if proxy:
232
+ new_proxies.setdefault(scheme, proxy)
233
+
234
+ if 'Proxy-Authorization' in headers:
235
+ del headers['Proxy-Authorization']
236
+
237
+ try:
238
+ username, password = get_auth_from_url(new_proxies[scheme])
239
+ except KeyError:
240
+ username, password = None, None
241
+
242
+ if username and password:
243
+ headers['Proxy-Authorization'] = _basic_auth_str(username, password)
244
+
245
+ return new_proxies
246
+
247
+ def rebuild_method(self, prepared_request, response):
248
+ """When being redirected we may want to change the method of the request
249
+ based on certain specs or browser behavior.
250
+ """
251
+ method = prepared_request.method
252
+
253
+ # http://tools.ietf.org/html/rfc7231#section-6.4.4
254
+ if response.status_code == codes.see_other and method != 'HEAD':
255
+ method = 'GET'
256
+
257
+ # Do what the browsers do, despite standards...
258
+ # First, turn 302s into GETs.
259
+ if response.status_code == codes.found and method != 'HEAD':
260
+ method = 'GET'
261
+
262
+ # Second, if a POST is responded to with a 301, turn it into a GET.
263
+ # This bizarre behaviour is explained in Issue 1704.
264
+ if response.status_code == codes.moved and method == 'POST':
265
+ method = 'GET'
266
+
267
+ prepared_request.method = method
268
+
269
+
270
+ class Session(SessionRedirectMixin):
271
+ """A Requests session.
272
+
273
+ Provides cookie persistence, connection-pooling, and configuration.
274
+
275
+ Basic Usage::
276
+
277
+ >>> import requests
278
+ >>> s = requests.Session()
279
+ >>> s.get('http://httpbin.org/get')
280
+ <Response [200]>
281
+
282
+ Or as a context manager::
283
+
284
+ >>> with requests.Session() as s:
285
+ >>> s.get('http://httpbin.org/get')
286
+ <Response [200]>
287
+ """
288
+
289
+ __attrs__ = [
290
+ 'headers', 'cookies', 'auth', 'proxies', 'hooks', 'params', 'verify',
291
+ 'cert', 'prefetch', 'adapters', 'stream', 'trust_env',
292
+ 'max_redirects',
293
+ ]
294
+
295
+ def __init__(self):
296
+
297
+ #: A case-insensitive dictionary of headers to be sent on each
298
+ #: :class:`Request <Request>` sent from this
299
+ #: :class:`Session <Session>`.
300
+ self.headers = default_headers()
301
+
302
+ #: Default Authentication tuple or object to attach to
303
+ #: :class:`Request <Request>`.
304
+ self.auth = None
305
+
306
+ #: Dictionary mapping protocol or protocol and host to the URL of the proxy
307
+ #: (e.g. {'http': 'foo.bar:3128', 'http://host.name': 'foo.bar:4012'}) to
308
+ #: be used on each :class:`Request <Request>`.
309
+ self.proxies = {}
310
+
311
+ #: Event-handling hooks.
312
+ self.hooks = default_hooks()
313
+
314
+ #: Dictionary of querystring data to attach to each
315
+ #: :class:`Request <Request>`. The dictionary values may be lists for
316
+ #: representing multivalued query parameters.
317
+ self.params = {}
318
+
319
+ #: Stream response content default.
320
+ self.stream = False
321
+
322
+ #: SSL Verification default.
323
+ self.verify = True
324
+
325
+ #: SSL certificate default.
326
+ self.cert = None
327
+
328
+ #: Maximum number of redirects allowed. If the request exceeds this
329
+ #: limit, a :class:`TooManyRedirects` exception is raised.
330
+ #: This defaults to requests.models.DEFAULT_REDIRECT_LIMIT, which is
331
+ #: 30.
332
+ self.max_redirects = DEFAULT_REDIRECT_LIMIT
333
+
334
+ #: Trust environment settings for proxy configuration, default
335
+ #: authentication and similar.
336
+ self.trust_env = True
337
+
338
+ #: A CookieJar containing all currently outstanding cookies set on this
339
+ #: session. By default it is a
340
+ #: :class:`RequestsCookieJar <requests.cookies.RequestsCookieJar>`, but
341
+ #: may be any other ``cookielib.CookieJar`` compatible object.
342
+ self.cookies = cookiejar_from_dict({})
343
+
344
+ # Default connection adapters.
345
+ self.adapters = OrderedDict()
346
+ self.mount('https://', HTTPAdapter())
347
+ self.mount('http://', HTTPAdapter())
348
+
349
+ # Only store 1000 redirects to prevent using infinite memory
350
+ self.redirect_cache = RecentlyUsedContainer(REDIRECT_CACHE_SIZE)
351
+
352
+ def __enter__(self):
353
+ return self
354
+
355
+ def __exit__(self, *args):
356
+ self.close()
357
+
358
+ def prepare_request(self, request):
359
+ """Constructs a :class:`PreparedRequest <PreparedRequest>` for
360
+ transmission and returns it. The :class:`PreparedRequest` has settings
361
+ merged from the :class:`Request <Request>` instance and those of the
362
+ :class:`Session`.
363
+
364
+ :param request: :class:`Request` instance to prepare with this
365
+ session's settings.
366
+ :rtype: requests.PreparedRequest
367
+ """
368
+ cookies = request.cookies or {}
369
+
370
+ # Bootstrap CookieJar.
371
+ if not isinstance(cookies, cookielib.CookieJar):
372
+ cookies = cookiejar_from_dict(cookies)
373
+
374
+ # Merge with session cookies
375
+ merged_cookies = merge_cookies(
376
+ merge_cookies(RequestsCookieJar(), self.cookies), cookies)
377
+
378
+ # Set environment's basic authentication if not explicitly set.
379
+ auth = request.auth
380
+ if self.trust_env and not auth and not self.auth:
381
+ auth = get_netrc_auth(request.url)
382
+
383
+ p = PreparedRequest()
384
+ p.prepare(
385
+ method=request.method.upper(),
386
+ url=request.url,
387
+ files=request.files,
388
+ data=request.data,
389
+ json=request.json,
390
+ headers=merge_setting(request.headers, self.headers, dict_class=CaseInsensitiveDict),
391
+ params=merge_setting(request.params, self.params),
392
+ auth=merge_setting(auth, self.auth),
393
+ cookies=merged_cookies,
394
+ hooks=merge_hooks(request.hooks, self.hooks),
395
+ )
396
+ return p
397
+
398
+ def request(self, method, url,
399
+ params=None,
400
+ data=None,
401
+ headers=None,
402
+ cookies=None,
403
+ files=None,
404
+ auth=None,
405
+ timeout=None,
406
+ allow_redirects=True,
407
+ proxies=None,
408
+ hooks=None,
409
+ stream=None,
410
+ verify=None,
411
+ cert=None,
412
+ json=None):
413
+ """Constructs a :class:`Request <Request>`, prepares it and sends it.
414
+ Returns :class:`Response <Response>` object.
415
+
416
+ :param method: method for the new :class:`Request` object.
417
+ :param url: URL for the new :class:`Request` object.
418
+ :param params: (optional) Dictionary or bytes to be sent in the query
419
+ string for the :class:`Request`.
420
+ :param data: (optional) Dictionary, bytes, or file-like object to send
421
+ in the body of the :class:`Request`.
422
+ :param json: (optional) json to send in the body of the
423
+ :class:`Request`.
424
+ :param headers: (optional) Dictionary of HTTP Headers to send with the
425
+ :class:`Request`.
426
+ :param cookies: (optional) Dict or CookieJar object to send with the
427
+ :class:`Request`.
428
+ :param files: (optional) Dictionary of ``'filename': file-like-objects``
429
+ for multipart encoding upload.
430
+ :param auth: (optional) Auth tuple or callable to enable
431
+ Basic/Digest/Custom HTTP Auth.
432
+ :param timeout: (optional) How long to wait for the server to send
433
+ data before giving up, as a float, or a :ref:`(connect timeout,
434
+ read timeout) <timeouts>` tuple.
435
+ :type timeout: float or tuple
436
+ :param allow_redirects: (optional) Set to True by default.
437
+ :type allow_redirects: bool
438
+ :param proxies: (optional) Dictionary mapping protocol or protocol and
439
+ hostname to the URL of the proxy.
440
+ :param stream: (optional) whether to immediately download the response
441
+ content. Defaults to ``False``.
442
+ :param verify: (optional) whether the SSL cert will be verified.
443
+ A CA_BUNDLE path can also be provided. Defaults to ``True``.
444
+ :param cert: (optional) if String, path to ssl client cert file (.pem).
445
+ If Tuple, ('cert', 'key') pair.
446
+ :rtype: requests.Response
447
+ """
448
+ # Create the Request.
449
+ req = Request(
450
+ method = method.upper(),
451
+ url = url,
452
+ headers = headers,
453
+ files = files,
454
+ data = data or {},
455
+ json = json,
456
+ params = params or {},
457
+ auth = auth,
458
+ cookies = cookies,
459
+ hooks = hooks,
460
+ )
461
+ prep = self.prepare_request(req)
462
+
463
+ proxies = proxies or {}
464
+
465
+ settings = self.merge_environment_settings(
466
+ prep.url, proxies, stream, verify, cert
467
+ )
468
+
469
+ # Send the request.
470
+ send_kwargs = {
471
+ 'timeout': timeout,
472
+ 'allow_redirects': allow_redirects,
473
+ }
474
+ send_kwargs.update(settings)
475
+ resp = self.send(prep, **send_kwargs)
476
+
477
+ return resp
478
+
479
+ def get(self, url, **kwargs):
480
+ """Sends a GET request. Returns :class:`Response` object.
481
+
482
+ :param url: URL for the new :class:`Request` object.
483
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
484
+ :rtype: requests.Response
485
+ """
486
+
487
+ kwargs.setdefault('allow_redirects', True)
488
+ return self.request('GET', url, **kwargs)
489
+
490
+ def options(self, url, **kwargs):
491
+ """Sends a OPTIONS request. Returns :class:`Response` object.
492
+
493
+ :param url: URL for the new :class:`Request` object.
494
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
495
+ :rtype: requests.Response
496
+ """
497
+
498
+ kwargs.setdefault('allow_redirects', True)
499
+ return self.request('OPTIONS', url, **kwargs)
500
+
501
+ def head(self, url, **kwargs):
502
+ """Sends a HEAD request. Returns :class:`Response` object.
503
+
504
+ :param url: URL for the new :class:`Request` object.
505
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
506
+ :rtype: requests.Response
507
+ """
508
+
509
+ kwargs.setdefault('allow_redirects', False)
510
+ return self.request('HEAD', url, **kwargs)
511
+
512
+ def post(self, url, data=None, json=None, **kwargs):
513
+ """Sends a POST request. Returns :class:`Response` object.
514
+
515
+ :param url: URL for the new :class:`Request` object.
516
+ :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
517
+ :param json: (optional) json to send in the body of the :class:`Request`.
518
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
519
+ :rtype: requests.Response
520
+ """
521
+
522
+ return self.request('POST', url, data=data, json=json, **kwargs)
523
+
524
+ def put(self, url, data=None, **kwargs):
525
+ """Sends a PUT request. Returns :class:`Response` object.
526
+
527
+ :param url: URL for the new :class:`Request` object.
528
+ :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
529
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
530
+ :rtype: requests.Response
531
+ """
532
+
533
+ return self.request('PUT', url, data=data, **kwargs)
534
+
535
+ def patch(self, url, data=None, **kwargs):
536
+ """Sends a PATCH request. Returns :class:`Response` object.
537
+
538
+ :param url: URL for the new :class:`Request` object.
539
+ :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
540
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
541
+ :rtype: requests.Response
542
+ """
543
+
544
+ return self.request('PATCH', url, data=data, **kwargs)
545
+
546
+ def delete(self, url, **kwargs):
547
+ """Sends a DELETE request. Returns :class:`Response` object.
548
+
549
+ :param url: URL for the new :class:`Request` object.
550
+ :param \*\*kwargs: Optional arguments that ``request`` takes.
551
+ :rtype: requests.Response
552
+ """
553
+
554
+ return self.request('DELETE', url, **kwargs)
555
+
556
+ def send(self, request, **kwargs):
557
+ """
558
+ Send a given PreparedRequest.
559
+
560
+ :rtype: requests.Response
561
+ """
562
+ # Set defaults that the hooks can utilize to ensure they always have
563
+ # the correct parameters to reproduce the previous request.
564
+ kwargs.setdefault('stream', self.stream)
565
+ kwargs.setdefault('verify', self.verify)
566
+ kwargs.setdefault('cert', self.cert)
567
+ kwargs.setdefault('proxies', self.proxies)
568
+
569
+ # It's possible that users might accidentally send a Request object.
570
+ # Guard against that specific failure case.
571
+ if isinstance(request, Request):
572
+ raise ValueError('You can only send PreparedRequests.')
573
+
574
+ # Set up variables needed for resolve_redirects and dispatching of hooks
575
+ allow_redirects = kwargs.pop('allow_redirects', True)
576
+ stream = kwargs.get('stream')
577
+ hooks = request.hooks
578
+
579
+ # Resolve URL in redirect cache, if available.
580
+ if allow_redirects:
581
+ checked_urls = set()
582
+ while request.url in self.redirect_cache:
583
+ checked_urls.add(request.url)
584
+ new_url = self.redirect_cache.get(request.url)
585
+ if new_url in checked_urls:
586
+ break
587
+ request.url = new_url
588
+
589
+ # Get the appropriate adapter to use
590
+ adapter = self.get_adapter(url=request.url)
591
+
592
+ # Start time (approximately) of the request
593
+ start = datetime.utcnow()
594
+
595
+ # Send the request
596
+ r = adapter.send(request, **kwargs)
597
+
598
+ # Total elapsed time of the request (approximately)
599
+ r.elapsed = datetime.utcnow() - start
600
+
601
+ # Response manipulation hooks
602
+ r = dispatch_hook('response', hooks, r, **kwargs)
603
+
604
+ # Persist cookies
605
+ if r.history:
606
+
607
+ # If the hooks create history then we want those cookies too
608
+ for resp in r.history:
609
+ extract_cookies_to_jar(self.cookies, resp.request, resp.raw)
610
+
611
+ extract_cookies_to_jar(self.cookies, request, r.raw)
612
+
613
+ # Redirect resolving generator.
614
+ gen = self.resolve_redirects(r, request, **kwargs)
615
+
616
+ # Resolve redirects if allowed.
617
+ history = [resp for resp in gen] if allow_redirects else []
618
+
619
+ # Shuffle things around if there's history.
620
+ if history:
621
+ # Insert the first (original) request at the start
622
+ history.insert(0, r)
623
+ # Get the last request made
624
+ r = history.pop()
625
+ r.history = history
626
+
627
+ if not stream:
628
+ r.content
629
+
630
+ return r
631
+
632
+ def merge_environment_settings(self, url, proxies, stream, verify, cert):
633
+ """
634
+ Check the environment and merge it with some settings.
635
+
636
+ :rtype: dict
637
+ """
638
+ # Gather clues from the surrounding environment.
639
+ if self.trust_env:
640
+ # Set environment's proxies.
641
+ env_proxies = get_environ_proxies(url) or {}
642
+ for (k, v) in env_proxies.items():
643
+ proxies.setdefault(k, v)
644
+
645
+ # Look for requests environment configuration and be compatible
646
+ # with cURL.
647
+ if verify is True or verify is None:
648
+ verify = (os.environ.get('REQUESTS_CA_BUNDLE') or
649
+ os.environ.get('CURL_CA_BUNDLE'))
650
+
651
+ # Merge all the kwargs.
652
+ proxies = merge_setting(proxies, self.proxies)
653
+ stream = merge_setting(stream, self.stream)
654
+ verify = merge_setting(verify, self.verify)
655
+ cert = merge_setting(cert, self.cert)
656
+
657
+ return {'verify': verify, 'proxies': proxies, 'stream': stream,
658
+ 'cert': cert}
659
+
660
+ def get_adapter(self, url):
661
+ """
662
+ Returns the appropriate connection adapter for the given URL.
663
+
664
+ :rtype: requests.adapters.BaseAdapter
665
+ """
666
+ for (prefix, adapter) in self.adapters.items():
667
+
668
+ if url.lower().startswith(prefix):
669
+ return adapter
670
+
671
+ # Nothing matches :-/
672
+ raise InvalidSchema("No connection adapters were found for '%s'" % url)
673
+
674
+ def close(self):
675
+ """Closes all adapters and as such the session"""
676
+ for v in self.adapters.values():
677
+ v.close()
678
+
679
+ def mount(self, prefix, adapter):
680
+ """Registers a connection adapter to a prefix.
681
+
682
+ Adapters are sorted in descending order by key length.
683
+ """
684
+ self.adapters[prefix] = adapter
685
+ keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
686
+
687
+ for key in keys_to_move:
688
+ self.adapters[key] = self.adapters.pop(key)
689
+
690
+ def __getstate__(self):
691
+ state = dict((attr, getattr(self, attr, None)) for attr in self.__attrs__)
692
+ state['redirect_cache'] = dict(self.redirect_cache)
693
+ return state
694
+
695
+ def __setstate__(self, state):
696
+ redirect_cache = state.pop('redirect_cache', {})
697
+ for attr, value in state.items():
698
+ setattr(self, attr, value)
699
+
700
+ self.redirect_cache = RecentlyUsedContainer(REDIRECT_CACHE_SIZE)
701
+ for redirect, to in redirect_cache.items():
702
+ self.redirect_cache[redirect] = to
703
+
704
+
705
+ def session():
706
+ """
707
+ Returns a :class:`Session` for context-management.
708
+
709
+ :rtype: Session
710
+ """
711
+
712
+ return Session()