UniversalCsvReaderFormatHelper.pass2()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 15
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 4
dl 0
loc 15
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
from typing import Dict
2
3
4
class UniversalCsvReaderFormatHelper:
5
    """
6
    A helper class for UniversalCsvReader for setting and correcting the formatting parameters for reading CSV files.
7
    """
8
9
    # ------------------------------------------------------------------------------------------------------------------
10
    def pass1(self, filename: str, formatting_parameters: Dict[str, str]) -> Dict[str, str]:
11
        """
12
        Returns the formatting parameters for reading the next current CSV file.
13
14
        This method is called by UniversalCsvReader before opening the CSV file and before auto-detecting parameters.
15
16
        Override this method in your own child class according to your needs.
17
18
        :param str filename: The next current file name.
19
        :param dict[str,str] formatting_parameters: The default formatting parameters. Keys are:
20
                                                     - encoding: Use auto for auto-detecting.
21
                                                     - delimiter: Use auto for auto-detecting.
22
                                                     - line_terminator: Use auto for auto-detecting.
23
                                                     - escape_char
24
                                                     - quote_char
25
        """
26
        return formatting_parameters
27
28
    # ------------------------------------------------------------------------------------------------------------------
29
    def pass2(self, filename: str, formatting_parameters1: Dict[str, str], formatting_parameters2: Dict[str, str]) -> \
30
            Dict[str, str]:
31
        """
32
        Returns the formatting parameters for reading the next current CSV file.
33
34
        This method is called by UniversalCsvReader after auto-detecting parameters.
35
36
        Override this method in your own child class according to your needs.
37
38
        :param str filename: The next current file name.
39
        :param dict[str,str] formatting_parameters1: The formatting parameters as returned by pass1.
40
        :param dict[str,str] formatting_parameters2: The formatting parameters as returned by pass1 but parameters set
41
                                                     to auto are replaced with the automatically detected values.
42
        """
43
        return formatting_parameters2
44
45
# ----------------------------------------------------------------------------------------------------------------------
46