From: Michael Tremer Date: Sat, 13 Feb 2021 15:05:41 +0000 (+0000) Subject: Drop unused compression module X-Git-Tag: 0.9.28~1285^2~732 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63f052876de4497bcc692ba9d7806fdcb47e8299;p=pakfire.git Drop unused compression module Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 4727ce55b..e5e6ebea1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,7 +120,6 @@ pakfire_PYTHON = \ src/pakfire/cgroups.py \ src/pakfire/client.py \ src/pakfire/cli.py \ - src/pakfire/compress.py \ src/pakfire/config.py \ src/pakfire/constants.py \ src/pakfire/daemon.py \ diff --git a/src/pakfire/compress.py b/src/pakfire/compress.py deleted file mode 100644 index df6cf1c7e..000000000 --- a/src/pakfire/compress.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/python3 -############################################################################### -# # -# Pakfire - The IPFire package management system # -# Copyright (C) 2011 Pakfire development team # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -############################################################################### - -import lzma - -from .constants import * -from .i18n import _ - -ALGO_DEFAULT = "xz" - -# A dictionary with all compression types -# we do support. -# XXX add bzip2, and more here. -MAGICS = { - #"gzip" : "\037\213\010", - "xz" : "\xfd7zXZ", -} - -FILES = { - "xz" : lzma.LZMAFile, -} - -COMPRESSORS = { - "xz" : lzma.LZMACompressor -} - -DECOMPRESSORS = { - "xz" : lzma.LZMADecompressor, -} - -def guess_algo(name=None, fileobj=None): - """ - This function takes a filename or a file descriptor - and tells the name of the algorithm the file was - compressed with. - If an unknown or no compression was used, None is returned. - """ - ret = None - - if name: - fileobj = open(file) - - # Save position of pointer. - pos = fileobj.tell() - - # Iterate over all algoriths and their magic values - # and check for a match. - for algo, magic in list(MAGICS.items()): - fileobj.seek(0) - - start_sequence = fileobj.read(len(magic)) - if start_sequence == magic: - ret = algo - break - - # Reset file pointer. - fileobj.seek(pos) - - if name: - fileobj.close() - - return ret - -def decompressobj(name=None, fileobj=None, algo=ALGO_DEFAULT): - f_cls = FILES.get(algo, None) - if not f_cls: - raise CompressionError(_("Given algorithm '%s' is not supported.")) - - f = f_cls(name, fileobj=fileobj, mode="r") - - return f - - -def compressobj(name=None, fileobj=None, algo=ALGO_DEFAULT): - f_cls = FILES.get(algo, None) - if not f_cls: - raise CompressionError(_("Given algorithm '%s' is not supported.")) - - f = f_cls(name, fileobj=fileobj, mode="w") - - return f