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/help.py |
First commit
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/help.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/help.py | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/help.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/help.py new file mode 100644 index 0000000..28385f8 --- /dev/null +++ b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/requests/help.py | |||
@@ -0,0 +1,120 @@ | |||
1 | """Module containing bug report helper(s).""" | ||
2 | from __future__ import print_function | ||
3 | |||
4 | import json | ||
5 | import platform | ||
6 | import sys | ||
7 | import ssl | ||
8 | |||
9 | from pip._vendor import idna | ||
10 | from pip._vendor import urllib3 | ||
11 | from pip._vendor import chardet | ||
12 | |||
13 | from . import __version__ as requests_version | ||
14 | |||
15 | try: | ||
16 | from .packages.urllib3.contrib import pyopenssl | ||
17 | except ImportError: | ||
18 | pyopenssl = None | ||
19 | OpenSSL = None | ||
20 | cryptography = None | ||
21 | else: | ||
22 | import OpenSSL | ||
23 | import cryptography | ||
24 | |||
25 | |||
26 | def _implementation(): | ||
27 | """Return a dict with the Python implementation and version. | ||
28 | |||
29 | Provide both the name and the version of the Python implementation | ||
30 | currently running. For example, on CPython 2.7.5 it will return | ||
31 | {'name': 'CPython', 'version': '2.7.5'}. | ||
32 | |||
33 | This function works best on CPython and PyPy: in particular, it probably | ||
34 | doesn't work for Jython or IronPython. Future investigation should be done | ||
35 | to work out the correct shape of the code for those platforms. | ||
36 | """ | ||
37 | implementation = platform.python_implementation() | ||
38 | |||
39 | if implementation == 'CPython': | ||
40 | implementation_version = platform.python_version() | ||
41 | elif implementation == 'PyPy': | ||
42 | implementation_version = '%s.%s.%s' % (sys.pypy_version_info.major, | ||
43 | sys.pypy_version_info.minor, | ||
44 | sys.pypy_version_info.micro) | ||
45 | if sys.pypy_version_info.releaselevel != 'final': | ||
46 | implementation_version = ''.join([ | ||
47 | implementation_version, sys.pypy_version_info.releaselevel | ||
48 | ]) | ||
49 | elif implementation == 'Jython': | ||
50 | implementation_version = platform.python_version() # Complete Guess | ||
51 | elif implementation == 'IronPython': | ||
52 | implementation_version = platform.python_version() # Complete Guess | ||
53 | else: | ||
54 | implementation_version = 'Unknown' | ||
55 | |||
56 | return {'name': implementation, 'version': implementation_version} | ||
57 | |||
58 | |||
59 | def info(): | ||
60 | """Generate information for a bug report.""" | ||
61 | try: | ||
62 | platform_info = { | ||
63 | 'system': platform.system(), | ||
64 | 'release': platform.release(), | ||
65 | } | ||
66 | except IOError: | ||
67 | platform_info = { | ||
68 | 'system': 'Unknown', | ||
69 | 'release': 'Unknown', | ||
70 | } | ||
71 | |||
72 | implementation_info = _implementation() | ||
73 | urllib3_info = {'version': urllib3.__version__} | ||
74 | chardet_info = {'version': chardet.__version__} | ||
75 | |||
76 | pyopenssl_info = { | ||
77 | 'version': None, | ||
78 | 'openssl_version': '', | ||
79 | } | ||
80 | if OpenSSL: | ||
81 | pyopenssl_info = { | ||
82 | 'version': OpenSSL.__version__, | ||
83 | 'openssl_version': '%x' % OpenSSL.SSL.OPENSSL_VERSION_NUMBER, | ||
84 | } | ||
85 | cryptography_info = { | ||
86 | 'version': getattr(cryptography, '__version__', ''), | ||
87 | } | ||
88 | idna_info = { | ||
89 | 'version': getattr(idna, '__version__', ''), | ||
90 | } | ||
91 | |||
92 | # OPENSSL_VERSION_NUMBER doesn't exist in the Python 2.6 ssl module. | ||
93 | system_ssl = getattr(ssl, 'OPENSSL_VERSION_NUMBER', None) | ||
94 | system_ssl_info = { | ||
95 | 'version': '%x' % system_ssl if system_ssl is not None else '' | ||
96 | } | ||
97 | |||
98 | return { | ||
99 | 'platform': platform_info, | ||
100 | 'implementation': implementation_info, | ||
101 | 'system_ssl': system_ssl_info, | ||
102 | 'using_pyopenssl': pyopenssl is not None, | ||
103 | 'pyOpenSSL': pyopenssl_info, | ||
104 | 'urllib3': urllib3_info, | ||
105 | 'chardet': chardet_info, | ||
106 | 'cryptography': cryptography_info, | ||
107 | 'idna': idna_info, | ||
108 | 'requests': { | ||
109 | 'version': requests_version, | ||
110 | }, | ||
111 | } | ||
112 | |||
113 | |||
114 | def main(): | ||
115 | """Pretty-print the bug information as JSON.""" | ||
116 | print(json.dumps(info(), sort_keys=True, indent=2)) | ||
117 | |||
118 | |||
119 | if __name__ == '__main__': | ||
120 | main() | ||