blob: bb7405a880f61c728a262b6b9162d2b338fcba68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# -*- coding: utf-8 -*-
import sys
import six
from six import PY3
from six import text_type
from six.moves import http_cookies
SimpleCookie = http_cookies.SimpleCookie
CookieError = http_cookies.CookieError
def to_bytes(value, charset='latin1'):
if isinstance(value, text_type):
return value.encode(charset)
return value
if PY3: # pragma: no cover
from html.entities import name2codepoint
from urllib.parse import urlencode
from urllib.parse import splittype
from urllib.parse import splithost
import urllib.parse as urlparse
else: # pragma: no cover
from htmlentitydefs import name2codepoint # noqa
from urllib import splittype # noqa
from urllib import splithost # noqa
from urllib import urlencode # noqa
import urlparse # noqa
def print_stderr(value):
if not PY3:
if isinstance(value, text_type):
value = value.encode('utf8')
six.print_(value, file=sys.stderr)
try:
from collections import OrderedDict
except ImportError: # pragma: no cover
from ordereddict import OrderedDict # noqa
|