~xianghui/ubuntu/trusty/oslo.messaging/icehouse-lp1521958

« back to all changes in this revision

Viewing changes to oslo/messaging/openstack/common/py3kcompat/urlutils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-02-07 14:32:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140207143219-faeitvpdrypb1c9x
Tags: 1.3.0~a7-0ubuntu1
* New upstream release.
* debian/control:
  - Add python-yaml, python-babel, python-six, python-mox3,
    python-mock as build dependency.
  - Dropped python-d2to1 as a dependency.
* wrap and sort.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Copyright 2013 Canonical Ltd.
 
3
# All Rights Reserved.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
#
 
17
 
 
18
"""
 
19
Python2/Python3 compatibility layer for OpenStack
 
20
"""
 
21
 
 
22
import six
 
23
 
 
24
if six.PY3:
 
25
    # python3
 
26
    import urllib.error
 
27
    import urllib.parse
 
28
    import urllib.request
 
29
 
 
30
    urlencode = urllib.parse.urlencode
 
31
    urljoin = urllib.parse.urljoin
 
32
    quote = urllib.parse.quote
 
33
    parse_qsl = urllib.parse.parse_qsl
 
34
    unquote = urllib.parse.unquote
 
35
    unquote_plus = urllib.parse.unquote_plus
 
36
    urlparse = urllib.parse.urlparse
 
37
    urlsplit = urllib.parse.urlsplit
 
38
    urlunsplit = urllib.parse.urlunsplit
 
39
    SplitResult = urllib.parse.SplitResult
 
40
 
 
41
    urlopen = urllib.request.urlopen
 
42
    URLError = urllib.error.URLError
 
43
    pathname2url = urllib.request.pathname2url
 
44
else:
 
45
    # python2
 
46
    import urllib
 
47
    import urllib2
 
48
    import urlparse
 
49
 
 
50
    urlencode = urllib.urlencode
 
51
    quote = urllib.quote
 
52
    unquote = urllib.unquote
 
53
    unquote_plus = urllib.unquote_plus
 
54
 
 
55
    parse = urlparse
 
56
    parse_qsl = parse.parse_qsl
 
57
    urljoin = parse.urljoin
 
58
    urlparse = parse.urlparse
 
59
    urlsplit = parse.urlsplit
 
60
    urlunsplit = parse.urlunsplit
 
61
    SplitResult = parse.SplitResult
 
62
 
 
63
    urlopen = urllib2.urlopen
 
64
    URLError = urllib2.URLError
 
65
    pathname2url = urllib.pathname2url