How to use the fava.core.filters.Match function in fava

To help you get started, we’ve selected a few fava examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beancount / fava / tests / test_core_filters.py View on Github external
def test_match():
    assert Match("asdf")("asdf")
    assert Match("asdf")("asdfasdf")
    assert not Match("asdf")("aasdfasdf")
    assert Match("(((")("(((")
github beancount / fava / tests / test_core_filters.py View on Github external
def test_match():
    assert Match("asdf")("asdf")
    assert Match("asdf")("asdfasdf")
    assert not Match("asdf")("aasdfasdf")
    assert Match("(((")("(((")
github beancount / fava / tests / test_core_filters.py View on Github external
def test_match():
    assert Match("asdf")("asdf")
    assert Match("asdf")("asdfasdf")
    assert not Match("asdf")("aasdfasdf")
    assert Match("(((")("(((")
github beancount / fava / tests / test_core_filters.py View on Github external
def test_match():
    assert Match("asdf")("asdf")
    assert Match("asdf")("asdfasdf")
    assert not Match("asdf")("aasdfasdf")
    assert Match("(((")("(((")
github beancount / fava / fava / core / filters.py View on Github external
def set(self, value):
        if value == self.value:
            return False
        self.value = value
        self.match = Match(value or "")
        return True
github beancount / fava / fava / core / filters.py View on Github external
def p_simple_expr_key(self, p):
        """
        simple_expr : KEY STRING
        """
        key, value = p[1], p[2]
        match = Match(value)

        def _key(entry):
            if hasattr(entry, key):
                return match(str(getattr(entry, key) or ""))
            if key in entry.meta:
                return match(str(entry.meta.get(key)))
            return False

        p[0] = _key
github beancount / fava / fava / core / filters.py View on Github external
def p_simple_expr_STRING(self, p):
        """
        simple_expr : STRING
        """
        string = p[1]
        match = Match(string)

        def _string(entry):
            for name in ("narration", "payee", "comment"):
                value = getattr(entry, name, "")
                if value and match(value):
                    return True
            return False

        p[0] = _string