"""
Implementation of a node handling hardcoded tokens. Tokens are a fixed set of strings, usually used for things
like keywords and enum names. In C++ tokens are more efficient than strings for lookup as they are represented
as a single long integer. The Python access methods are set up the same way, though at present there is no
differentiation between strings and tokens in Python code.
"""


class OgnTutorialTokensPy:
    """Exercise access to hardcoded tokens"""

    @staticmethod
    def compute(db) -> bool:
        """
        Run through a list of input tokens and set booleans in a corresponding output array indicating if the
        token appears in the list of hardcoded color names.
        """

        values_to_check = db.inputs.valuesToCheck

        # When assigning the entire array the size does not have to be set in advance
        db.outputs.isColor = [value in [db.tokens.red, db.tokens.green, db.tokens.blue] for value in values_to_check]

        return True
