Skip to content

Base

base

Abstract base for compaction strategies.

SmeltStrategy

Bases: ABC

Base class for all compaction strategies.

Source code in packages/axm-smelt/src/axm_smelt/strategies/base.py
Python
class SmeltStrategy(abc.ABC):
    """Base class for all compaction strategies."""

    @property
    @abc.abstractmethod
    def name(self) -> str: ...

    @property
    @abc.abstractmethod
    def category(self) -> str: ...

    @abc.abstractmethod
    def apply(self, ctx: SmeltContext) -> SmeltContext:
        """Apply the compaction strategy to the given context.

        Receives a ``SmeltContext`` carrying the current text (and optional
        parsed representation) and returns a new ``SmeltContext`` with the
        compacted result.  If the strategy does not apply, return *ctx*
        unchanged.
        """
        ...
apply(ctx) abstractmethod

Apply the compaction strategy to the given context.

Receives a SmeltContext carrying the current text (and optional parsed representation) and returns a new SmeltContext with the compacted result. If the strategy does not apply, return ctx unchanged.

Source code in packages/axm-smelt/src/axm_smelt/strategies/base.py
Python
@abc.abstractmethod
def apply(self, ctx: SmeltContext) -> SmeltContext:
    """Apply the compaction strategy to the given context.

    Receives a ``SmeltContext`` carrying the current text (and optional
    parsed representation) and returns a new ``SmeltContext`` with the
    compacted result.  If the strategy does not apply, return *ctx*
    unchanged.
    """
    ...