Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/requests/__init__.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author | shellac |
---|---|
date | Mon, 01 Jun 2020 08:59:25 -0400 |
parents | 79f47841a781 |
children |
comparison
equal
deleted
inserted
replaced
4:79f47841a781 | 5:9b1c78e6ba9c |
---|---|
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. | |
13 Basic GET usage: | |
14 | |
15 >>> import requests | |
16 >>> r = requests.get('https://www.python.org') | |
17 >>> r.status_code | |
18 200 | |
19 >>> b'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('https://httpbin.org/post', data=payload) | |
26 >>> print(r.text) | |
27 { | |
28 ... | |
29 "form": { | |
30 "key1": "value1", | |
31 "key2": "value2" | |
32 }, | |
33 ... | |
34 } | |
35 | |
36 The other HTTP methods are supported - see `requests.api`. Full documentation | |
37 is at <https://requests.readthedocs.io>. | |
38 | |
39 :copyright: (c) 2017 by Kenneth Reitz. | |
40 :license: Apache 2.0, see LICENSE for more details. | |
41 """ | |
42 | |
43 import urllib3 | |
44 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.25 | |
61 assert major == 1 | |
62 assert minor >= 21 | |
63 assert minor <= 25 | |
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 def _check_cryptography(cryptography_version): | |
75 # cryptography < 1.3.4 | |
76 try: | |
77 cryptography_version = list(map(int, cryptography_version.split('.'))) | |
78 except ValueError: | |
79 return | |
80 | |
81 if cryptography_version < [1, 3, 4]: | |
82 warning = 'Old version of cryptography ({}) may cause slowdown.'.format(cryptography_version) | |
83 warnings.warn(warning, RequestsDependencyWarning) | |
84 | |
85 # Check imported dependencies for compatibility. | |
86 try: | |
87 check_compatibility(urllib3.__version__, chardet.__version__) | |
88 except (AssertionError, ValueError): | |
89 warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported " | |
90 "version!".format(urllib3.__version__, chardet.__version__), | |
91 RequestsDependencyWarning) | |
92 | |
93 # Attempt to enable urllib3's SNI support, if possible | |
94 try: | |
95 from urllib3.contrib import pyopenssl | |
96 pyopenssl.inject_into_urllib3() | |
97 | |
98 # Check cryptography version | |
99 from cryptography import __version__ as cryptography_version | |
100 _check_cryptography(cryptography_version) | |
101 except ImportError: | |
102 pass | |
103 | |
104 # urllib3's DependencyWarnings should be silenced. | |
105 from urllib3.exceptions import DependencyWarning | |
106 warnings.simplefilter('ignore', DependencyWarning) | |
107 | |
108 from .__version__ import __title__, __description__, __url__, __version__ | |
109 from .__version__ import __build__, __author__, __author_email__, __license__ | |
110 from .__version__ import __copyright__, __cake__ | |
111 | |
112 from . import utils | |
113 from . import packages | |
114 from .models import Request, Response, PreparedRequest | |
115 from .api import request, get, head, post, patch, put, delete, options | |
116 from .sessions import session, Session | |
117 from .status_codes import codes | |
118 from .exceptions import ( | |
119 RequestException, Timeout, URLRequired, | |
120 TooManyRedirects, HTTPError, ConnectionError, | |
121 FileModeWarning, ConnectTimeout, ReadTimeout | |
122 ) | |
123 | |
124 # Set default logging handler to avoid "No handler found" warnings. | |
125 import logging | |
126 from logging import NullHandler | |
127 | |
128 logging.getLogger(__name__).addHandler(NullHandler()) | |
129 | |
130 # FileModeWarnings go off per the default. | |
131 warnings.simplefilter('default', FileModeWarning, append=True) |