diff options
author | Shubham Saini <shubham6405@gmail.com> | 2018-12-11 10:01:23 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2018-12-11 10:01:23 +0000 |
commit | 68df54d6629ec019142eb149dd037774f2d11e7c (patch) | |
tree | 345bc22d46b4e01a4ba8303b94278952a4ed2b9e /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/__init__.py |
First commit
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/__init__.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/__init__.py | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/__init__.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/__init__.py new file mode 100644 index 0000000..f9565cb --- /dev/null +++ b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/__init__.py | |||
@@ -0,0 +1,123 @@ | |||
1 | # -*- coding: utf-8 -*- | ||
2 | |||
3 | # __ | ||
4 | # /__) _ _ _ _ _/ _ | ||
5 | # / ( (- (/ (/ (- _) / _) | ||
6 | # / | ||
7 | |||
8 | """ | ||
9 | Requests HTTP Library | ||
10 | ~~~~~~~~~~~~~~~~~~~~~ | ||
11 | |||
12 | Requests is an HTTP library, written in Python, for human beings. Basic GET | ||
13 | usage: | ||
14 | |||
15 | >>> import requests | ||
16 | >>> r = requests.get('https://www.python.org') | ||
17 | >>> r.status_code | ||
18 | 200 | ||
19 | >>> 'Python is a programming language' in r.content | ||
20 | True | ||
21 | |||
22 | ... or POST: | ||
23 | |||
24 | >>> payload = dict(key1='value1', key2='value2') | ||
25 | >>> r = requests.post('http://httpbin.org/post', data=payload) | ||
26 | >>> print(r.text) | ||
27 | { | ||
28 | ... | ||
29 | "form": { | ||
30 | "key2": "value2", | ||
31 | "key1": "value1" | ||
32 | }, | ||
33 | ... | ||
34 | } | ||
35 | |||
36 | The other HTTP methods are supported - see `requests.api`. Full documentation | ||
37 | is at <http://python-requests.org>. | ||
38 | |||
39 | :copyright: (c) 2017 by Kenneth Reitz. | ||
40 | :license: Apache 2.0, see LICENSE for more details. | ||
41 | """ | ||
42 | |||
43 | from pip._vendor import urllib3 | ||
44 | from pip._vendor import chardet | ||
45 | import warnings | ||
46 | from .exceptions import RequestsDependencyWarning | ||
47 | |||
48 | |||
49 | def check_compatibility(urllib3_version, chardet_version): | ||
50 | urllib3_version = urllib3_version.split('.') | ||
51 | assert urllib3_version != ['dev'] # Verify urllib3 isn't installed from git. | ||
52 | |||
53 | # Sometimes, urllib3 only reports its version as 16.1. | ||
54 | if len(urllib3_version) == 2: | ||
55 | urllib3_version.append('0') | ||
56 | |||
57 | # Check urllib3 for compatibility. | ||
58 | major, minor, patch = urllib3_version # noqa: F811 | ||
59 | major, minor, patch = int(major), int(minor), int(patch) | ||
60 | # urllib3 >= 1.21.1, <= 1.22 | ||
61 | assert major == 1 | ||
62 | assert minor >= 21 | ||
63 | assert minor <= 22 | ||
64 | |||
65 | # Check chardet for compatibility. | ||
66 | major, minor, patch = chardet_version.split('.')[:3] | ||
67 | major, minor, patch = int(major), int(minor), int(patch) | ||
68 | # chardet >= 3.0.2, < 3.1.0 | ||
69 | assert major == 3 | ||
70 | assert minor < 1 | ||
71 | assert patch >= 2 | ||
72 | |||
73 | |||
74 | # Check imported dependencies for compatibility. | ||
75 | try: | ||
76 | check_compatibility(urllib3.__version__, chardet.__version__) | ||
77 | except (AssertionError, ValueError): | ||
78 | warnings.warn("urllib3 ({0}) or chardet ({1}) doesn't match a supported " | ||
79 | "version!".format(urllib3.__version__, chardet.__version__), | ||
80 | RequestsDependencyWarning) | ||
81 | |||
82 | # Attempt to enable urllib3's SNI support, if possible | ||
83 | from pip._internal.compat import WINDOWS | ||
84 | if not WINDOWS: | ||
85 | try: | ||
86 | from pip._vendor.urllib3.contrib import pyopenssl | ||
87 | pyopenssl.inject_into_urllib3() | ||
88 | except ImportError: | ||
89 | pass | ||
90 | |||
91 | # urllib3's DependencyWarnings should be silenced. | ||
92 | from pip._vendor.urllib3.exceptions import DependencyWarning | ||
93 | warnings.simplefilter('ignore', DependencyWarning) | ||
94 | |||
95 | from .__version__ import __title__, __description__, __url__, __version__ | ||
96 | from .__version__ import __build__, __author__, __author_email__, __license__ | ||
97 | from .__version__ import __copyright__, __cake__ | ||
98 | |||
99 | from . import utils | ||
100 | from . import packages | ||
101 | from .models import Request, Response, PreparedRequest | ||
102 | from .api import request, get, head, post, patch, put, delete, options | ||
103 | from .sessions import session, Session | ||
104 | from .status_codes import codes | ||
105 | from .exceptions import ( | ||
106 | RequestException, Timeout, URLRequired, | ||
107 | TooManyRedirects, HTTPError, ConnectionError, | ||
108 | FileModeWarning, ConnectTimeout, ReadTimeout | ||
109 | ) | ||
110 | |||
111 | # Set default logging handler to avoid "No handler found" warnings. | ||
112 | import logging | ||
113 | try: # Python 2.7+ | ||
114 | from logging import NullHandler | ||
115 | except ImportError: | ||
116 | class NullHandler(logging.Handler): | ||
117 | def emit(self, record): | ||
118 | pass | ||
119 | |||
120 | logging.getLogger(__name__).addHandler(NullHandler()) | ||
121 | |||
122 | # FileModeWarnings go off per the default. | ||
123 | warnings.simplefilter('default', FileModeWarning, append=True) | ||