Zappy - Year end project 2
This is a project that Epitech asked us to create in order to allow us to reveiw the notions of the current year.
Loading...
Searching...
No Matches
custom_functions.py
Go to the documentation of this file.
7
8from global_variables import GlobalVariables
9
10
11def perror(global_variables: GlobalVariables, string: str = "This is an error") -> None:
12 """
13 _summary_
14 This is the function in charge of displaying an error on the error channel
15
16 Args:
17 global_variables (GlobalVariables): _description_. This is a class in charge of storing parameters that are global to the program.
18 string (str, optional): _description_. Defaults to "This is an error".
19 """
20
21 if isinstance(string, list):
22 data = string
23 else:
24 data = f"{string}".split("\n")
25 if data[-1] == "":
26 data.pop()
27 for i in data:
28 global_variables.beautify.disp_round_message_box(f"Error: {i}")
29 global_variables.colourise_error.display(
30 global_variables.message_colours.ERROR,
31 (),
32 global_variables.beautify.get_generated_content()
33 )
34 global_variables.colourise_error.display(
35 global_variables.message_colours.DEFAULT,
36 (),
37 ""
38 )
39
40
41def pwarning(global_variables: GlobalVariables, string: str = "This is a warning") -> None:
42 """
43 _summary_
44 This is the function in charge of displaying a warning on the standard channel
45
46 Args:
47 global_variables (GlobalVariables): _description_. This is a class in charge of storing parameters that are global to the program.
48 string (str, optional): _description_. Defaults to "This is a warning".
49 """
50 if isinstance(string, list):
51 data = string
52 else:
53 data = f"{string}".split("\n")
54 if data[-1] == "":
55 data.pop()
56 for i in data:
57 global_variables.beautify.warning_message(i)
58 global_variables.colourise_output.display(
59 global_variables.message_colours.WARNING,
60 (),
61 global_variables.beautify.get_generated_content()
62 )
63 global_variables.colourise_output.display(
64 global_variables.message_colours.DEFAULT,
65 (),
66 ""
67 )
68
69
70def psuccess(global_variables: GlobalVariables, string: str = "This is a success") -> None:
71 """
72 _summary_
73 This is the function in charge of displaying a success on the standard channel
74
75 Args:
76 global_variables (GlobalVariables): _description_. This is a class in charge of storing parameters that are global to the program.
77 string (str, optional): _description_. Defaults to "This is a warning".
78 """
79 if isinstance(string, list):
80 data = string
81 else:
82 data = f"{string}".split("\n")
83 if data[-1] == "":
84 data.pop()
85 for i in data:
86 global_variables.beautify.success_message(i)
87 global_variables.colourise_output.display(
88 global_variables.message_colours.SUCCESS,
89 (),
90 global_variables.beautify.get_generated_content()
91 )
92 global_variables.colourise_output.display(
93 global_variables.message_colours.DEFAULT,
94 (),
95 ""
96 )
97
98
99def pinfo(global_variables: GlobalVariables, string: str = "This is a success") -> None:
100 """
101 _summary_
102 This is the function in charge of displaying an info on the standard channel
103
104 Args:
105 global_variables (GlobalVariables): _description_. This is a class in charge of storing parameters that are global to the program.
106 string (str, optional): _description_. Defaults to "This is a warning".
107 """
108 if isinstance(string, list):
109 data = string
110 else:
111 data = f"{string}".split("\n")
112 if data[-1] == "":
113 data.pop()
114 for i in data:
115 global_variables.beautify.inform_message(i)
116 global_variables.colourise_output.display(
117 global_variables.message_colours.INFO,
118 (),
119 global_variables.beautify.get_generated_content()
120 )
121 global_variables.colourise_output.display(
122 global_variables.message_colours.DEFAULT,
123 (),
124 ""
125 )
126
127
128def pdebug(global_variables: GlobalVariables, string: str = "This is a debug string") -> None:
129 """
130 _summary_
131 This is a function in charge of displaying a string only if the debug variable is set to true (in global variables)
132 """
133 if global_variables.user_arguments.debug:
134 if isinstance(string, list):
135 data = string
136 else:
137 data = f"{string}".split("\n")
138 if data[-1] == "":
139 data.pop()
140 for i in data:
141 global_variables.beautify.message(f"Debug: {i}")
142 global_variables.colourise_output.display(
143 global_variables.message_colours.DEBUG,
144 (),
145 global_variables.beautify.get_generated_content()
146 )
147 global_variables.colourise_output.display(
148 global_variables.message_colours.DEFAULT,
149 (),
150 ""
151 )
None pdebug(GlobalVariables global_variables, str string="This is a debug string")
None pinfo(GlobalVariables global_variables, str string="This is a success")
None perror(GlobalVariables global_variables, str string="This is an error")
None pwarning(GlobalVariables global_variables, str string="This is a warning")
None psuccess(GlobalVariables global_variables, str string="This is a success")