diff options
author | Helmut Grohne <helmut@subdivi.de> | 2015-04-16 17:43:11 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2015-04-16 17:43:11 +0200 |
commit | 621e4e5ed5783339973351aed5c0b08c22936c55 (patch) | |
tree | 92cd8b8e739be85986e65c27ea71714032b45cf4 /importpkg.py | |
parent | 2a728ab85e1ddfeec03514f86f706c116ca94440 (diff) | |
download | debian-dedup-621e4e5ed5783339973351aed5c0b08c22936c55.tar.gz |
distinguish bytes from unicode for py3k
Diffstat (limited to 'importpkg.py')
-rwxr-xr-x | importpkg.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/importpkg.py b/importpkg.py index 7e074e1..6dced21 100755 --- a/importpkg.py +++ b/importpkg.py @@ -45,13 +45,14 @@ def gifhash(): return hashobj def decompress_tar(filelike, extension): - if extension in (".lzma", ".xz"): + if extension in (b".lzma", b".xz"): filelike = DecompressedStream(filelike, lzma.LZMADecompressor()) - extension = "" - if extension not in ("", ".gz", ".bz2"): + extension = b"" + if extension not in (b"", b".gz", b".bz2"): raise ValueError("unknown compression format with extension %r" % extension) - return tarfile.open(fileobj=filelike, mode="r|" + extension[1:]) + return tarfile.open(fileobj=filelike, + mode="r|" + extension[1:].decode("ascii")) def process_package(filelike, hash_functions): af = ArReader(filelike) @@ -62,7 +63,7 @@ def process_package(filelike, hash_functions): name = af.read_entry() except EOFError: raise ValueError("data.tar not found") - if name.startswith("control.tar"): + if name.startswith(b"control.tar"): if state != "start": raise ValueError("unexpected control.tar") state = "control" @@ -76,7 +77,7 @@ def process_package(filelike, hash_functions): yield process_control(tf.extractfile(elem).read()) break continue - elif name.startswith("data.tar"): + elif name.startswith(b"data.tar"): if state != "control_file": raise ValueError("missing control file") state = "data" |