| Total Complexity | 6 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | """ |
||
| 11 | class Writer: |
||
|
|
|||
| 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 | |||
| 70 |