14 """This contains common helpers for generating randomized data."""
21 ALPHANUM = string.ascii_letters + string.digits
24 ALPHANUM_LOWERCASE = string.ascii_lowercase + string.digits
27 def rand_string(length: int = 8, *, lowercase: bool =
False) -> str:
28 """Return random alphanumeric string of given length.
30 Space for default arguments: alphabet^length
31 lowercase and uppercase = (26*2 + 10)^8 = 2.18e14 = 218 trillion.
32 lowercase only = (26 + 10)^8 = 2.8e12 = 2.8 trillion.
34 alphabet = ALPHANUM_LOWERCASE
if lowercase
else ALPHANUM
35 return ''.join(random.choices(population=alphabet, k=length))
39 """Return a ready-to-use resource suffix with datetime and nonce."""
49 return f
'{datetime_suffix}-{unique_hash}'