Engine module
Provide the class and functions that handles the backend of the application.
This module allows the application to run and process information
Examples:
>>> directory = path.dirname(path.realpath("__file__"))
>>> app = PowerConsumption(root_path=directory)
>>> csv_handler = app.create_csv()
The module contains the following class:
- PowerConsumption
: A class that represents the engine of the application.
The module contains the following functions:
- print_welcome_message
: Prints welcome message.
- set_file_name
: User input for the output file name.
- render_result
: Render the results.
PowerConsumption
dataclass
A class used to represent the game engine.
Attributes:
Name | Type | Description |
---|---|---|
root_path |
str
|
str It is absolute path of the working directory. |
file_name |
str
|
str = "result" It is the name of the file where the data is going to be saved. Default to 'result'. |
Methods:
Name | Description |
---|---|
create_csv |
Returns the handler where the data is going to be save. |
get_path |
Returns the working directory path. |
parse_csv |
Parse the information save and return the total of energy consume. |
Source code in src\backend\engine.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
create_csv()
Returns the handler where the data is going to be save.
Returns:
Name | Type | Description |
---|---|---|
CSVHandler |
CSVHandler
|
Handler of the file where the information is going to be save |
Source code in src\backend\engine.py
73 74 75 76 77 78 79 80 81 82 |
|
get_path()
Returns the working directory path.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
File path with file name |
Source code in src\backend\engine.py
62 63 64 65 66 67 68 69 70 71 |
|
parse_csv()
Parse the information save and return the total of energy consume.
Source code in src\backend\engine.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
start()
Validation of permission for the application to work
Source code in src\backend\engine.py
56 57 58 59 60 |
|
print_welcome_message()
Prints welcome message
Source code in src\backend\engine.py
101 102 103 104 105 |
|
render_result(sum_energy, sum_duration)
Render the results
Source code in src\backend\engine.py
121 122 123 124 125 126 127 |
|
set_file_name(default)
User input for the output file name
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Returns file name selected or 'result' |
Source code in src\backend\engine.py
108 109 110 111 112 113 114 115 116 117 118 |
|