diff --git a/utils/enums.py b/utils/enums.py index 0aa9447e..fa89e7b2 100644 --- a/utils/enums.py +++ b/utils/enums.py @@ -99,7 +99,7 @@ def build_enum_data(enum_class): from enum import IntFlag class HtkIntFlag(IntFlag): - """ HTK IntFlag + """HTK IntFlag Wrapper around Python's built-in `enum.IntFlag` to provide extra functionalities. @@ -107,8 +107,39 @@ class HtkIntFlag(IntFlag): Requires: Python 3.6 or greater Reference: https://docs.python.org/3.6/library/enum.html#enum.IntFlag """ + + @classmethod + def display(cls, int_value) -> list[str]: + """Get human-readable display names for combined flag values. + + Decomposes combined flag values using list_flags(), then uses + get_enum_symbolic_name() to format each flag. + + Args: + int_value: Combined flag value (e.g., 3 = BICEPS_BRACHII | BRACHIALIS) + + Returns: + List of human-readable flag names + + Example: + class Muscle(HtkIntFlag): + UNSPECIFIED = 0 + BICEPS_BRACHII = 1 + BRACHIALIS = 2 + BRACHIORADIALIS = 4 + TRICEPS_BRACHII = 8 + + Muscle.display(3) # ['Biceps Brachii', 'Brachialis'] + Muscle.display(1) # ['Biceps Brachii'] + """ + result = [ + get_enum_symbolic_name(flag) + for flag in cls.list_flags(int_value) + ] + return result + @classmethod - def list_flags(cls, int_value): + def list_flags(cls, int_value) -> list[HtkIntFlag]: """List Flags Returns the list of flags that value contains, running bitwise