Total Complexity | 2 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 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 | |||
30 |