Plex plugin to to play various online streams (mostly Latvian).

__init__.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536
  1. '''
  2. Debian and other distributions "unbundle" requests' vendored dependencies, and
  3. rewrite all imports to use the global versions of ``urllib3`` and ``chardet``.
  4. The problem with this is that not only requests itself imports those
  5. dependencies, but third-party code outside of the distros' control too.
  6. In reaction to these problems, the distro maintainers replaced
  7. ``requests.packages`` with a magical "stub module" that imports the correct
  8. modules. The implementations were varying in quality and all had severe
  9. problems. For example, a symlink (or hardlink) that links the correct modules
  10. into place introduces problems regarding object identity, since you now have
  11. two modules in `sys.modules` with the same API, but different identities::
  12. requests.packages.urllib3 is not urllib3
  13. With version ``2.5.2``, requests started to maintain its own stub, so that
  14. distro-specific breakage would be reduced to a minimum, even though the whole
  15. issue is not requests' fault in the first place. See
  16. https://github.com/kennethreitz/requests/pull/2375 for the corresponding pull
  17. request.
  18. '''
  19. from __future__ import absolute_import
  20. import sys
  21. try:
  22. from . import urllib3
  23. except ImportError:
  24. import urllib3
  25. sys.modules['%s.urllib3' % __name__] = urllib3
  26. try:
  27. from . import chardet
  28. except ImportError:
  29. import chardet
  30. sys.modules['%s.chardet' % __name__] = chardet