etlt.condition.RegularExpressionCondition   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 31
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A RegularExpressionCondition.scheme() 0 6 1
A RegularExpressionCondition.match() 0 10 2
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