mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-29 11:51:08 +00:00
lp/libsupport.py
This commit is contained in:
parent
65ab539516
commit
0c211c1bc7
@ -19,8 +19,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
import urllib
|
try:
|
||||||
import urlparse
|
from urllib.parse import urlsplit, urlencode, urlunsplit
|
||||||
|
except ImportError:
|
||||||
|
from urllib import urlencode
|
||||||
|
from urlparse import urlsplit, urlunsplit
|
||||||
|
|
||||||
def query_to_dict(query_string):
|
def query_to_dict(query_string):
|
||||||
result = dict()
|
result = dict()
|
||||||
@ -31,7 +34,7 @@ def query_to_dict(query_string):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def translate_web_api(url, launchpad):
|
def translate_web_api(url, launchpad):
|
||||||
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
|
scheme, netloc, path, query, fragment = urlsplit(url)
|
||||||
query = query_to_dict(query)
|
query = query_to_dict(query)
|
||||||
|
|
||||||
differences = set(netloc.split('.')).symmetric_difference(
|
differences = set(netloc.split('.')).symmetric_difference(
|
||||||
@ -44,8 +47,8 @@ def translate_web_api(url, launchpad):
|
|||||||
if "ws.op" in query:
|
if "ws.op" in query:
|
||||||
raise ValueError("Invalid web url, url: %s" %url)
|
raise ValueError("Invalid web url, url: %s" %url)
|
||||||
query["ws.op"] = "searchTasks"
|
query["ws.op"] = "searchTasks"
|
||||||
scheme, netloc, api_path, _, _ = urlparse.urlsplit(str(launchpad._root_uri))
|
scheme, netloc, api_path, _, _ = urlsplit(str(launchpad._root_uri))
|
||||||
query = urllib.urlencode(query)
|
query = urlencode(query)
|
||||||
url = urlparse.urlunsplit((scheme, netloc, api_path + path.lstrip("/"),
|
url = urlunsplit((scheme, netloc, api_path + path.lstrip("/"),
|
||||||
query, fragment))
|
query, fragment))
|
||||||
return url
|
return url
|
||||||
|
Loading…
x
Reference in New Issue
Block a user