etlt.condition.GlobCondition   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

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