Passed
Pull Request — master (#298)
by
unknown
01:32
created

elodie.log   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 15

10 Functions

Rating   Name   Duplication   Size   Complexity  
A warn() 0 2 1
A error() 0 2 1
A warn_json() 0 2 1
A error_json() 0 2 1
A _print() 0 9 4
A info() 0 2 1
A progress() 0 5 2
A info_json() 0 2 1
A _print_debug() 0 3 2
A all() 0 2 1
1
"""
2
General file system methods.
3
4
.. moduleauthor:: Jaisen Mathai <[email protected]>
5
"""
6
from __future__ import print_function
7
8
from json import dumps
9
10
from elodie import constants
11
12
def all(message):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in all.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
13
    _print(message)
14
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
15
16
def info(message):
17
    _print_debug(message)
18
19
20
def info_json(payload):
21
    _print_debug(dumps(payload))
22
23
24
def progress(message='.', new_line=False):
25
    if not new_line:
26
        print(message, end="")
27
    else:
28
        print(message)
29
30
31
def warn(message):
32
    _print_debug(message)
33
34
35
def warn_json(payload):
36
    _print_debug(dumps(payload))
37
38
39
def error(message):
40
    _print_debug(message)
41
42
43
def error_json(payload):
44
    _print_debug(dumps(payload))
45
46
47
def _print_debug(string):
48
    if(constants.debug is True):
0 ignored issues
show
Unused Code Coding Style introduced by
There is an unnecessary parenthesis after if.
Loading history...
49
        _print(string)
50
51
def _print(s):
52
    try:
53
        print(s)
54
    except UnicodeEncodeError:
55
        for c in s:
56
            try:
57
                print(c, end='')
58
            except UnicodeEncodeError:
59
                print('?', end='')
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...