diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-12-31 15:24:01 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-12-31 15:24:01 +0100 |
commit | 5b359b10053cbade539246eec26e86b44793ca40 (patch) | |
tree | 6c0f754afd588c65060983ba5e777e1ddd2c1d62 /dedup/utils.py | |
parent | 1631e91b116ebf04ba9bd332e12c2f165263088b (diff) | |
download | debian-dedup-5b359b10053cbade539246eec26e86b44793ca40.tar.gz |
dedup.utils: uninline helper function iterate_packages
Diffstat (limited to 'dedup/utils.py')
-rw-r--r-- | dedup/utils.py | 11 |
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) |