urlopen moved from urllib to urllib.request in py3k
[~helmut/debian-dedup.git] / autoimport.py
index 76e9962..5f14b2e 100755 (executable)
@@ -12,11 +12,14 @@ import os
 import sqlite3
 import subprocess
 import tempfile
-import urllib
 try:
     from urllib.parse import unquote
 except ImportError:
     from urllib import unquote
+try:
+    from urllib.request import urlopen
+except ImportError:
+    from urllib import urlopen
 
 import concurrent.futures
 from debian import deb822
@@ -25,7 +28,7 @@ from debian.debian_support import version_compare
 from readyaml import readyaml
 
 def process_http(pkgs, url):
-    pkglist = urllib.urlopen(url + "/dists/sid/main/binary-amd64/Packages.gz").read()
+    pkglist = urlopen(url + "/dists/sid/main/binary-amd64/Packages.gz").read()
     pkglist = gzip.GzipFile(fileobj=io.BytesIO(pkglist)).read()
     pkglist = io.BytesIO(pkglist)
     pkglist = deb822.Packages.iter_paragraphs(pkglist)