Module refinery.units.meta.iffx

Expand source code Browse git
from __future__ import annotations

from refinery.units.pattern import SingleRegexUnit
from refinery.units.meta import ConditionalUnit


class iffx(SingleRegexUnit, ConditionalUnit, docs='{0}{p}{1}'):
    """
    Filter incoming chunks by discarding those that do not match the given
    regular expression.
    """
    def match(self, chunk):
        if matcher := self._make_matcher(self.args.regex):
            return bool(matcher(chunk))
        else:
            return True

Classes

class iffx (regex, count=0, fullmatch=False, multiline=False, ignorecase=False)

Filter incoming chunks by discarding those that do not match the given regular expression.

Note: The reverse operation of a conditional unit uses the logical negation of its condition.

Expand source code Browse git
class iffx(SingleRegexUnit, ConditionalUnit, docs='{0}{p}{1}'):
    """
    Filter incoming chunks by discarding those that do not match the given
    regular expression.
    """
    def match(self, chunk):
        if matcher := self._make_matcher(self.args.regex):
            return bool(matcher(chunk))
        else:
            return True

Ancestors

Subclasses

Class variables

var required_dependencies
var optional_dependencies
var console

Methods

def match(self, chunk)
Expand source code Browse git
def match(self, chunk):
    if matcher := self._make_matcher(self.args.regex):
        return bool(matcher(chunk))
    else:
        return True

Inherited members