|
a/Ming/ming/utils.py |
|
b/Ming/ming/utils.py |
|
|
1 |
import cgi
|
|
|
2 |
import urllib
|
|
|
3 |
|
|
|
4 |
def parse_uri(uri, **kwargs):
|
|
|
5 |
scheme, rest = urllib.splittype(uri)
|
|
|
6 |
host, rest = urllib.splithost(rest)
|
|
|
7 |
user, rest = urllib.splituser(rest)
|
|
|
8 |
if user:
|
|
|
9 |
username, password = urllib.splitpasswd(user)
|
|
|
10 |
else:
|
|
|
11 |
username = password = None
|
|
|
12 |
host, port = urllib.splitnport(host)
|
|
|
13 |
path, query = urllib.splitquery(rest)
|
|
|
14 |
if query:
|
|
|
15 |
kwargs.update(dict(cgi.parse_qsl(query)))
|
|
|
16 |
return dict(
|
|
|
17 |
scheme=scheme,
|
|
|
18 |
host=host,
|
|
|
19 |
username=username,
|
|
|
20 |
password=password,
|
|
|
21 |
port=port,
|
|
|
22 |
path=path,
|
|
|
23 |
query=kwargs)
|
|
|
24 |
|
1 |
class LazyProperty(object):
|
25 |
class LazyProperty(object):
|
2 |
|
26 |
|
3 |
def __init__(self, func):
|
27 |
def __init__(self, func):
|
4 |
self._func = func
|
28 |
self._func = func
|
5 |
self.__name__ = func.__name__
|
29 |
self.__name__ = func.__name__
|