Source code for pudding.tokens.functions.do.say

"""Control function do.say."""

import re
import sys
import warnings

from ....datatypes.string import String
from ....processor import PAction
from ....processor.context import Context
from .do import Do


[docs] class Say(Do): """Class for `do.say` function. Prints the given string to stdout. """ min_args = 1 max_args = 1 match_re = re.compile(r"(do\.say)\((.*)\)$") value_types = (String,)
[docs] def execute(self, context: Context) -> PAction: """Print to stdout. :param context: Current context object. :returns: Returns PAction.CONTINUE for processor class. """ warnings.warn( "The function 'do.say()' will be deprecated. Use 'out.say()' instead.", DeprecationWarning, ) sys.stdout.write(context.replace_string_vars(self.get_string(0))) return PAction.CONTINUE