Completed
Push — master ( 7b86c6...8c3cbf )
by P.R.
01:53
created

UniversalCsvReaderFormatHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 43
ccs 0
cts 5
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass1() 0 19 1
A pass2() 0 16 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):
2 ignored issues
show
Unused Code introduced by
The argument filename seems to be unused.
Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
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):
3 ignored issues
show
Unused Code introduced by
The argument formatting_parameters1 seems to be unused.
Loading history...
Unused Code introduced by
The argument filename seems to be unused.
Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
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