1 | from typing import Union, List |
||
2 | |||
3 | from cleo import Output, Input |
||
4 | from cleo.styles import CleoStyle |
||
5 | |||
6 | |||
7 | View Code Duplication | class BackupPcCloneStyle(CleoStyle): |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
8 | """ |
||
9 | Output style for py-stratum. |
||
10 | """ |
||
11 | |||
12 | # ------------------------------------------------------------------------------------------------------------------ |
||
13 | def __init__(self, input_object: Input, output_object: Output): |
||
14 | """ |
||
15 | Object constructor. |
||
16 | |||
17 | @param Input input_object: The input object. |
||
18 | @param Output output_object: The output_object object. |
||
19 | """ |
||
20 | CleoStyle.__init__(self, input_object, output_object) |
||
21 | |||
22 | # Create style notes. |
||
23 | output_object.get_formatter().add_style('note', 'yellow', None, ['bold']) |
||
24 | |||
25 | # Create style for data_layer objects. |
||
26 | output_object.get_formatter().add_style('dbo', 'green', None, ['bold']) |
||
27 | |||
28 | # Create style for file and directory names. |
||
29 | output_object.get_formatter().add_style('fso', 'white', None, ['bold']) |
||
30 | |||
31 | # Create style for SQL statements. |
||
32 | output_object.get_formatter().add_style('sql', 'magenta', None, ['bold']) |
||
33 | |||
34 | # ------------------------------------------------------------------------------------------------------------------ |
||
35 | def warning(self, message: Union[str, List]) -> None: |
||
36 | """ |
||
37 | Writes a waring message. |
||
38 | |||
39 | @param str|list[str] message: The message or list of messages. |
||
40 | """ |
||
41 | self.block(message, 'WARNING', 'fg=white;bg=red', padding=True) |
||
42 | |||
43 | # ------------------------------------------------------------------------------------------------------------------ |
||
44 | def text(self, message: Union[str, List]) -> None: |
||
45 | """ |
||
46 | Formats informational text. |
||
47 | |||
48 | @param str|list[str] message: The message or list of messages. |
||
49 | """ |
||
50 | if isinstance(message, list): |
||
51 | messages = message |
||
52 | else: |
||
53 | messages = [message] |
||
54 | |||
55 | for line in messages: |
||
56 | self.writeln(' {0}'.format(line)) |
||
57 | |||
58 | # ------------------------------------------------------------------------------------------------------------------ |
||
59 | def log_verbose(self, message: Union[str, List]) -> None: |
||
60 | """ |
||
61 | Logs a message only when logging level is verbose. |
||
62 | |||
63 | @param str|list[str] message: The message. |
||
64 | """ |
||
65 | if self.get_verbosity() >= Output.VERBOSITY_VERBOSE: |
||
66 | self.writeln(message) |
||
67 | |||
68 | # ------------------------------------------------------------------------------------------------------------------ |
||
69 | def log_very_verbose(self, message: Union[str, List]) -> None: |
||
70 | """ |
||
71 | Logs a message only when logging level is very verbose. |
||
72 | |||
73 | @param str|list[str] message: The message. |
||
74 | """ |
||
75 | if self.get_verbosity() >= Output.VERBOSITY_VERY_VERBOSE: |
||
76 | self.writeln(message) |
||
77 | |||
78 | # ---------------------------------------------------------------------------------------------------------------------- |
||
79 |