Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: third_party/google-endpoints/requests/compat.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # -*- coding: utf-8 -*-
2
3 """
4 requests.compat
5 ~~~~~~~~~~~~~~~
6
7 This module handles import compatibility issues between Python 2 and
8 Python 3.
9 """
10
11 from .packages import chardet
12
13 import sys
14
15 # -------
16 # Pythons
17 # -------
18
19 # Syntax sugar.
20 _ver = sys.version_info
21
22 #: Python 2.x?
23 is_py2 = (_ver[0] == 2)
24
25 #: Python 3.x?
26 is_py3 = (_ver[0] == 3)
27
28 try:
29 import simplejson as json
30 except (ImportError, SyntaxError):
31 # simplejson does not support Python 3.2, it throws a SyntaxError
32 # because of u'...' Unicode literals.
33 import json
34
35 # ---------
36 # Specifics
37 # ---------
38
39 if is_py2:
40 from urllib import quote, unquote, quote_plus, unquote_plus, urlencode, getp roxies, proxy_bypass
41 from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
42 from urllib2 import parse_http_list
43 import cookielib
44 from Cookie import Morsel
45 from StringIO import StringIO
46 from .packages.urllib3.packages.ordered_dict import OrderedDict
47
48 builtin_str = str
49 bytes = str
50 str = unicode
51 basestring = basestring
52 numeric_types = (int, long, float)
53 integer_types = (int, long)
54
55 elif is_py3:
56 from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag
57 from urllib.request import parse_http_list, getproxies, proxy_bypass
58 from http import cookiejar as cookielib
59 from http.cookies import Morsel
60 from io import StringIO
61 from collections import OrderedDict
62
63 builtin_str = str
64 str = str
65 bytes = bytes
66 basestring = (str, bytes)
67 numeric_types = (int, float)
68 integer_types = (int,)
OLDNEW
« no previous file with comments | « third_party/google-endpoints/requests/certs.py ('k') | third_party/google-endpoints/requests/cookies.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698