Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/urllib3/__init__.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d30785e31577 | 1:56ad4e20f292 |
---|---|
1 """ | |
2 urllib3 - Thread-safe connection pooling and re-using. | |
3 """ | |
4 from __future__ import absolute_import | |
5 import warnings | |
6 | |
7 from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url | |
8 | |
9 from . import exceptions | |
10 from .filepost import encode_multipart_formdata | |
11 from .poolmanager import PoolManager, ProxyManager, proxy_from_url | |
12 from .response import HTTPResponse | |
13 from .util.request import make_headers | |
14 from .util.url import get_host | |
15 from .util.timeout import Timeout | |
16 from .util.retry import Retry | |
17 from ._version import __version__ | |
18 | |
19 | |
20 # Set default logging handler to avoid "No handler found" warnings. | |
21 import logging | |
22 from logging import NullHandler | |
23 | |
24 __author__ = "Andrey Petrov (andrey.petrov@shazow.net)" | |
25 __license__ = "MIT" | |
26 __version__ = __version__ | |
27 | |
28 __all__ = ( | |
29 "HTTPConnectionPool", | |
30 "HTTPSConnectionPool", | |
31 "PoolManager", | |
32 "ProxyManager", | |
33 "HTTPResponse", | |
34 "Retry", | |
35 "Timeout", | |
36 "add_stderr_logger", | |
37 "connection_from_url", | |
38 "disable_warnings", | |
39 "encode_multipart_formdata", | |
40 "get_host", | |
41 "make_headers", | |
42 "proxy_from_url", | |
43 ) | |
44 | |
45 logging.getLogger(__name__).addHandler(NullHandler()) | |
46 | |
47 | |
48 def add_stderr_logger(level=logging.DEBUG): | |
49 """ | |
50 Helper for quickly adding a StreamHandler to the logger. Useful for | |
51 debugging. | |
52 | |
53 Returns the handler after adding it. | |
54 """ | |
55 # This method needs to be in this __init__.py to get the __name__ correct | |
56 # even if urllib3 is vendored within another package. | |
57 logger = logging.getLogger(__name__) | |
58 handler = logging.StreamHandler() | |
59 handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s")) | |
60 logger.addHandler(handler) | |
61 logger.setLevel(level) | |
62 logger.debug("Added a stderr logging handler to logger: %s", __name__) | |
63 return handler | |
64 | |
65 | |
66 # ... Clean up. | |
67 del NullHandler | |
68 | |
69 | |
70 # All warning filters *must* be appended unless you're really certain that they | |
71 # shouldn't be: otherwise, it's very hard for users to use most Python | |
72 # mechanisms to silence them. | |
73 # SecurityWarning's always go off by default. | |
74 warnings.simplefilter("always", exceptions.SecurityWarning, append=True) | |
75 # SubjectAltNameWarning's should go off once per host | |
76 warnings.simplefilter("default", exceptions.SubjectAltNameWarning, append=True) | |
77 # InsecurePlatformWarning's don't vary between requests, so we keep it default. | |
78 warnings.simplefilter("default", exceptions.InsecurePlatformWarning, append=True) | |
79 # SNIMissingWarnings should go off only once. | |
80 warnings.simplefilter("default", exceptions.SNIMissingWarning, append=True) | |
81 | |
82 | |
83 def disable_warnings(category=exceptions.HTTPWarning): | |
84 """ | |
85 Helper for quickly disabling all urllib3 warnings. | |
86 """ | |
87 warnings.simplefilter("ignore", category) |