Coverage for src/nos/utils/unique_id.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-19 11:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-19 11:29 +0000
1from datetime import (
2 datetime,
3)
4from uuid import (
5 uuid4,
6)
9class UniqueId:
10 """Unique ID."""
12 def __init__(self, time_stamp: datetime.time = datetime.now()):
13 """Unique ID in the format YYYY_MM_DD_HH_MM_SS-uuid4.
15 Args:
16 time_stamp: Time used for the first part of the ID.
17 """
18 # time part
19 self.time_stamp = time_stamp
20 self.uuid = uuid4()
22 def __str__(self):
23 return self.time_stamp.strftime("%Y_%m_%d_%H_%M_%S-") + str(self.uuid)