Module refinery.units.meta.iffs

Expand source code Browse git
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from refinery.units.meta import Arg, ConditionalUnit


class iffs(ConditionalUnit, extend_docs=True):
    """
    Filter incoming chunks depending on whether they contain a given binary substring.
    """
    def __init__(
        self,
        needle: Arg(help='the string to search for'),
        negate=False,
        single=False,
    ):
        super().__init__(
            needle=needle,
            negate=negate,
            single=single,
        )

    def match(self, chunk):
        return self.args.needle in chunk

Classes

class iffs (needle, negate=False, single=False)

Filter incoming chunks depending on whether they contain a given binary substring.

Conditional units can be used in two different ways. When a new frame opens after using this unit, chunks that did not match the condition are moved out of scope for that frame but still exist and will re-appear after the frame closes. When used inside a frame, however, the unit works as a filter and will discard any chunks that do not match.

Expand source code Browse git
class iffs(ConditionalUnit, extend_docs=True):
    """
    Filter incoming chunks depending on whether they contain a given binary substring.
    """
    def __init__(
        self,
        needle: Arg(help='the string to search for'),
        negate=False,
        single=False,
    ):
        super().__init__(
            needle=needle,
            negate=negate,
            single=single,
        )

    def match(self, chunk):
        return self.args.needle in chunk

Ancestors

Class variables

var required_dependencies
var optional_dependencies

Methods

def match(self, chunk)
Expand source code Browse git
def match(self, chunk):
    return self.args.needle in chunk

Inherited members