mirror of
https://github.com/SickGear/SickGear.git
synced 2024-11-15 17:35:04 +00:00
23 lines
904 B
Python
23 lines
904 B
Python
import sys
|
|
|
|
from .compat import chardet
|
|
|
|
# This code exists for backwards compatibility reasons.
|
|
# I don't like it either. Just look the other way. :)
|
|
|
|
for package in ("urllib3", "idna"):
|
|
locals()[package] = __import__(package)
|
|
# This traversal is apparently necessary such that the identities are
|
|
# preserved (requests.packages.urllib3.* is urllib3.*)
|
|
for mod in list(sys.modules):
|
|
if mod == package or mod.startswith(f"{package}."):
|
|
sys.modules[f"requests.packages.{mod}"] = sys.modules[mod]
|
|
|
|
if chardet is not None:
|
|
target = chardet.__name__
|
|
for mod in list(sys.modules):
|
|
if mod == target or mod.startswith(f"{target}."):
|
|
imported_mod = sys.modules[mod]
|
|
sys.modules[f"requests.packages.{mod}"] = imported_mod
|
|
mod = mod.replace(target, "chardet")
|
|
sys.modules[f"requests.packages.{mod}"] = imported_mod
|