comparison requests/packages.py @ 7:5eb2d5e3bf22

planemo upload for repository https://toolrepo.galaxytrakr.org/view/jpayne/bioproject_to_srr_2/556cac4fb538
author jpayne
date Sun, 05 May 2024 23:32:17 -0400
parents
children
comparison
equal deleted inserted replaced
6:b2745907b1eb 7:5eb2d5e3bf22
1 import sys
2
3 try:
4 import chardet
5 except ImportError:
6 import warnings
7
8 import charset_normalizer as chardet
9
10 warnings.filterwarnings("ignore", "Trying to detect", module="charset_normalizer")
11
12 # This code exists for backwards compatibility reasons.
13 # I don't like it either. Just look the other way. :)
14
15 for package in ("urllib3", "idna"):
16 locals()[package] = __import__(package)
17 # This traversal is apparently necessary such that the identities are
18 # preserved (requests.packages.urllib3.* is urllib3.*)
19 for mod in list(sys.modules):
20 if mod == package or mod.startswith(f"{package}."):
21 sys.modules[f"requests.packages.{mod}"] = sys.modules[mod]
22
23 target = chardet.__name__
24 for mod in list(sys.modules):
25 if mod == target or mod.startswith(f"{target}."):
26 target = target.replace(target, "chardet")
27 sys.modules[f"requests.packages.{target}"] = sys.modules[mod]
28 # Kinda cool, though, right?