Completed
Push — master ( d8cee1...b07d26 )
by Jaisen
02:05
created

elodie/result.py (4 issues)

1
from tabulate import tabulate
0 ignored issues
show
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
4
class Result(object):
5
6
    def __init__(self):
7
        self.records = []
8
        self.success = 0
9
        self.error = 0
10
        self.error_items = []
11
12
    def append(self, row):
13
        id, status = row
14
15
        if status:
16
            self.success += 1
17
        else:
18
            self.error += 1
19
            self.error_items.append(id)
20
21
    def write(self):
22
        if self.error > 0:
23
            error_headers = ["File"]
24
            error_result = []
25
            for id in self.error_items:
26
                error_result.append([id])
27
28
            print("****** ERROR DETAILS ******")
29
            print(tabulate(error_result, headers=error_headers))
30
            print("\n")
31
32
        headers = ["Metric", "Count"]
33
        result = [
34
                    ["Success", self.success],
0 ignored issues
show
Wrong hanging indentation (remove 8 spaces).
Loading history...
35
                    ["Error", self.error],
0 ignored issues
show
Wrong hanging indentation (remove 8 spaces).
Loading history...
36
                 ]
0 ignored issues
show
Wrong hanging indentation.
Loading history...
37
38
        print("****** SUMMARY ******")
39
        print(tabulate(result, headers=headers))
40