summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py66
1 files changed, 17 insertions, 49 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 6969e261b4..427c47673b 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -319,40 +319,9 @@ def decodeurl(url):
319 user, password, parameters). 319 user, password, parameters).
320 """ 320 """
321 321
322 m = re.compile('(?P<type>[^:]*)://((?P<user>.+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url) 322 urlo = URI(url)
323 if not m: 323 return (urlo.scheme, urlo.hostport, urlo.path,
324 raise MalformedUrl(url) 324 urlo.username, urlo.password, urlo.params)
325
326 type = m.group('type')
327 location = m.group('location')
328 if not location:
329 raise MalformedUrl(url)
330 user = m.group('user')
331 parm = m.group('parm')
332
333 locidx = location.find('/')
334 if locidx != -1 and type.lower() != 'file':
335 host = location[:locidx]
336 path = location[locidx:]
337 else:
338 host = ""
339 path = location
340 if user:
341 m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user)
342 if m:
343 user = m.group('user')
344 pswd = m.group('pswd')
345 else:
346 user = ''
347 pswd = ''
348
349 p = {}
350 if parm:
351 for s in parm.split(';'):
352 s1, s2 = s.split('=')
353 p[s1] = s2
354
355 return type, host, urllib.unquote(path), user, pswd, p
356 325
357def encodeurl(decoded): 326def encodeurl(decoded):
358 """Encodes a URL from tokens (scheme, network location, path, 327 """Encodes a URL from tokens (scheme, network location, path,
@@ -361,27 +330,26 @@ def encodeurl(decoded):
361 330
362 type, host, path, user, pswd, p = decoded 331 type, host, path, user, pswd, p = decoded
363 332
333 urlo = URI()
334
364 if not path: 335 if not path:
365 raise MissingParameterError('path', "encoded from the data %s" % str(decoded)) 336 raise MissingParameterError('path', "encoded from the data %s" % str(decoded))
366 if not type: 337 if not type:
367 raise MissingParameterError('type', "encoded from the data %s" % str(decoded)) 338 raise MissingParameterError('type', "encoded from the data %s" % str(decoded))
368 url = '%s://' % type 339
369 if user and type != "file": 340 urlo.scheme = type
370 url += "%s" % user 341 urlo.path = path
371 if pswd: 342
372 url += ":%s" % pswd 343 if host:
373 url += "@" 344 urlo.hostname = host
374 if host and type != "file": 345 if user:
375 url += "%s" % host 346 urlo.username = user
376 # Standardise path to ensure comparisons work 347 if pswd:
377 while '//' in path: 348 urlo.password = pswd
378 path = path.replace("//", "/")
379 url += "%s" % urllib.quote(path)
380 if p: 349 if p:
381 for parm in p: 350 urlo.params = p
382 url += ";%s=%s" % (parm, p[parm])
383 351
384 return url 352 return str(urlo)
385 353
386def uri_replace(ud, uri_find, uri_replace, replacements, d): 354def uri_replace(ud, uri_find, uri_replace, replacements, d):
387 if not ud.url or not uri_find or not uri_replace: 355 if not ud.url or not uri_find or not uri_replace: