Total Complexity | 15 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
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): |
||
13 | _print(message) |
||
14 | |||
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): |
||
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='') |