File: _compat.py

package info (click to toggle)
python-vega-datasets 0.8%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,112 kB
  • sloc: python: 625; makefile: 21
file content (19 lines) | stat: -rw-r--r-- 494 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# flake8: noqa

try:
    from urllib.error import URLError, HTTPError
    from urllib.request import urlopen, urlretrieve
    from io import BytesIO

    def bytes_decode(bytes_, encoding="utf-8"):
        return bytes_.decode(encoding)


except ImportError:  # noqa: F401
    # Python 2.X
    from urllib2 import URLError, HTTPError, urlopen
    from urllib import urlretrieve
    from StringIO import StringIO as BytesIO

    def bytes_decode(bytes_, encoding="utf-8"):
        return bytes_