def parse(self, token_parser: TokenParser) -> StringTransformerSdv: token_parser.require_has_valid_head_token(_REGEX_ARGUMENT.name) mb_line_matcher = self._parser_of_lines_selection.parse_from_token_parser(token_parser) preserve_new_lines = token_parser.consume_optional_option(names.PRESERVE_NEW_LINES_OPTION_NAME) regex_sdv = self._parser_of_regex.parse_from_token_parser(token_parser) replacement = self._parser_of_replacement.parse(token_parser) return _impl.Sdv(mb_line_matcher, preserve_new_lines, regex_sdv, replacement)
def _parse_setup( self, token_parser: TokenParser ) -> Tuple[str, ModelGetterSdv[ExitCodeAndStderrFile]]: if token_parser.consume_optional_option( defs.OUTPUT_FROM_PROGRAM_OPTION_NAME): program = self._program_parser.parse_from_token_parser( token_parser) return texts.OBJECT__PROGRAM, getter_from_program.model_getter( program) else: return texts.OBJECT__ATC, getter_from_atc.model_getter()
def parse(self, program_option: Token, token_parser: TokenParser) -> StringSourceSdv: is_ignore_exit_code = token_parser.consume_optional_option( defs.IGNORE_EXIT_CODE) program = _PROGRAM_PARSER.parse_from_token_parser(token_parser) return sdvs.ProgramOutputStringSourceSdv( program_option.string, is_ignore_exit_code, self._output_file_to_capture, program, )
def parse_from_token_parser(self, parser: TokenParser) -> bool: return parser.consume_optional_option(self._option)
def _parse_matches(parser: TokenParser) -> FilesMatcherSdv: is_full = parser.consume_optional_option(config.MATCHES_FULL_OPTION.name) fc = _FILES_CONDITION_COMPONENT_PARSER.parse_from_token_parser(parser) return (matches_full.sdv(fc) if is_full else matches_non_full.sdv(fc))
def parse(token_parser: TokenParser) -> StringTransformerSdv: is_ignore_exit_code = token_parser.consume_optional_option( names.RUN_WITH_IGNORED_EXIT_CODE_OPTION_NAME) program = _PROGRAM_PARSER.parse_from_token_parser(token_parser) return sdv.sdv(is_ignore_exit_code, program)