-
-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathreports.py
More file actions
24 lines (19 loc) · 648 Bytes
/
reports.py
File metadata and controls
24 lines (19 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"A Singleton Dictionary of Reported Events"
import time
class Reports():
"A Singleton Dictionary of Reported Events"
_reports: dict[int, tuple[float, str]] = {} # Python 3.9
# _reports = {} # Python 3.8 or earlier
_row_id = 0
def __new__(cls):
return cls
@classmethod
def get_history(cls) -> dict:
"A method to retrieve all historic events"
return cls._reports
@classmethod
def log_event(cls, event: str) -> bool:
"A method to add a new event to the record"
cls._reports[cls._row_id] = (time.time(), event)
cls._row_id = cls._row_id + 1
return True