Completed
Push — master ( 0c702e...f32b73 )
by P.R.
01:15
created

Writer.__enter__()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
"""
2
ETLT
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
import abc
9
10
11
class Writer:
0 ignored issues
show
Unused Code introduced by
This abstract class does not seem to be used anywhere.
Loading history...
12
    """
13
    Abstract parent class for writing rows to a destination.
14
    """
15
16
    # ------------------------------------------------------------------------------------------------------------------
17
    def __init__(self):
18
        """
19
        Object constructor.
20
        """
21
22
        self._fields = []
23
        """
24
        The fields (or columns) that must be written to the destination.
25
26
        :type list[str]:
27
        """
28
29
    # ------------------------------------------------------------------------------------------------------------------
30
    @property
31
    def fields(self):
32
        """
33
        Getter for fields.
34
35
        :rtype: list[str]
36
        """
37
        return self._fields
38
39
    # ------------------------------------------------------------------------------------------------------------------
40
    @fields.setter
41
    def fields(self, fields):
42
        """
43
        Setter for fields.
44
45
        :param list[str] fields: The fields (or columns) that must be written to the destination.
46
        """
47
        self._fields = fields
48
49
    # ------------------------------------------------------------------------------------------------------------------
50
    @abc.abstractmethod
51
    def write(self, row):
52
        """
53
        Writes a row to the destination.
54
55
        :param dict[str,T] row: The row.
56
57
        :rtype: None
58
        """
59
        raise NotImplementedError()
60
61
    # ------------------------------------------------------------------------------------------------------------------
62
    def __enter__(self):
63
        raise NotImplementedError()
64
65
    # ------------------------------------------------------------------------------------------------------------------
66
    def __exit__(self, exc_type, exc_value, traceback):
67
        raise NotImplementedError()
68
69
# ----------------------------------------------------------------------------------------------------------------------
70