comparison env/lib/python3.7/site-packages/requests/compat.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 # -*- coding: utf-8 -*-
2
3 """
4 requests.compat
5 ~~~~~~~~~~~~~~~
6
7 This module handles import compatibility issues between Python 2 and
8 Python 3.
9 """
10
11 import chardet
12
13 import sys
14
15 # -------
16 # Pythons
17 # -------
18
19 # Syntax sugar.
20 _ver = sys.version_info
21
22 #: Python 2.x?
23 is_py2 = (_ver[0] == 2)
24
25 #: Python 3.x?
26 is_py3 = (_ver[0] == 3)
27
28 try:
29 import simplejson as json
30 except ImportError:
31 import json
32
33 # ---------
34 # Specifics
35 # ---------
36
37 if is_py2:
38 from urllib import (
39 quote, unquote, quote_plus, unquote_plus, urlencode, getproxies,
40 proxy_bypass, proxy_bypass_environment, getproxies_environment)
41 from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
42 from urllib2 import parse_http_list
43 import cookielib
44 from Cookie import Morsel
45 from StringIO import StringIO
46 # Keep OrderedDict for backwards compatibility.
47 from collections import Callable, Mapping, MutableMapping, OrderedDict
48
49
50 builtin_str = str
51 bytes = str
52 str = unicode
53 basestring = basestring
54 numeric_types = (int, long, float)
55 integer_types = (int, long)
56
57 elif is_py3:
58 from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag
59 from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment
60 from http import cookiejar as cookielib
61 from http.cookies import Morsel
62 from io import StringIO
63 # Keep OrderedDict for backwards compatibility.
64 from collections import OrderedDict
65 from collections.abc import Callable, Mapping, MutableMapping
66
67 builtin_str = str
68 str = str
69 bytes = bytes
70 basestring = (str, bytes)
71 numeric_types = (int, float)
72 integer_types = (int,)