mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-14 15:12:03 +01:00
Remove more broken urlparse.urljoin examples.
urlparse.urljoin('scheme:foo/bar/', 'baz') == 'baz', so it doesn't work the
way I expected. Instead, let's use regular string joins.
BUG=chromium-os:5311
TEST=Examine example Packages file.
Review URL: http://codereview.chromium.org/5414001
Change-Id: I1d81dd7a3a79ca6c1f0750993535d3b66696ec23
This commit is contained in:
parent
6edcc4d952
commit
2df2dd5d23
@ -11,7 +11,6 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import urllib2
|
import urllib2
|
||||||
import urlparse
|
|
||||||
|
|
||||||
class PackageIndex(object):
|
class PackageIndex(object):
|
||||||
"""A parser for the Portage Packages index file.
|
"""A parser for the Portage Packages index file.
|
||||||
@ -54,7 +53,7 @@ class PackageIndex(object):
|
|||||||
cpv, sha1 = pkg['CPV'], pkg.get('SHA1')
|
cpv, sha1 = pkg['CPV'], pkg.get('SHA1')
|
||||||
if sha1:
|
if sha1:
|
||||||
path = pkg.get('PATH', cpv + '.tbz2')
|
path = pkg.get('PATH', cpv + '.tbz2')
|
||||||
db[sha1] = urlparse.urljoin(uri, path)
|
db[sha1] = '%s/%s' % (uri.rstrip('/'), path)
|
||||||
|
|
||||||
def _ReadPkgIndex(self, pkgfile):
|
def _ReadPkgIndex(self, pkgfile):
|
||||||
"""Read a list of key/value pairs from the Packages file into a dictionary.
|
"""Read a list of key/value pairs from the Packages file into a dictionary.
|
||||||
@ -201,7 +200,7 @@ class PackageIndex(object):
|
|||||||
"""
|
"""
|
||||||
self.header['URI'] = base_uri
|
self.header['URI'] = base_uri
|
||||||
for pkg in self.packages:
|
for pkg in self.packages:
|
||||||
pkg['PATH'] = urlparse.urljoin(path_prefix, pkg['CPV'] + '.tbz2')
|
pkg['PATH'] = '%s/%s' % (path_prefix.rstrip('/'), pkg['CPV'] + '.tbz2')
|
||||||
|
|
||||||
def Write(self, pkgfile):
|
def Write(self, pkgfile):
|
||||||
"""Write a packages file to disk.
|
"""Write a packages file to disk.
|
||||||
@ -277,7 +276,7 @@ def GrabRemotePackageIndex(binhost_url):
|
|||||||
server returns status code 404, None is returned.
|
server returns status code 404, None is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = urlparse.urljoin(binhost_url, 'Packages')
|
url = '%s/Packages' % binhost_url.rstrip('/')
|
||||||
try:
|
try:
|
||||||
f = _RetryUrlOpen(url)
|
f = _RetryUrlOpen(url)
|
||||||
except urllib2.HTTPError as e:
|
except urllib2.HTTPError as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user