summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/bintree.py
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-09-20 16:22:08 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-09-20 16:22:08 +0000
commit8243a08d6d2121e4c1e92201c9d4361df42e5d8f (patch)
tree8885f3b3d554054901d15c7a77bad789a8aa12e8 /pym/portage/dbapi/bintree.py
parent5ce55d59b6a1e0fabd4e7879aa94f69251d03d69 (diff)
downloadportage-8243a08d6d2121e4c1e92201c9d4361df42e5d8f.tar.gz
portage-8243a08d6d2121e4c1e92201c9d4361df42e5d8f.tar.bz2
portage-8243a08d6d2121e4c1e92201c9d4361df42e5d8f.zip
Update system imports for compatibility with Python 3.
svn path=/main/trunk/; revision=14294
Diffstat (limited to 'pym/portage/dbapi/bintree.py')
-rw-r--r--pym/portage/dbapi/bintree.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index e020415ab..bc91152a6 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -660,7 +660,10 @@ class binarytree(object):
base_url = self.settings["PORTAGE_BINHOST"]
from portage.const import CACHE_PATH
- from urlparse import urlparse
+ try:
+ from urllib.parse import urlparse
+ except ImportError:
+ from urlparse import urlparse
urldata = urlparse(base_url)
pkgindex_file = os.path.join(self.settings["ROOT"], CACHE_PATH, "binhost",
urldata[1] + urldata[2], "Packages")
@@ -678,13 +681,16 @@ class binarytree(object):
if e.errno != errno.ENOENT:
raise
local_timestamp = pkgindex.header.get("TIMESTAMP", None)
- import urllib, urlparse
+ try:
+ from urllib.request import urlopen as urllib_request_urlopen
+ except ImportError:
+ from urllib import urlopen as urllib_request_urlopen
rmt_idx = self._new_pkgindex()
try:
# urlparse.urljoin() only works correctly with recognized
# protocols and requires the base url to have a trailing
# slash, so join manually...
- f = urllib.urlopen(base_url.rstrip("/") + "/Packages")
+ f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
try:
rmt_idx.readHeader(f)
remote_timestamp = rmt_idx.header.get("TIMESTAMP", None)
@@ -1082,7 +1088,10 @@ class binarytree(object):
mydest = os.path.dirname(self.getname(pkgname))
self._ensure_dir(mydest)
- from urlparse import urlparse
+ try:
+ from urllib.parse import urlparse
+ except ImportError:
+ from urlparse import urlparse
# urljoin doesn't work correctly with unrecognized protocols like sftp
if self._remote_has_index:
rel_url = self._remotepkgs[pkgname].get("PATH")