diff options
author | Helmut Grohne <helmut@subdivi.de> | 2023-05-09 15:10:25 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2023-05-09 15:12:01 +0200 |
commit | 924f0c734a7accb87e2ac911cee6e24dd463f237 (patch) | |
tree | eb1bcaa2f25933374d28905bcb56e2e8aabeec62 /dedup/utils.py | |
parent | 8a05a6d8bacea0643a4967eed4cd67019ee0b6d7 (diff) | |
download | debian-dedup-924f0c734a7accb87e2ac911cee6e24dd463f237.tar.gz |
Diffstat (limited to 'dedup/utils.py')
-rw-r--r-- | dedup/utils.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/dedup/utils.py b/dedup/utils.py index 55cdef0..e1b134f 100644 --- a/dedup/utils.py +++ b/dedup/utils.py @@ -1,5 +1,7 @@ import contextlib import errno +import sqlite3 +import typing import urllib.error import urllib.request @@ -7,13 +9,17 @@ import debian.deb822 from dedup.compression import decompress -def fetchiter(cursor): + +def fetchiter(cursor: sqlite3.Cursor) -> typing.Iterator[typing.Any]: rows = cursor.fetchmany() while rows: yield from rows rows = cursor.fetchmany() -def open_compressed_mirror_url(url, extensions=(".xz", ".gz", "")): + +def open_compressed_mirror_url( + url: str, extensions: typing.Iterable[str] = (".xz", ".gz", "") +) -> typing.BinaryIO: """Fetch the given url. Try appending each of the given compression schemes and move on in case it doesn't exist. Decompress the resulting stream on the fly. @@ -34,7 +40,13 @@ def open_compressed_mirror_url(url, extensions=(".xz", ".gz", "")): return decompress(handle, ext) raise OSError(errno.ENOENT, "No such file or directory") -def iterate_packages(mirror, architecture, distribution="sid", section="main"): + +def iterate_packages( + mirror: str, + architecture: str, + distribution: str = "sid", + section: str = "main", +) -> typing.Iterator[debian.deb822.Packages]: """Download the relevant binary package list and generate debian.deb822.Packages objects per listed package.""" url = "%s/dists/%s/%s/binary-%s/Packages" % \ |