etlt.condition.GlobCondition.GlobCondition.match()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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