rigid 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/rigid +4 -0
- data/rigid +16 -0
- data/vendor/PyYAML-3.12.dist-info/DESCRIPTION.rst +12 -0
- data/vendor/PyYAML-3.12.dist-info/INSTALLER +1 -0
- data/vendor/PyYAML-3.12.dist-info/METADATA +35 -0
- data/vendor/PyYAML-3.12.dist-info/RECORD +42 -0
- data/vendor/PyYAML-3.12.dist-info/WHEEL +5 -0
- data/vendor/PyYAML-3.12.dist-info/metadata.json +1 -0
- data/vendor/PyYAML-3.12.dist-info/top_level.txt +2 -0
- data/vendor/_yaml.so +0 -0
- data/vendor/click/__init__.py +98 -0
- data/vendor/click/__init__.pyc +0 -0
- data/vendor/click/_bashcomplete.py +83 -0
- data/vendor/click/_bashcomplete.pyc +0 -0
- data/vendor/click/_compat.py +642 -0
- data/vendor/click/_compat.pyc +0 -0
- data/vendor/click/_termui_impl.py +547 -0
- data/vendor/click/_termui_impl.pyc +0 -0
- data/vendor/click/_textwrap.py +38 -0
- data/vendor/click/_textwrap.pyc +0 -0
- data/vendor/click/_unicodefun.py +119 -0
- data/vendor/click/_unicodefun.pyc +0 -0
- data/vendor/click/_winconsole.py +273 -0
- data/vendor/click/_winconsole.pyc +0 -0
- data/vendor/click/core.py +1738 -0
- data/vendor/click/core.pyc +0 -0
- data/vendor/click/decorators.py +304 -0
- data/vendor/click/decorators.pyc +0 -0
- data/vendor/click/exceptions.py +201 -0
- data/vendor/click/exceptions.pyc +0 -0
- data/vendor/click/formatting.py +256 -0
- data/vendor/click/formatting.pyc +0 -0
- data/vendor/click/globals.py +48 -0
- data/vendor/click/globals.pyc +0 -0
- data/vendor/click/parser.py +426 -0
- data/vendor/click/parser.pyc +0 -0
- data/vendor/click/termui.py +539 -0
- data/vendor/click/termui.pyc +0 -0
- data/vendor/click/testing.py +322 -0
- data/vendor/click/testing.pyc +0 -0
- data/vendor/click/types.py +550 -0
- data/vendor/click/types.pyc +0 -0
- data/vendor/click/utils.py +415 -0
- data/vendor/click/utils.pyc +0 -0
- data/vendor/click-6.6.dist-info/DESCRIPTION.rst +3 -0
- data/vendor/click-6.6.dist-info/INSTALLER +1 -0
- data/vendor/click-6.6.dist-info/METADATA +16 -0
- data/vendor/click-6.6.dist-info/RECORD +41 -0
- data/vendor/click-6.6.dist-info/WHEEL +6 -0
- data/vendor/click-6.6.dist-info/metadata.json +1 -0
- data/vendor/click-6.6.dist-info/top_level.txt +1 -0
- data/vendor/easy_install.py +5 -0
- data/vendor/easy_install.pyc +0 -0
- data/vendor/pip-9.0.1.dist-info/DESCRIPTION.rst +39 -0
- data/vendor/pip-9.0.1.dist-info/INSTALLER +1 -0
- data/vendor/pip-9.0.1.dist-info/METADATA +69 -0
- data/vendor/pip-9.0.1.dist-info/RECORD +501 -0
- data/vendor/pip-9.0.1.dist-info/WHEEL +6 -0
- data/vendor/pip-9.0.1.dist-info/entry_points.txt +5 -0
- data/vendor/pip-9.0.1.dist-info/metadata.json +1 -0
- data/vendor/pip-9.0.1.dist-info/top_level.txt +1 -0
- data/vendor/pkg_resources/__init__.py +3051 -0
- data/vendor/pkg_resources/__init__.pyc +0 -0
- data/vendor/pkg_resources/_vendor/__init__.py +0 -0
- data/vendor/pkg_resources/_vendor/__init__.pyc +0 -0
- data/vendor/pkg_resources/_vendor/appdirs.py +552 -0
- data/vendor/pkg_resources/_vendor/appdirs.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/__about__.py +21 -0
- data/vendor/pkg_resources/_vendor/packaging/__about__.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/__init__.py +14 -0
- data/vendor/pkg_resources/_vendor/packaging/__init__.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/_compat.py +30 -0
- data/vendor/pkg_resources/_vendor/packaging/_compat.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/_structures.py +68 -0
- data/vendor/pkg_resources/_vendor/packaging/_structures.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/markers.py +287 -0
- data/vendor/pkg_resources/_vendor/packaging/markers.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/requirements.py +127 -0
- data/vendor/pkg_resources/_vendor/packaging/requirements.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/specifiers.py +774 -0
- data/vendor/pkg_resources/_vendor/packaging/specifiers.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/utils.py +14 -0
- data/vendor/pkg_resources/_vendor/packaging/utils.pyc +0 -0
- data/vendor/pkg_resources/_vendor/packaging/version.py +393 -0
- data/vendor/pkg_resources/_vendor/packaging/version.pyc +0 -0
- data/vendor/pkg_resources/_vendor/pyparsing.py +5696 -0
- data/vendor/pkg_resources/_vendor/pyparsing.pyc +0 -0
- data/vendor/pkg_resources/_vendor/six.py +868 -0
- data/vendor/pkg_resources/_vendor/six.pyc +0 -0
- data/vendor/pkg_resources/extern/__init__.py +73 -0
- data/vendor/pkg_resources/extern/__init__.pyc +0 -0
- data/vendor/requests/__init__.py +86 -0
- data/vendor/requests/__init__.pyc +0 -0
- data/vendor/requests/adapters.py +503 -0
- data/vendor/requests/adapters.pyc +0 -0
- data/vendor/requests/api.py +148 -0
- data/vendor/requests/api.pyc +0 -0
- data/vendor/requests/auth.py +252 -0
- data/vendor/requests/auth.pyc +0 -0
- data/vendor/requests/cacert.pem +5616 -0
- data/vendor/requests/certs.py +25 -0
- data/vendor/requests/certs.pyc +0 -0
- data/vendor/requests/compat.py +66 -0
- data/vendor/requests/compat.pyc +0 -0
- data/vendor/requests/cookies.py +540 -0
- data/vendor/requests/cookies.pyc +0 -0
- data/vendor/requests/exceptions.py +114 -0
- data/vendor/requests/exceptions.pyc +0 -0
- data/vendor/requests/hooks.py +34 -0
- data/vendor/requests/hooks.pyc +0 -0
- data/vendor/requests/models.py +873 -0
- data/vendor/requests/models.pyc +0 -0
- data/vendor/requests/packages/__init__.py +36 -0
- data/vendor/requests/packages/__init__.pyc +0 -0
- data/vendor/requests/packages/chardet/__init__.py +32 -0
- data/vendor/requests/packages/chardet/__init__.pyc +0 -0
- data/vendor/requests/packages/chardet/big5freq.py +925 -0
- data/vendor/requests/packages/chardet/big5freq.pyc +0 -0
- data/vendor/requests/packages/chardet/big5prober.py +42 -0
- data/vendor/requests/packages/chardet/big5prober.pyc +0 -0
- data/vendor/requests/packages/chardet/chardetect.py +80 -0
- data/vendor/requests/packages/chardet/chardetect.pyc +0 -0
- data/vendor/requests/packages/chardet/chardistribution.py +231 -0
- data/vendor/requests/packages/chardet/chardistribution.pyc +0 -0
- data/vendor/requests/packages/chardet/charsetgroupprober.py +106 -0
- data/vendor/requests/packages/chardet/charsetgroupprober.pyc +0 -0
- data/vendor/requests/packages/chardet/charsetprober.py +62 -0
- data/vendor/requests/packages/chardet/charsetprober.pyc +0 -0
- data/vendor/requests/packages/chardet/codingstatemachine.py +61 -0
- data/vendor/requests/packages/chardet/codingstatemachine.pyc +0 -0
- data/vendor/requests/packages/chardet/compat.py +34 -0
- data/vendor/requests/packages/chardet/compat.pyc +0 -0
- data/vendor/requests/packages/chardet/constants.py +39 -0
- data/vendor/requests/packages/chardet/constants.pyc +0 -0
- data/vendor/requests/packages/chardet/cp949prober.py +44 -0
- data/vendor/requests/packages/chardet/cp949prober.pyc +0 -0
- data/vendor/requests/packages/chardet/escprober.py +86 -0
- data/vendor/requests/packages/chardet/escprober.pyc +0 -0
- data/vendor/requests/packages/chardet/escsm.py +242 -0
- data/vendor/requests/packages/chardet/escsm.pyc +0 -0
- data/vendor/requests/packages/chardet/eucjpprober.py +90 -0
- data/vendor/requests/packages/chardet/eucjpprober.pyc +0 -0
- data/vendor/requests/packages/chardet/euckrfreq.py +596 -0
- data/vendor/requests/packages/chardet/euckrfreq.pyc +0 -0
- data/vendor/requests/packages/chardet/euckrprober.py +42 -0
- data/vendor/requests/packages/chardet/euckrprober.pyc +0 -0
- data/vendor/requests/packages/chardet/euctwfreq.py +428 -0
- data/vendor/requests/packages/chardet/euctwfreq.pyc +0 -0
- data/vendor/requests/packages/chardet/euctwprober.py +41 -0
- data/vendor/requests/packages/chardet/euctwprober.pyc +0 -0
- data/vendor/requests/packages/chardet/gb2312freq.py +472 -0
- data/vendor/requests/packages/chardet/gb2312freq.pyc +0 -0
- data/vendor/requests/packages/chardet/gb2312prober.py +41 -0
- data/vendor/requests/packages/chardet/gb2312prober.pyc +0 -0
- data/vendor/requests/packages/chardet/hebrewprober.py +283 -0
- data/vendor/requests/packages/chardet/hebrewprober.pyc +0 -0
- data/vendor/requests/packages/chardet/jisfreq.py +569 -0
- data/vendor/requests/packages/chardet/jisfreq.pyc +0 -0
- data/vendor/requests/packages/chardet/jpcntx.py +227 -0
- data/vendor/requests/packages/chardet/jpcntx.pyc +0 -0
- data/vendor/requests/packages/chardet/langbulgarianmodel.py +229 -0
- data/vendor/requests/packages/chardet/langbulgarianmodel.pyc +0 -0
- data/vendor/requests/packages/chardet/langcyrillicmodel.py +329 -0
- data/vendor/requests/packages/chardet/langcyrillicmodel.pyc +0 -0
- data/vendor/requests/packages/chardet/langgreekmodel.py +225 -0
- data/vendor/requests/packages/chardet/langgreekmodel.pyc +0 -0
- data/vendor/requests/packages/chardet/langhebrewmodel.py +201 -0
- data/vendor/requests/packages/chardet/langhebrewmodel.pyc +0 -0
- data/vendor/requests/packages/chardet/langhungarianmodel.py +225 -0
- data/vendor/requests/packages/chardet/langhungarianmodel.pyc +0 -0
- data/vendor/requests/packages/chardet/langthaimodel.py +200 -0
- data/vendor/requests/packages/chardet/langthaimodel.pyc +0 -0
- data/vendor/requests/packages/chardet/latin1prober.py +139 -0
- data/vendor/requests/packages/chardet/latin1prober.pyc +0 -0
- data/vendor/requests/packages/chardet/mbcharsetprober.py +86 -0
- data/vendor/requests/packages/chardet/mbcharsetprober.pyc +0 -0
- data/vendor/requests/packages/chardet/mbcsgroupprober.py +54 -0
- data/vendor/requests/packages/chardet/mbcsgroupprober.pyc +0 -0
- data/vendor/requests/packages/chardet/mbcssm.py +572 -0
- data/vendor/requests/packages/chardet/mbcssm.pyc +0 -0
- data/vendor/requests/packages/chardet/sbcharsetprober.py +120 -0
- data/vendor/requests/packages/chardet/sbcharsetprober.pyc +0 -0
- data/vendor/requests/packages/chardet/sbcsgroupprober.py +69 -0
- data/vendor/requests/packages/chardet/sbcsgroupprober.pyc +0 -0
- data/vendor/requests/packages/chardet/sjisprober.py +91 -0
- data/vendor/requests/packages/chardet/sjisprober.pyc +0 -0
- data/vendor/requests/packages/chardet/universaldetector.py +170 -0
- data/vendor/requests/packages/chardet/universaldetector.pyc +0 -0
- data/vendor/requests/packages/chardet/utf8prober.py +76 -0
- data/vendor/requests/packages/chardet/utf8prober.pyc +0 -0
- data/vendor/requests/packages/urllib3/__init__.py +96 -0
- data/vendor/requests/packages/urllib3/__init__.pyc +0 -0
- data/vendor/requests/packages/urllib3/_collections.py +324 -0
- data/vendor/requests/packages/urllib3/_collections.pyc +0 -0
- data/vendor/requests/packages/urllib3/connection.py +330 -0
- data/vendor/requests/packages/urllib3/connection.pyc +0 -0
- data/vendor/requests/packages/urllib3/connectionpool.py +866 -0
- data/vendor/requests/packages/urllib3/connectionpool.pyc +0 -0
- data/vendor/requests/packages/urllib3/contrib/__init__.py +0 -0
- data/vendor/requests/packages/urllib3/contrib/__init__.pyc +0 -0
- data/vendor/requests/packages/urllib3/contrib/appengine.py +231 -0
- data/vendor/requests/packages/urllib3/contrib/appengine.pyc +0 -0
- data/vendor/requests/packages/urllib3/contrib/ntlmpool.py +115 -0
- data/vendor/requests/packages/urllib3/contrib/ntlmpool.pyc +0 -0
- data/vendor/requests/packages/urllib3/contrib/pyopenssl.py +358 -0
- data/vendor/requests/packages/urllib3/contrib/pyopenssl.pyc +0 -0
- data/vendor/requests/packages/urllib3/contrib/socks.py +172 -0
- data/vendor/requests/packages/urllib3/contrib/socks.pyc +0 -0
- data/vendor/requests/packages/urllib3/exceptions.py +209 -0
- data/vendor/requests/packages/urllib3/exceptions.pyc +0 -0
- data/vendor/requests/packages/urllib3/fields.py +178 -0
- data/vendor/requests/packages/urllib3/fields.pyc +0 -0
- data/vendor/requests/packages/urllib3/filepost.py +94 -0
- data/vendor/requests/packages/urllib3/filepost.pyc +0 -0
- data/vendor/requests/packages/urllib3/packages/__init__.py +5 -0
- data/vendor/requests/packages/urllib3/packages/__init__.pyc +0 -0
- data/vendor/requests/packages/urllib3/packages/ordered_dict.py +259 -0
- data/vendor/requests/packages/urllib3/packages/ordered_dict.pyc +0 -0
- data/vendor/requests/packages/urllib3/packages/six.py +868 -0
- data/vendor/requests/packages/urllib3/packages/six.pyc +0 -0
- data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py +13 -0
- data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc +0 -0
- data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py +105 -0
- data/vendor/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyc +0 -0
- data/vendor/requests/packages/urllib3/poolmanager.py +367 -0
- data/vendor/requests/packages/urllib3/poolmanager.pyc +0 -0
- data/vendor/requests/packages/urllib3/request.py +151 -0
- data/vendor/requests/packages/urllib3/request.pyc +0 -0
- data/vendor/requests/packages/urllib3/response.py +530 -0
- data/vendor/requests/packages/urllib3/response.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/__init__.py +46 -0
- data/vendor/requests/packages/urllib3/util/__init__.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/connection.py +144 -0
- data/vendor/requests/packages/urllib3/util/connection.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/request.py +72 -0
- data/vendor/requests/packages/urllib3/util/request.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/response.py +74 -0
- data/vendor/requests/packages/urllib3/util/response.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/retry.py +300 -0
- data/vendor/requests/packages/urllib3/util/retry.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/ssl_.py +320 -0
- data/vendor/requests/packages/urllib3/util/ssl_.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/timeout.py +242 -0
- data/vendor/requests/packages/urllib3/util/timeout.pyc +0 -0
- data/vendor/requests/packages/urllib3/util/url.py +217 -0
- data/vendor/requests/packages/urllib3/util/url.pyc +0 -0
- data/vendor/requests/sessions.py +712 -0
- data/vendor/requests/sessions.pyc +0 -0
- data/vendor/requests/status_codes.py +91 -0
- data/vendor/requests/status_codes.pyc +0 -0
- data/vendor/requests/structures.py +105 -0
- data/vendor/requests/structures.pyc +0 -0
- data/vendor/requests/utils.py +817 -0
- data/vendor/requests/utils.pyc +0 -0
- data/vendor/requests-2.11.1.dist-info/DESCRIPTION.rst +1294 -0
- data/vendor/requests-2.11.1.dist-info/INSTALLER +1 -0
- data/vendor/requests-2.11.1.dist-info/METADATA +1323 -0
- data/vendor/requests-2.11.1.dist-info/RECORD +170 -0
- data/vendor/requests-2.11.1.dist-info/WHEEL +6 -0
- data/vendor/requests-2.11.1.dist-info/metadata.json +1 -0
- data/vendor/requests-2.11.1.dist-info/top_level.txt +1 -0
- data/vendor/rigid/__init__.py +1 -0
- data/vendor/rigid/__init__.pyc +0 -0
- data/vendor/rigid/api.py +129 -0
- data/vendor/rigid/api.pyc +0 -0
- data/vendor/rigid/commands/__init__.py +260 -0
- data/vendor/rigid/commands/__init__.pyc +0 -0
- data/vendor/rigid/commands/deploy.py +0 -0
- data/vendor/rigid/commands/deploy.pyc +0 -0
- data/vendor/rigid/deploy.py +70 -0
- data/vendor/rigid/deploy.pyc +0 -0
- data/vendor/rigid/file_scanner.py +63 -0
- data/vendor/rigid/file_scanner.pyc +0 -0
- data/vendor/rigid/utils.py +17 -0
- data/vendor/rigid/utils.pyc +0 -0
- data/vendor/rigid-0.2.0.dist-info/DESCRIPTION.rst +3 -0
- data/vendor/rigid-0.2.0.dist-info/INSTALLER +1 -0
- data/vendor/rigid-0.2.0.dist-info/METADATA +23 -0
- data/vendor/rigid-0.2.0.dist-info/RECORD +49 -0
- data/vendor/rigid-0.2.0.dist-info/WHEEL +5 -0
- data/vendor/rigid-0.2.0.dist-info/entry_points.txt +3 -0
- data/vendor/rigid-0.2.0.dist-info/metadata.json +1 -0
- data/vendor/rigid-0.2.0.dist-info/top_level.txt +2 -0
- data/vendor/setuptools-28.8.0.dist-info/DESCRIPTION.rst +243 -0
- data/vendor/setuptools-28.8.0.dist-info/INSTALLER +1 -0
- data/vendor/setuptools-28.8.0.dist-info/METADATA +272 -0
- data/vendor/setuptools-28.8.0.dist-info/RECORD +143 -0
- data/vendor/setuptools-28.8.0.dist-info/WHEEL +6 -0
- data/vendor/setuptools-28.8.0.dist-info/dependency_links.txt +2 -0
- data/vendor/setuptools-28.8.0.dist-info/entry_points.txt +63 -0
- data/vendor/setuptools-28.8.0.dist-info/metadata.json +1 -0
- data/vendor/setuptools-28.8.0.dist-info/top_level.txt +3 -0
- data/vendor/setuptools-28.8.0.dist-info/zip-safe +1 -0
- data/vendor/tests/__init__.py +0 -0
- data/vendor/tests/__init__.pyc +0 -0
- data/vendor/tests/integration/__init__.py +0 -0
- data/vendor/tests/integration/__init__.pyc +0 -0
- data/vendor/tests/integration/test_app.py +63 -0
- data/vendor/tests/integration/test_app.pyc +0 -0
- data/vendor/tests/integration/test_apps.py +27 -0
- data/vendor/tests/integration/test_apps.pyc +0 -0
- data/vendor/tests/integration/test_deploy.py +128 -0
- data/vendor/tests/integration/test_deploy.pyc +0 -0
- data/vendor/tests/integration/test_domains.py +35 -0
- data/vendor/tests/integration/test_domains.pyc +0 -0
- data/vendor/tests/integration/test_login.py +37 -0
- data/vendor/tests/integration/test_login.pyc +0 -0
- data/vendor/tests/integration/test_promote.py +24 -0
- data/vendor/tests/integration/test_promote.pyc +0 -0
- data/vendor/tests/integration/test_token.py +33 -0
- data/vendor/tests/integration/test_token.pyc +0 -0
- data/vendor/tests/integration/test_whoami.py +24 -0
- data/vendor/tests/integration/test_whoami.pyc +0 -0
- data/vendor/tests/test_deploy.py +33 -0
- data/vendor/tests/test_deploy.pyc +0 -0
- data/vendor/tests/test_file_scanner.py +89 -0
- data/vendor/tests/test_file_scanner.pyc +0 -0
- data/vendor/tests/utils.py +78 -0
- data/vendor/tests/utils.pyc +0 -0
- data/vendor/wheel-0.30.0a0.dist-info/DESCRIPTION.rst +325 -0
- data/vendor/wheel-0.30.0a0.dist-info/INSTALLER +1 -0
- data/vendor/wheel-0.30.0a0.dist-info/LICENSE.txt +22 -0
- data/vendor/wheel-0.30.0a0.dist-info/METADATA +357 -0
- data/vendor/wheel-0.30.0a0.dist-info/RECORD +86 -0
- data/vendor/wheel-0.30.0a0.dist-info/WHEEL +6 -0
- data/vendor/wheel-0.30.0a0.dist-info/entry_points.txt +6 -0
- data/vendor/wheel-0.30.0a0.dist-info/metadata.json +1 -0
- data/vendor/wheel-0.30.0a0.dist-info/top_level.txt +1 -0
- data/vendor/yaml/__init__.py +315 -0
- data/vendor/yaml/__init__.pyc +0 -0
- data/vendor/yaml/composer.py +139 -0
- data/vendor/yaml/composer.pyc +0 -0
- data/vendor/yaml/constructor.py +675 -0
- data/vendor/yaml/constructor.pyc +0 -0
- data/vendor/yaml/cyaml.py +85 -0
- data/vendor/yaml/cyaml.pyc +0 -0
- data/vendor/yaml/dumper.py +62 -0
- data/vendor/yaml/dumper.pyc +0 -0
- data/vendor/yaml/emitter.py +1140 -0
- data/vendor/yaml/emitter.pyc +0 -0
- data/vendor/yaml/error.py +75 -0
- data/vendor/yaml/error.pyc +0 -0
- data/vendor/yaml/events.py +86 -0
- data/vendor/yaml/events.pyc +0 -0
- data/vendor/yaml/loader.py +40 -0
- data/vendor/yaml/loader.pyc +0 -0
- data/vendor/yaml/nodes.py +49 -0
- data/vendor/yaml/nodes.pyc +0 -0
- data/vendor/yaml/parser.py +589 -0
- data/vendor/yaml/parser.pyc +0 -0
- data/vendor/yaml/reader.py +190 -0
- data/vendor/yaml/reader.pyc +0 -0
- data/vendor/yaml/representer.py +486 -0
- data/vendor/yaml/representer.pyc +0 -0
- data/vendor/yaml/resolver.py +227 -0
- data/vendor/yaml/resolver.pyc +0 -0
- data/vendor/yaml/scanner.py +1453 -0
- data/vendor/yaml/scanner.pyc +0 -0
- data/vendor/yaml/serializer.py +111 -0
- data/vendor/yaml/serializer.pyc +0 -0
- data/vendor/yaml/tokens.py +104 -0
- data/vendor/yaml/tokens.pyc +0 -0
- 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, ''))
|