def setLoggingDebugActionForParserElement( parser_element: pyparsing.ParserElement) -> None: ''' helper function to set up the custom debug actions for a ParserElement with our own functions that use the logging framework rather than `print()` this also calls setDebug(True) for the parser element as well ''' parser_element.setDebug(True) parser_element.setDebugActions(pyparsingLoggingStartDebugAction, pyparsingLoggingSuccessDebugAction, pyparsingLoggingExceptionDebugAction)
def add_element(name: str, value: pp.ParserElement): nonlocal self if self.debug: value.setName(name) value.setDebug() return value