Coverage for src / sparkle / tools / general.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-21 15:31 +0000

1"""General tools for Sparkle.""" 

2 

3import time 

4import random 

5import os 

6 

7 

8def get_time_pid_random_string() -> str: 

9 """Return a combination of time, Process ID, and random int as string. 

10 

11 Returns: 

12 A random string composed of time, PID and a random positive integer value. 

13 """ 

14 time_stamp = time.strftime("%Y-%m-%d-%H.%M.%S", time.localtime(time.time())) 

15 return f"{time_stamp}_{os.getpid()}_{int(random.getrandbits(32))}"