comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/requests/compat.py @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
1 """
2 requests.compat
3 ~~~~~~~~~~~~~~~
4
5 This module previously handled import compatibility issues
6 between Python 2 and Python 3. It remains for backwards
7 compatibility until the next major version.
8 """
9
10 import importlib
11 import sys
12
13 # -------------------
14 # Character Detection
15 # -------------------
16
17
18 def _resolve_char_detection():
19 """Find supported character detection libraries."""
20 chardet = None
21 for lib in ("chardet", "charset_normalizer"):
22 if chardet is None:
23 try:
24 chardet = importlib.import_module(lib)
25 except ImportError:
26 pass
27 return chardet
28
29
30 chardet = _resolve_char_detection()
31
32 # -------
33 # Pythons
34 # -------
35
36 # Syntax sugar.
37 _ver = sys.version_info
38
39 #: Python 2.x?
40 is_py2 = _ver[0] == 2
41
42 #: Python 3.x?
43 is_py3 = _ver[0] == 3
44
45 # json/simplejson module import resolution
46 has_simplejson = False
47 try:
48 import simplejson as json
49
50 has_simplejson = True
51 except ImportError:
52 import json
53
54 if has_simplejson:
55 from simplejson import JSONDecodeError
56 else:
57 from json import JSONDecodeError
58
59 # Keep OrderedDict for backwards compatibility.
60 from collections import OrderedDict
61 from collections.abc import Callable, Mapping, MutableMapping
62 from http import cookiejar as cookielib
63 from http.cookies import Morsel
64 from io import StringIO
65
66 # --------------
67 # Legacy Imports
68 # --------------
69 from urllib.parse import (
70 quote,
71 quote_plus,
72 unquote,
73 unquote_plus,
74 urldefrag,
75 urlencode,
76 urljoin,
77 urlparse,
78 urlsplit,
79 urlunparse,
80 )
81 from urllib.request import (
82 getproxies,
83 getproxies_environment,
84 parse_http_list,
85 proxy_bypass,
86 proxy_bypass_environment,
87 )
88
89 builtin_str = str
90 str = str
91 bytes = bytes
92 basestring = (str, bytes)
93 numeric_types = (int, float)
94 integer_types = (int,)