Utilities Module
Module contents
- exception beautifuljason.utils.InvalidUUIDError
Bases:
ValueError
Exception raised for invalid UUID strings.
- beautifuljason.utils.check_uuid_str(uuid_str) str
Validates a UUID string.
- Parameters:
uuid_str (
str
) – The UUID string to validate.- Returns:
The validated UUID string.
- Return type:
str
- Raises:
InvalidUUIDError – If the provided string is not a valid UUID.
- beautifuljason.utils.create_uuid() str
Generates a UUID string in a specific format.
- Returns:
A UUID string enclosed in curly braces.
- Return type:
str
- beautifuljason.utils.ensure_str(str_: str | bytes) str
Ensures the input is a string, decoding if it’s bytes.
- Parameters:
str (
str
|bytes
) – The input string or bytes.- Returns:
The decoded string if input was bytes, or the original string.
- Return type:
str
- beautifuljason.utils.group_to_list(group, path)
Converts a group to a sorted list based on numeric keys.
- Parameters:
group (
h5py.Group
) – The group object to be converted.path (
str
) – The path within the group to be converted.
- Returns:
A list of values sorted by their numeric keys.
- Return type:
list
- beautifuljason.utils.nuclide_str(isotope, name) str
Constructs a nuclide string from isotope and name.
- Parameters:
isotope – The isotope number.
name (
str
) – The name of the nuclide.
- Returns:
A string representation of the nuclide, or an empty string if either argument is missing.
- Return type:
str