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,817 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ requests.utils
5
+ ~~~~~~~~~~~~~~
6
+
7
+ This module provides utility functions that are used within Requests
8
+ that are also useful for external consumption.
9
+ """
10
+
11
+ import cgi
12
+ import codecs
13
+ import collections
14
+ import io
15
+ import os
16
+ import re
17
+ import socket
18
+ import struct
19
+ import warnings
20
+
21
+ from . import __version__
22
+ from . import certs
23
+ from .compat import parse_http_list as _parse_list_header
24
+ from .compat import (quote, urlparse, bytes, str, OrderedDict, unquote, is_py2,
25
+ builtin_str, getproxies, proxy_bypass, urlunparse,
26
+ basestring)
27
+ from .cookies import RequestsCookieJar, cookiejar_from_dict
28
+ from .structures import CaseInsensitiveDict
29
+ from .exceptions import InvalidURL, InvalidHeader, FileModeWarning
30
+
31
+ _hush_pyflakes = (RequestsCookieJar,)
32
+
33
+ NETRC_FILES = ('.netrc', '_netrc')
34
+
35
+ DEFAULT_CA_BUNDLE_PATH = certs.where()
36
+
37
+
38
+ def dict_to_sequence(d):
39
+ """Returns an internal sequence dictionary update."""
40
+
41
+ if hasattr(d, 'items'):
42
+ d = d.items()
43
+
44
+ return d
45
+
46
+
47
+ def super_len(o):
48
+ total_length = 0
49
+ current_position = 0
50
+
51
+ if hasattr(o, '__len__'):
52
+ total_length = len(o)
53
+
54
+ elif hasattr(o, 'len'):
55
+ total_length = o.len
56
+
57
+ elif hasattr(o, 'getvalue'):
58
+ # e.g. BytesIO, cStringIO.StringIO
59
+ total_length = len(o.getvalue())
60
+
61
+ elif hasattr(o, 'fileno'):
62
+ try:
63
+ fileno = o.fileno()
64
+ except io.UnsupportedOperation:
65
+ pass
66
+ else:
67
+ total_length = os.fstat(fileno).st_size
68
+
69
+ # Having used fstat to determine the file length, we need to
70
+ # confirm that this file was opened up in binary mode.
71
+ if 'b' not in o.mode:
72
+ warnings.warn((
73
+ "Requests has determined the content-length for this "
74
+ "request using the binary size of the file: however, the "
75
+ "file has been opened in text mode (i.e. without the 'b' "
76
+ "flag in the mode). This may lead to an incorrect "
77
+ "content-length. In Requests 3.0, support will be removed "
78
+ "for files in text mode."),
79
+ FileModeWarning
80
+ )
81
+
82
+ if hasattr(o, 'tell'):
83
+ try:
84
+ current_position = o.tell()
85
+ except (OSError, IOError):
86
+ # This can happen in some weird situations, such as when the file
87
+ # is actually a special file descriptor like stdin. In this
88
+ # instance, we don't know what the length is, so set it to zero and
89
+ # let requests chunk it instead.
90
+ current_position = total_length
91
+
92
+ return max(0, total_length - current_position)
93
+
94
+
95
+ def get_netrc_auth(url, raise_errors=False):
96
+ """Returns the Requests tuple auth for a given url from netrc."""
97
+
98
+ try:
99
+ from netrc import netrc, NetrcParseError
100
+
101
+ netrc_path = None
102
+
103
+ for f in NETRC_FILES:
104
+ try:
105
+ loc = os.path.expanduser('~/{0}'.format(f))
106
+ except KeyError:
107
+ # os.path.expanduser can fail when $HOME is undefined and
108
+ # getpwuid fails. See http://bugs.python.org/issue20164 &
109
+ # https://github.com/kennethreitz/requests/issues/1846
110
+ return
111
+
112
+ if os.path.exists(loc):
113
+ netrc_path = loc
114
+ break
115
+
116
+ # Abort early if there isn't one.
117
+ if netrc_path is None:
118
+ return
119
+
120
+ ri = urlparse(url)
121
+
122
+ # Strip port numbers from netloc. This weird `if...encode`` dance is
123
+ # used for Python 3.2, which doesn't support unicode literals.
124
+ splitstr = b':'
125
+ if isinstance(url, str):
126
+ splitstr = splitstr.decode('ascii')
127
+ host = ri.netloc.split(splitstr)[0]
128
+
129
+ try:
130
+ _netrc = netrc(netrc_path).authenticators(host)
131
+ if _netrc:
132
+ # Return with login / password
133
+ login_i = (0 if _netrc[0] else 1)
134
+ return (_netrc[login_i], _netrc[2])
135
+ except (NetrcParseError, IOError):
136
+ # If there was a parsing error or a permissions issue reading the file,
137
+ # we'll just skip netrc auth unless explicitly asked to raise errors.
138
+ if raise_errors:
139
+ raise
140
+
141
+ # AppEngine hackiness.
142
+ except (ImportError, AttributeError):
143
+ pass
144
+
145
+
146
+ def guess_filename(obj):
147
+ """Tries to guess the filename of the given object."""
148
+ name = getattr(obj, 'name', None)
149
+ if (name and isinstance(name, basestring) and name[0] != '<' and
150
+ name[-1] != '>'):
151
+ return os.path.basename(name)
152
+
153
+
154
+ def from_key_val_list(value):
155
+ """Take an object and test to see if it can be represented as a
156
+ dictionary. Unless it can not be represented as such, return an
157
+ OrderedDict, e.g.,
158
+
159
+ ::
160
+
161
+ >>> from_key_val_list([('key', 'val')])
162
+ OrderedDict([('key', 'val')])
163
+ >>> from_key_val_list('string')
164
+ ValueError: need more than 1 value to unpack
165
+ >>> from_key_val_list({'key': 'val'})
166
+ OrderedDict([('key', 'val')])
167
+
168
+ :rtype: OrderedDict
169
+ """
170
+ if value is None:
171
+ return None
172
+
173
+ if isinstance(value, (str, bytes, bool, int)):
174
+ raise ValueError('cannot encode objects that are not 2-tuples')
175
+
176
+ return OrderedDict(value)
177
+
178
+
179
+ def to_key_val_list(value):
180
+ """Take an object and test to see if it can be represented as a
181
+ dictionary. If it can be, return a list of tuples, e.g.,
182
+
183
+ ::
184
+
185
+ >>> to_key_val_list([('key', 'val')])
186
+ [('key', 'val')]
187
+ >>> to_key_val_list({'key': 'val'})
188
+ [('key', 'val')]
189
+ >>> to_key_val_list('string')
190
+ ValueError: cannot encode objects that are not 2-tuples.
191
+
192
+ :rtype: list
193
+ """
194
+ if value is None:
195
+ return None
196
+
197
+ if isinstance(value, (str, bytes, bool, int)):
198
+ raise ValueError('cannot encode objects that are not 2-tuples')
199
+
200
+ if isinstance(value, collections.Mapping):
201
+ value = value.items()
202
+
203
+ return list(value)
204
+
205
+
206
+ # From mitsuhiko/werkzeug (used with permission).
207
+ def parse_list_header(value):
208
+ """Parse lists as described by RFC 2068 Section 2.
209
+
210
+ In particular, parse comma-separated lists where the elements of
211
+ the list may include quoted-strings. A quoted-string could
212
+ contain a comma. A non-quoted string could have quotes in the
213
+ middle. Quotes are removed automatically after parsing.
214
+
215
+ It basically works like :func:`parse_set_header` just that items
216
+ may appear multiple times and case sensitivity is preserved.
217
+
218
+ The return value is a standard :class:`list`:
219
+
220
+ >>> parse_list_header('token, "quoted value"')
221
+ ['token', 'quoted value']
222
+
223
+ To create a header from the :class:`list` again, use the
224
+ :func:`dump_header` function.
225
+
226
+ :param value: a string with a list header.
227
+ :return: :class:`list`
228
+ :rtype: list
229
+ """
230
+ result = []
231
+ for item in _parse_list_header(value):
232
+ if item[:1] == item[-1:] == '"':
233
+ item = unquote_header_value(item[1:-1])
234
+ result.append(item)
235
+ return result
236
+
237
+
238
+ # From mitsuhiko/werkzeug (used with permission).
239
+ def parse_dict_header(value):
240
+ """Parse lists of key, value pairs as described by RFC 2068 Section 2 and
241
+ convert them into a python dict:
242
+
243
+ >>> d = parse_dict_header('foo="is a fish", bar="as well"')
244
+ >>> type(d) is dict
245
+ True
246
+ >>> sorted(d.items())
247
+ [('bar', 'as well'), ('foo', 'is a fish')]
248
+
249
+ If there is no value for a key it will be `None`:
250
+
251
+ >>> parse_dict_header('key_without_value')
252
+ {'key_without_value': None}
253
+
254
+ To create a header from the :class:`dict` again, use the
255
+ :func:`dump_header` function.
256
+
257
+ :param value: a string with a dict header.
258
+ :return: :class:`dict`
259
+ :rtype: dict
260
+ """
261
+ result = {}
262
+ for item in _parse_list_header(value):
263
+ if '=' not in item:
264
+ result[item] = None
265
+ continue
266
+ name, value = item.split('=', 1)
267
+ if value[:1] == value[-1:] == '"':
268
+ value = unquote_header_value(value[1:-1])
269
+ result[name] = value
270
+ return result
271
+
272
+
273
+ # From mitsuhiko/werkzeug (used with permission).
274
+ def unquote_header_value(value, is_filename=False):
275
+ r"""Unquotes a header value. (Reversal of :func:`quote_header_value`).
276
+ This does not use the real unquoting but what browsers are actually
277
+ using for quoting.
278
+
279
+ :param value: the header value to unquote.
280
+ :rtype: str
281
+ """
282
+ if value and value[0] == value[-1] == '"':
283
+ # this is not the real unquoting, but fixing this so that the
284
+ # RFC is met will result in bugs with internet explorer and
285
+ # probably some other browsers as well. IE for example is
286
+ # uploading files with "C:\foo\bar.txt" as filename
287
+ value = value[1:-1]
288
+
289
+ # if this is a filename and the starting characters look like
290
+ # a UNC path, then just return the value without quotes. Using the
291
+ # replace sequence below on a UNC path has the effect of turning
292
+ # the leading double slash into a single slash and then
293
+ # _fix_ie_filename() doesn't work correctly. See #458.
294
+ if not is_filename or value[:2] != '\\\\':
295
+ return value.replace('\\\\', '\\').replace('\\"', '"')
296
+ return value
297
+
298
+
299
+ def dict_from_cookiejar(cj):
300
+ """Returns a key/value dictionary from a CookieJar.
301
+
302
+ :param cj: CookieJar object to extract cookies from.
303
+ :rtype: dict
304
+ """
305
+
306
+ cookie_dict = {}
307
+
308
+ for cookie in cj:
309
+ cookie_dict[cookie.name] = cookie.value
310
+
311
+ return cookie_dict
312
+
313
+
314
+ def add_dict_to_cookiejar(cj, cookie_dict):
315
+ """Returns a CookieJar from a key/value dictionary.
316
+
317
+ :param cj: CookieJar to insert cookies into.
318
+ :param cookie_dict: Dict of key/values to insert into CookieJar.
319
+ :rtype: CookieJar
320
+ """
321
+
322
+ cj2 = cookiejar_from_dict(cookie_dict)
323
+ cj.update(cj2)
324
+ return cj
325
+
326
+
327
+ def get_encodings_from_content(content):
328
+ """Returns encodings from given content string.
329
+
330
+ :param content: bytestring to extract encodings from.
331
+ """
332
+ warnings.warn((
333
+ 'In requests 3.0, get_encodings_from_content will be removed. For '
334
+ 'more information, please see the discussion on issue #2266. (This'
335
+ ' warning should only appear once.)'),
336
+ DeprecationWarning)
337
+
338
+ charset_re = re.compile(r'<meta.*?charset=["\']*(.+?)["\'>]', flags=re.I)
339
+ pragma_re = re.compile(r'<meta.*?content=["\']*;?charset=(.+?)["\'>]', flags=re.I)
340
+ xml_re = re.compile(r'^<\?xml.*?encoding=["\']*(.+?)["\'>]')
341
+
342
+ return (charset_re.findall(content) +
343
+ pragma_re.findall(content) +
344
+ xml_re.findall(content))
345
+
346
+
347
+ def get_encoding_from_headers(headers):
348
+ """Returns encodings from given HTTP Header Dict.
349
+
350
+ :param headers: dictionary to extract encoding from.
351
+ :rtype: str
352
+ """
353
+
354
+ content_type = headers.get('content-type')
355
+
356
+ if not content_type:
357
+ return None
358
+
359
+ content_type, params = cgi.parse_header(content_type)
360
+
361
+ if 'charset' in params:
362
+ return params['charset'].strip("'\"")
363
+
364
+ if 'text' in content_type:
365
+ return 'ISO-8859-1'
366
+
367
+
368
+ def stream_decode_response_unicode(iterator, r):
369
+ """Stream decodes a iterator."""
370
+
371
+ if r.encoding is None:
372
+ for item in iterator:
373
+ yield item
374
+ return
375
+
376
+ decoder = codecs.getincrementaldecoder(r.encoding)(errors='replace')
377
+ for chunk in iterator:
378
+ rv = decoder.decode(chunk)
379
+ if rv:
380
+ yield rv
381
+ rv = decoder.decode(b'', final=True)
382
+ if rv:
383
+ yield rv
384
+
385
+
386
+ def iter_slices(string, slice_length):
387
+ """Iterate over slices of a string."""
388
+ pos = 0
389
+ if slice_length is None or slice_length <= 0:
390
+ slice_length = len(string)
391
+ while pos < len(string):
392
+ yield string[pos:pos + slice_length]
393
+ pos += slice_length
394
+
395
+
396
+ def get_unicode_from_response(r):
397
+ """Returns the requested content back in unicode.
398
+
399
+ :param r: Response object to get unicode content from.
400
+
401
+ Tried:
402
+
403
+ 1. charset from content-type
404
+ 2. fall back and replace all unicode characters
405
+
406
+ :rtype: str
407
+ """
408
+ warnings.warn((
409
+ 'In requests 3.0, get_unicode_from_response will be removed. For '
410
+ 'more information, please see the discussion on issue #2266. (This'
411
+ ' warning should only appear once.)'),
412
+ DeprecationWarning)
413
+
414
+ tried_encodings = []
415
+
416
+ # Try charset from content-type
417
+ encoding = get_encoding_from_headers(r.headers)
418
+
419
+ if encoding:
420
+ try:
421
+ return str(r.content, encoding)
422
+ except UnicodeError:
423
+ tried_encodings.append(encoding)
424
+
425
+ # Fall back:
426
+ try:
427
+ return str(r.content, encoding, errors='replace')
428
+ except TypeError:
429
+ return r.content
430
+
431
+
432
+ # The unreserved URI characters (RFC 3986)
433
+ UNRESERVED_SET = frozenset(
434
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
435
+ + "0123456789-._~")
436
+
437
+
438
+ def unquote_unreserved(uri):
439
+ """Un-escape any percent-escape sequences in a URI that are unreserved
440
+ characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
441
+
442
+ :rtype: str
443
+ """
444
+ parts = uri.split('%')
445
+ for i in range(1, len(parts)):
446
+ h = parts[i][0:2]
447
+ if len(h) == 2 and h.isalnum():
448
+ try:
449
+ c = chr(int(h, 16))
450
+ except ValueError:
451
+ raise InvalidURL("Invalid percent-escape sequence: '%s'" % h)
452
+
453
+ if c in UNRESERVED_SET:
454
+ parts[i] = c + parts[i][2:]
455
+ else:
456
+ parts[i] = '%' + parts[i]
457
+ else:
458
+ parts[i] = '%' + parts[i]
459
+ return ''.join(parts)
460
+
461
+
462
+ def requote_uri(uri):
463
+ """Re-quote the given URI.
464
+
465
+ This function passes the given URI through an unquote/quote cycle to
466
+ ensure that it is fully and consistently quoted.
467
+
468
+ :rtype: str
469
+ """
470
+ safe_with_percent = "!#$%&'()*+,/:;=?@[]~"
471
+ safe_without_percent = "!#$&'()*+,/:;=?@[]~"
472
+ try:
473
+ # Unquote only the unreserved characters
474
+ # Then quote only illegal characters (do not quote reserved,
475
+ # unreserved, or '%')
476
+ return quote(unquote_unreserved(uri), safe=safe_with_percent)
477
+ except InvalidURL:
478
+ # We couldn't unquote the given URI, so let's try quoting it, but
479
+ # there may be unquoted '%'s in the URI. We need to make sure they're
480
+ # properly quoted so they do not cause issues elsewhere.
481
+ return quote(uri, safe=safe_without_percent)
482
+
483
+
484
+ def address_in_network(ip, net):
485
+ """This function allows you to check if on IP belongs to a network subnet
486
+
487
+ Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
488
+ returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
489
+
490
+ :rtype: bool
491
+ """
492
+ ipaddr = struct.unpack('=L', socket.inet_aton(ip))[0]
493
+ netaddr, bits = net.split('/')
494
+ netmask = struct.unpack('=L', socket.inet_aton(dotted_netmask(int(bits))))[0]
495
+ network = struct.unpack('=L', socket.inet_aton(netaddr))[0] & netmask
496
+ return (ipaddr & netmask) == (network & netmask)
497
+
498
+
499
+ def dotted_netmask(mask):
500
+ """Converts mask from /xx format to xxx.xxx.xxx.xxx
501
+
502
+ Example: if mask is 24 function returns 255.255.255.0
503
+
504
+ :rtype: str
505
+ """
506
+ bits = 0xffffffff ^ (1 << 32 - mask) - 1
507
+ return socket.inet_ntoa(struct.pack('>I', bits))
508
+
509
+
510
+ def is_ipv4_address(string_ip):
511
+ """
512
+ :rtype: bool
513
+ """
514
+ try:
515
+ socket.inet_aton(string_ip)
516
+ except socket.error:
517
+ return False
518
+ return True
519
+
520
+
521
+ def is_valid_cidr(string_network):
522
+ """
523
+ Very simple check of the cidr format in no_proxy variable.
524
+
525
+ :rtype: bool
526
+ """
527
+ if string_network.count('/') == 1:
528
+ try:
529
+ mask = int(string_network.split('/')[1])
530
+ except ValueError:
531
+ return False
532
+
533
+ if mask < 1 or mask > 32:
534
+ return False
535
+
536
+ try:
537
+ socket.inet_aton(string_network.split('/')[0])
538
+ except socket.error:
539
+ return False
540
+ else:
541
+ return False
542
+ return True
543
+
544
+
545
+ def should_bypass_proxies(url):
546
+ """
547
+ Returns whether we should bypass proxies or not.
548
+
549
+ :rtype: bool
550
+ """
551
+ get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper())
552
+
553
+ # First check whether no_proxy is defined. If it is, check that the URL
554
+ # we're getting isn't in the no_proxy list.
555
+ no_proxy = get_proxy('no_proxy')
556
+ netloc = urlparse(url).netloc
557
+
558
+ if no_proxy:
559
+ # We need to check whether we match here. We need to see if we match
560
+ # the end of the netloc, both with and without the port.
561
+ no_proxy = (
562
+ host for host in no_proxy.replace(' ', '').split(',') if host
563
+ )
564
+
565
+ ip = netloc.split(':')[0]
566
+ if is_ipv4_address(ip):
567
+ for proxy_ip in no_proxy:
568
+ if is_valid_cidr(proxy_ip):
569
+ if address_in_network(ip, proxy_ip):
570
+ return True
571
+ elif ip == proxy_ip:
572
+ # If no_proxy ip was defined in plain IP notation instead of cidr notation &
573
+ # matches the IP of the index
574
+ return True
575
+ else:
576
+ for host in no_proxy:
577
+ if netloc.endswith(host) or netloc.split(':')[0].endswith(host):
578
+ # The URL does match something in no_proxy, so we don't want
579
+ # to apply the proxies on this URL.
580
+ return True
581
+
582
+ # If the system proxy settings indicate that this URL should be bypassed,
583
+ # don't proxy.
584
+ # The proxy_bypass function is incredibly buggy on OS X in early versions
585
+ # of Python 2.6, so allow this call to fail. Only catch the specific
586
+ # exceptions we've seen, though: this call failing in other ways can reveal
587
+ # legitimate problems.
588
+ try:
589
+ bypass = proxy_bypass(netloc)
590
+ except (TypeError, socket.gaierror):
591
+ bypass = False
592
+
593
+ if bypass:
594
+ return True
595
+
596
+ return False
597
+
598
+
599
+ def get_environ_proxies(url):
600
+ """
601
+ Return a dict of environment proxies.
602
+
603
+ :rtype: dict
604
+ """
605
+ if should_bypass_proxies(url):
606
+ return {}
607
+ else:
608
+ return getproxies()
609
+
610
+
611
+ def select_proxy(url, proxies):
612
+ """Select a proxy for the url, if applicable.
613
+
614
+ :param url: The url being for the request
615
+ :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
616
+ """
617
+ proxies = proxies or {}
618
+ urlparts = urlparse(url)
619
+ if urlparts.hostname is None:
620
+ return proxies.get('all', proxies.get(urlparts.scheme))
621
+
622
+ proxy_keys = [
623
+ 'all://' + urlparts.hostname,
624
+ 'all',
625
+ urlparts.scheme + '://' + urlparts.hostname,
626
+ urlparts.scheme,
627
+ ]
628
+ proxy = None
629
+ for proxy_key in proxy_keys:
630
+ if proxy_key in proxies:
631
+ proxy = proxies[proxy_key]
632
+ break
633
+
634
+ return proxy
635
+
636
+
637
+ def default_user_agent(name="python-requests"):
638
+ """
639
+ Return a string representing the default user agent.
640
+
641
+ :rtype: str
642
+ """
643
+ return '%s/%s' % (name, __version__)
644
+
645
+
646
+ def default_headers():
647
+ """
648
+ :rtype: requests.structures.CaseInsensitiveDict
649
+ """
650
+ return CaseInsensitiveDict({
651
+ 'User-Agent': default_user_agent(),
652
+ 'Accept-Encoding': ', '.join(('gzip', 'deflate')),
653
+ 'Accept': '*/*',
654
+ 'Connection': 'keep-alive',
655
+ })
656
+
657
+
658
+ def parse_header_links(value):
659
+ """Return a dict of parsed link headers proxies.
660
+
661
+ i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
662
+
663
+ :rtype: list
664
+ """
665
+
666
+ links = []
667
+
668
+ replace_chars = ' \'"'
669
+
670
+ for val in re.split(', *<', value):
671
+ try:
672
+ url, params = val.split(';', 1)
673
+ except ValueError:
674
+ url, params = val, ''
675
+
676
+ link = {'url': url.strip('<> \'"')}
677
+
678
+ for param in params.split(';'):
679
+ try:
680
+ key, value = param.split('=')
681
+ except ValueError:
682
+ break
683
+
684
+ link[key.strip(replace_chars)] = value.strip(replace_chars)
685
+
686
+ links.append(link)
687
+
688
+ return links
689
+
690
+
691
+ # Null bytes; no need to recreate these on each call to guess_json_utf
692
+ _null = '\x00'.encode('ascii') # encoding to ASCII for Python 3
693
+ _null2 = _null * 2
694
+ _null3 = _null * 3
695
+
696
+
697
+ def guess_json_utf(data):
698
+ """
699
+ :rtype: str
700
+ """
701
+ # JSON always starts with two ASCII characters, so detection is as
702
+ # easy as counting the nulls and from their location and count
703
+ # determine the encoding. Also detect a BOM, if present.
704
+ sample = data[:4]
705
+ if sample in (codecs.BOM_UTF32_LE, codecs.BOM32_BE):
706
+ return 'utf-32' # BOM included
707
+ if sample[:3] == codecs.BOM_UTF8:
708
+ return 'utf-8-sig' # BOM included, MS style (discouraged)
709
+ if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE):
710
+ return 'utf-16' # BOM included
711
+ nullcount = sample.count(_null)
712
+ if nullcount == 0:
713
+ return 'utf-8'
714
+ if nullcount == 2:
715
+ if sample[::2] == _null2: # 1st and 3rd are null
716
+ return 'utf-16-be'
717
+ if sample[1::2] == _null2: # 2nd and 4th are null
718
+ return 'utf-16-le'
719
+ # Did not detect 2 valid UTF-16 ascii-range characters
720
+ if nullcount == 3:
721
+ if sample[:3] == _null3:
722
+ return 'utf-32-be'
723
+ if sample[1:] == _null3:
724
+ return 'utf-32-le'
725
+ # Did not detect a valid UTF-32 ascii-range character
726
+ return None
727
+
728
+
729
+ def prepend_scheme_if_needed(url, new_scheme):
730
+ """Given a URL that may or may not have a scheme, prepend the given scheme.
731
+ Does not replace a present scheme with the one provided as an argument.
732
+
733
+ :rtype: str
734
+ """
735
+ scheme, netloc, path, params, query, fragment = urlparse(url, new_scheme)
736
+
737
+ # urlparse is a finicky beast, and sometimes decides that there isn't a
738
+ # netloc present. Assume that it's being over-cautious, and switch netloc
739
+ # and path if urlparse decided there was no netloc.
740
+ if not netloc:
741
+ netloc, path = path, netloc
742
+
743
+ return urlunparse((scheme, netloc, path, params, query, fragment))
744
+
745
+
746
+ def get_auth_from_url(url):
747
+ """Given a url with authentication components, extract them into a tuple of
748
+ username,password.
749
+
750
+ :rtype: (str,str)
751
+ """
752
+ parsed = urlparse(url)
753
+
754
+ try:
755
+ auth = (unquote(parsed.username), unquote(parsed.password))
756
+ except (AttributeError, TypeError):
757
+ auth = ('', '')
758
+
759
+ return auth
760
+
761
+
762
+ def to_native_string(string, encoding='ascii'):
763
+ """Given a string object, regardless of type, returns a representation of
764
+ that string in the native string type, encoding and decoding where
765
+ necessary. This assumes ASCII unless told otherwise.
766
+ """
767
+ if isinstance(string, builtin_str):
768
+ out = string
769
+ else:
770
+ if is_py2:
771
+ out = string.encode(encoding)
772
+ else:
773
+ out = string.decode(encoding)
774
+
775
+ return out
776
+
777
+
778
+ # Moved outside of function to avoid recompile every call
779
+ _CLEAN_HEADER_REGEX_BYTE = re.compile(b'^\\S[^\\r\\n]*$|^$')
780
+ _CLEAN_HEADER_REGEX_STR = re.compile(r'^\S[^\r\n]*$|^$')
781
+
782
+ def check_header_validity(header):
783
+ """Verifies that header value is a string which doesn't contain
784
+ leading whitespace or return characters. This prevents unintended
785
+ header injection.
786
+
787
+ :param header: tuple, in the format (name, value).
788
+ """
789
+ name, value = header
790
+
791
+ if isinstance(value, bytes):
792
+ pat = _CLEAN_HEADER_REGEX_BYTE
793
+ else:
794
+ pat = _CLEAN_HEADER_REGEX_STR
795
+ try:
796
+ if not pat.match(value):
797
+ raise InvalidHeader("Invalid return character or leading space in header: %s" % name)
798
+ except TypeError:
799
+ raise InvalidHeader("Header value %s must be of type str or bytes, "
800
+ "not %s" % (value, type(value)))
801
+
802
+
803
+ def urldefragauth(url):
804
+ """
805
+ Given a url remove the fragment and the authentication part.
806
+
807
+ :rtype: str
808
+ """
809
+ scheme, netloc, path, params, query, fragment = urlparse(url)
810
+
811
+ # see func:`prepend_scheme_if_needed`
812
+ if not netloc:
813
+ netloc, path = path, netloc
814
+
815
+ netloc = netloc.rsplit('@', 1)[-1]
816
+
817
+ return urlunparse((scheme, netloc, path, params, query, ''))