Tower: upload cetmix_tower_server 16.0.2.2.9 (via marketplace)

This commit is contained in:
2026-04-27 08:43:39 +00:00
parent 3f23cfecf3
commit 7264942e8d

View File

@@ -0,0 +1,35 @@
# Copyright (C) 2022 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from random import choices
CHARS = "23456789acefhjkmnprtvwxyz"
def generate_random_id(sections=1, population=4, separator="-"):
"""Generates random id
eg 'ahj2-jer83'
Args:
sections (int, optional): number of sections. Defaults to 1.
population (int, optional): number of symbols per section. Defaults to 4.
separator (str, optional): section separator. Defaults to "-".
Returns:
Str: generated id
"""
if sections < 1 or population < 0:
return None
def get_section():
return "".join(choices(CHARS, k=population))
# Single section
if sections == 1:
return get_section()
# Multiple sections
result = []
for _ in range(sections):
result.append(get_section())
return separator.join(result)