diff options
author | Helmut Grohne <helmut@subdivi.de> | 2020-02-16 08:21:20 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2020-02-16 08:21:20 +0100 |
commit | 27b95909f061ae3ecb3ba1b8d46adfef98ca5e6f (patch) | |
tree | 87695b998b1e97e406050584812d4db68bdb4610 /dedup/debpkg.py | |
parent | e77a1ebf8bda10494088bb6c72873d8ef214e0f3 (diff) | |
download | debian-dedup-27b95909f061ae3ecb3ba1b8d46adfef98ca5e6f.tar.gz |
drop support for Python 2.x
Diffstat (limited to 'dedup/debpkg.py')
-rw-r--r-- | dedup/debpkg.py | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/dedup/debpkg.py b/dedup/debpkg.py index 3a30b3e..38086ec 100644 --- a/dedup/debpkg.py +++ b/dedup/debpkg.py @@ -1,4 +1,3 @@ -import sys import tarfile from debian import deb822 @@ -7,7 +6,7 @@ from dedup.arreader import ArReader from dedup.compression import decompress from dedup.hashing import hash_file -class MultiHash(object): +class MultiHash: def __init__(self, *hashes): self.hashes = hashes @@ -38,32 +37,11 @@ def get_tar_hashes(tar, hash_functions): hashes[hashobj.name] = hashvalue yield (elem.name, elem.size, hashes) -if sys.version_info.major >= 3: - def opentar(filelike): - return tarfile.open(fileobj=filelike, mode="r|", encoding="utf8", - errors="surrogateescape") +def opentar(filelike): + return tarfile.open(fileobj=filelike, mode="r|", encoding="utf8", + errors="surrogateescape") - def decodetarname(name): - """Decoded name of a tarinfo. - @raises UnicodeDecodeError: - """ - try: - name.encode("utf8", "strict") - except UnicodeEncodeError as e: - if e.reason == "surrogates not allowed": - name.encode("utf8", "surrogateescape").decode("utf8", "strict") - return name -else: - def opentar(filelike): - return tarfile.open(fileobj=filelike, mode="r|") - - def decodetarname(name): - """Decoded name of a tarinfo. - @raises UnicodeDecodeError: - """ - return name.decode("utf8") - -class DebExtractor(object): +class DebExtractor: "Base class for extracting desired features from a Debian package." def __init__(self): |