Module refinery.units.compression.lzx

Expand source code Browse git
from __future__ import annotations

from refinery.lib.lzx import LzxDecoder
from refinery.lib.types import Param
from refinery.units import Arg, RefineryPartialResult, Unit


class lzx(Unit):

    def __init__(
        self,
        window: Param[int, Arg(help='Optionally specify the window size; the default is {default}.')] = 15,
        wim: Param[bool, Arg('-w', help='Use the WIM flavor of LZX.')] = False,
    ):
        super().__init__(window=window, wim=wim)

    def process(self, data):
        lzx = LzxDecoder(self.args.wim)
        lzx.set_params_and_alloc(self.args.window)

        try:
            return lzx.decompress(memoryview(data))
        except Exception as E:
            if out := lzx.get_output_data():
                raise RefineryPartialResult(str(E), out) from E
            raise

Classes

class lzx (window=15, wim=False)
Expand source code Browse git
class lzx(Unit):

    def __init__(
        self,
        window: Param[int, Arg(help='Optionally specify the window size; the default is {default}.')] = 15,
        wim: Param[bool, Arg('-w', help='Use the WIM flavor of LZX.')] = False,
    ):
        super().__init__(window=window, wim=wim)

    def process(self, data):
        lzx = LzxDecoder(self.args.wim)
        lzx.set_params_and_alloc(self.args.window)

        try:
            return lzx.decompress(memoryview(data))
        except Exception as E:
            if out := lzx.get_output_data():
                raise RefineryPartialResult(str(E), out) from E
            raise

Ancestors

Subclasses

Class variables

var required_dependencies
var optional_dependencies
var console
var reverse

Inherited members