Structural Bioinformatics Library
Template C++ / Python API for developping structural bioinformatics applications.
SBL.gui_codegen_utils Namespace Reference

Functions

str generate_unique_id ()
str sanitize_name (str name)

Packages

Shared helper utilities for GUI code generators.

This module centralizes small helper functions used across code generator
backends, such as generating short unique IDs for variable names and sanitizing
arbitrary strings into Python-safe identifiers.

Function Documentation

◆ generate_unique_id()

str generate_unique_id ( )
Generate a short unique identifier for variable names.

The identifier combines the current microsecond timestamp (modulo
1,000,000) with a random 4-digit suffix. This is not cryptographically
secure and is intended only for avoiding collisions in generated code.

Returns:
    A unique identifier string such as "123456_9876".

◆ sanitize_name()

str sanitize_name ( str name)
Return a string sanitized for safe Python identifiers.

Replaces non-word characters with underscores and guards against
leading digits by prepending an underscore if needed.

Args:
    name: Original, possibly unsafe name.

Returns:
    A Python-safe identifier (lower fidelity but robust). If ``name`` is
    falsy, a default value like "group" is used.