38
38
def parse(full_url):
39
39
" parse a apt url and return a list of AptUrl objects "
40
# apt:pkg1?k11=v11?k12=v12,pkg2?k21=v21?k22=v22,...
42
43
for url in full_url.split(";"):
44
45
raise InvalidUrlException
48
(schema, rem) = url.split(":", 1)
49
apt_url.schema = schema
50
# check for schemas of the form: apt+http://
51
if schema.startswith("apt+"):
52
apt_url.repo_url = schema[len("apt+"):] + ":" + rem.split("?",1)[0]
55
rem = rem.split("?")[0]
56
apt_url.package = rem.lstrip("/")
58
# now parse the ?... bits
60
key_value_pairs = url.split("?")
61
if len(key_value_pairs) > 1:
62
# first one is invalid
63
del key_value_pairs[0]
64
for s in key_value_pairs:
66
# for list defaults, add to list
68
if type(getattr(apt_url, k)) == type([]):
69
getattr(apt_url, k).append(v)
71
setattr(apt_url, k, v)
73
raise InvalidUrlException
49
(schema, packages) = url.split(":", 1)
50
packages = packages.split(",")
52
for package in packages:
54
apt_url.schema = schema
55
# check for schemas of the form: apt+http://
56
if schema.startswith("apt+"):
57
apt_url.repo_url = schema[len("apt+"):] + ":" + package.split("?",1)[0]
60
apt_url.package = package.split("?")[0].lstrip("/")
62
apt_url.package = package.lstrip("/")
64
# now parse the ?... bits
66
key_value_pairs = package.split("?")
67
if len(key_value_pairs) > 1:
68
# first one is invalid
69
del key_value_pairs[0]
70
for s in key_value_pairs:
72
# for list defaults, add to list
74
if type(getattr(apt_url, k)) == type([]):
75
getattr(apt_url, k).append(v)
77
setattr(apt_url, k, v)
79
raise InvalidUrlException