summaryrefslogtreecommitdiff
path: root/dedup/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'dedup/utils.py')
-rw-r--r--dedup/utils.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/dedup/utils.py b/dedup/utils.py
index d3a27a0..55cdef0 100644
--- a/dedup/utils.py
+++ b/dedup/utils.py
@@ -1,7 +1,10 @@
+import contextlib
import errno
import urllib.error
import urllib.request
+import debian.deb822
+
from dedup.compression import decompress
def fetchiter(cursor):
@@ -30,3 +33,11 @@ def open_compressed_mirror_url(url, extensions=(".xz", ".gz", "")):
else:
return decompress(handle, ext)
raise OSError(errno.ENOENT, "No such file or directory")
+
+def iterate_packages(mirror, architecture, distribution="sid", section="main"):
+ """Download the relevant binary package list and generate
+ debian.deb822.Packages objects per listed package."""
+ url = "%s/dists/%s/%s/binary-%s/Packages" % \
+ (mirror, distribution, section, architecture)
+ with contextlib.closing(open_compressed_mirror_url(url)) as pkglist:
+ yield from debian.deb822.Packages.iter_paragraphs(pkglist)