Passed
Branch master (17b603)
by P.R.
01:31
created

etlt.reader.UniversalCsvReaderFormatHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 53
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A UniversalCsvReaderFormatHelper.pass2() 0 16 1
A UniversalCsvReaderFormatHelper.pass1() 0 19 1
1
"""
2
ETLT
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
9
10
class UniversalCsvReaderFormatHelper:
11
    """
12
    A helper class for UniversalCsvReader for setting and correcting the formatting parameters for reading CSV files.
13
    """
14
15
    # ------------------------------------------------------------------------------------------------------------------
16
    def pass1(self, filename, formatting_parameters0):
17
        """
18
        Returns the formatting parameters for reading the next current CSV file.
19
20
        This method is called by UniversalCsvReader before opening the CSV file and before auto detecting parameters.
21
22
        Override this method in your own child class according to your needs.
23
24
        :param str filename: The next current file name.
25
        :param dict[str,str] formatting_parameters0: The default formatting parameters. Keys are:
26
                                                     - encoding: Use auto for auto detecting.
27
                                                     - delimiter: Use auto for auto detecting.
28
                                                     - line_terminator: Use auto for auto detecting.
29
                                                     - escape_char
30
                                                     - quote_char
31
32
        :rtype: dict[str,str]
33
        """
34
        return formatting_parameters0
35
36
    # ------------------------------------------------------------------------------------------------------------------
37
    def pass2(self, filename, formatting_parameters1, formatting_parameters2):
38
        """
39
        Returns the formatting parameters for reading the next current CSV file.
40
41
        This method is called by UniversalCsvReader after auto detecting parameters.
42
43
        Override this method in your own child class according to your needs.
44
45
        :param str filename: The next current file name.
46
        :param dict[str,str] formatting_parameters1: The formatting parameters as returned by pass1.
47
        :param dict[str,str] formatting_parameters2: The formatting parameters as returned by pass1 but parameters set
48
                                                     to auto are replaced with the automatically detected values.
49
50
        :rtype: dict[str,str]
51
        """
52
        return formatting_parameters2
53
54
# ----------------------------------------------------------------------------------------------------------------------
55