annotate requests/compat.py @ 10:ccec96a537b7

planemo upload for repository https://toolrepo.galaxytrakr.org/view/jpayne/bioproject_to_srr_2/556cac4fb538
author jpayne
date Mon, 06 May 2024 00:12:39 -0400
parents 5eb2d5e3bf22
children
rev   line source
jpayne@7 1 """
jpayne@7 2 requests.compat
jpayne@7 3 ~~~~~~~~~~~~~~~
jpayne@7 4
jpayne@7 5 This module previously handled import compatibility issues
jpayne@7 6 between Python 2 and Python 3. It remains for backwards
jpayne@7 7 compatibility until the next major version.
jpayne@7 8 """
jpayne@7 9
jpayne@7 10 try:
jpayne@7 11 import chardet
jpayne@7 12 except ImportError:
jpayne@7 13 import charset_normalizer as chardet
jpayne@7 14
jpayne@7 15 import sys
jpayne@7 16
jpayne@7 17 # -------
jpayne@7 18 # Pythons
jpayne@7 19 # -------
jpayne@7 20
jpayne@7 21 # Syntax sugar.
jpayne@7 22 _ver = sys.version_info
jpayne@7 23
jpayne@7 24 #: Python 2.x?
jpayne@7 25 is_py2 = _ver[0] == 2
jpayne@7 26
jpayne@7 27 #: Python 3.x?
jpayne@7 28 is_py3 = _ver[0] == 3
jpayne@7 29
jpayne@7 30 # json/simplejson module import resolution
jpayne@7 31 has_simplejson = False
jpayne@7 32 try:
jpayne@7 33 import simplejson as json
jpayne@7 34
jpayne@7 35 has_simplejson = True
jpayne@7 36 except ImportError:
jpayne@7 37 import json
jpayne@7 38
jpayne@7 39 if has_simplejson:
jpayne@7 40 from simplejson import JSONDecodeError
jpayne@7 41 else:
jpayne@7 42 from json import JSONDecodeError
jpayne@7 43
jpayne@7 44 # Keep OrderedDict for backwards compatibility.
jpayne@7 45 from collections import OrderedDict
jpayne@7 46 from collections.abc import Callable, Mapping, MutableMapping
jpayne@7 47 from http import cookiejar as cookielib
jpayne@7 48 from http.cookies import Morsel
jpayne@7 49 from io import StringIO
jpayne@7 50
jpayne@7 51 # --------------
jpayne@7 52 # Legacy Imports
jpayne@7 53 # --------------
jpayne@7 54 from urllib.parse import (
jpayne@7 55 quote,
jpayne@7 56 quote_plus,
jpayne@7 57 unquote,
jpayne@7 58 unquote_plus,
jpayne@7 59 urldefrag,
jpayne@7 60 urlencode,
jpayne@7 61 urljoin,
jpayne@7 62 urlparse,
jpayne@7 63 urlsplit,
jpayne@7 64 urlunparse,
jpayne@7 65 )
jpayne@7 66 from urllib.request import (
jpayne@7 67 getproxies,
jpayne@7 68 getproxies_environment,
jpayne@7 69 parse_http_list,
jpayne@7 70 proxy_bypass,
jpayne@7 71 proxy_bypass_environment,
jpayne@7 72 )
jpayne@7 73
jpayne@7 74 builtin_str = str
jpayne@7 75 str = str
jpayne@7 76 bytes = bytes
jpayne@7 77 basestring = (str, bytes)
jpayne@7 78 numeric_types = (int, float)
jpayne@7 79 integer_types = (int,)