Completed
Push — master ( 00dd46...452f18 )
by P.R.
01:48
created

GlobCondition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 25
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scheme() 0 8 1
A match() 0 9 1
1
"""
2
ETLT
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8 1
import fnmatch
9
10 1
from etlt.condition.SimpleCondition import SimpleCondition
11
12
13 1
class GlobCondition(SimpleCondition):
14
    """
15
    A glob condition matches a field in the row against a glob expression.
16
    """
17
18
    # ------------------------------------------------------------------------------------------------------------------
19 1
    def match(self, row):
20
        """
21
        Returns True if the field matches the glob expression of this simple condition. Returns False otherwise.
22
23
        :param dict row: The row.
24
25
        :rtype: bool
26
        """
27 1
        return fnmatch.fnmatchcase(row[self._field], self._expression)
28
29
    # ------------------------------------------------------------------------------------------------------------------
30 1
    @property
31
    def scheme(self):
32
        """
33
        Returns 'glob'.
34
35
        :rtype: str
36
        """
37 1
        return 'glob'
38
39
# ----------------------------------------------------------------------------------------------------------------------
40