Completed
Push — master ( 9d90ba...7d87fd )
by P.R.
01:17
created

RegularExpressionCondition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 18
rs 10

1 Method

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