RegularExpressionCondition.match()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 2
dl 0
loc 10
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
1 1
import re
2
from typing import Any, Dict
3 1
4
from etlt.condition.SimpleCondition import SimpleCondition
5
6 1
7
class RegularExpressionCondition(SimpleCondition):
8
    """
9
    A regular expression condition matches a field in the row against a regular expression expression.
10
    """
11
12 1
    # ------------------------------------------------------------------------------------------------------------------
13
    def match(self, row: Dict[str, Any]) -> bool:
14
        """
15
        Returns True if the field matches the regular expression of this simple condition. Returns False otherwise.
16
17
        :param row: The row.
18
        """
19
        if re.search(self._expression, row[self._field]):
20 1
            return True
21 1
22
        return False
23 1
24
    # ------------------------------------------------------------------------------------------------------------------
25
    @property
26 1
    def scheme(self) -> str:
27 1
        """
28
        Returns 're'.
29
        """
30
        return 're'
31
32
# ----------------------------------------------------------------------------------------------------------------------
33