def parse_from_token_parser( self, parser: TokenParser) -> ComparisonActualFileConstructor: parser.require_is_not_at_eol('Missing {actual_file} argument'.format( actual_file=ACTUAL_PATH_ARGUMENT.name)) path = self._path_parser.parse_from_token_parser(parser) parser.consume_mandatory_constant_unquoted_string( reserved_words.COLON, must_be_on_current_line=False) return actual_files.ConstructorForPath( path, actual_file_attributes.PLAIN_FILE_OBJECT_NAME, True)
def parse_integer_matcher(parser: TokenParser, name_of_lhs: str = 'LHS') -> IntegerMatcher: comparison_operator = parse_comparison_operator(parser) parser.require_is_not_at_eol(_MISSING_INTEGER_ARGUMENT) token = parser.consume_mandatory_token(_MISSING_INTEGER_ARGUMENT) try: integer_arg = python_evaluate(token.string) return IntegerMatcherFromComparisonOperator(name_of_lhs, comparison_operator, integer_arg) except NotAnIntegerException as ex: raise SingleInstructionInvalidArgumentException('Not an integer: ' + ex.value_string)
def parse_regex2(parser: TokenParser, must_be_on_same_line: bool = True, consume_last_here_doc_line: bool = False) -> Tuple[SourceType, RegexResolver]: if must_be_on_same_line: parser.require_is_not_at_eol(MISSING_REGEX_ARGUMENT_ERR_MSG) is_ignore_case = parser.consume_and_handle_optional_option(False, lambda x: True, IGNORE_CASE_OPTION_NAME) if must_be_on_same_line: parser.require_is_not_at_eol(MISSING_REGEX_ARGUMENT_ERR_MSG) source_type, regex_pattern = parse_string_or_here_doc_from_token_parser(parser, consume_last_here_doc_line) return source_type, _RegexResolver(is_ignore_case, regex_pattern)
def parse_files_matcher(parser: TokenParser, must_be_on_current_line: bool = True) -> FilesMatcherResolver: if must_be_on_current_line: parser.require_is_not_at_eol('Missing ' + syntax_elements.FILES_MATCHER_SYNTAX_ELEMENT.singular_name) mb_file_selector = parse_file_matcher.parse_optional_selection_resolver2(parser) expectation_type = parser.consume_optional_negation_operator() ret_val = _SIMPLE_MATCHER_PARSER.parse(parser) if expectation_type is ExpectationType.NEGATIVE: ret_val = negation.negation_matcher(ret_val) if mb_file_selector is not None: ret_val = sub_set_selection.sub_set_selection_matcher(mb_file_selector, ret_val) return ret_val
def parse_from_token_parser(self, parser: TokenParser) -> ComparisonActualFileConstructor: parser.require_is_not_at_eol( 'Missing {actual_file} argument'.format(actual_file=ACTUAL_PATH_ARGUMENT.name)) file_ref = parse_file_ref.parse_file_ref_from_token_parser(ACTUAL_RELATIVITY_CONFIGURATION, parser) return actual_files.ComparisonActualFileConstructorForConstant(ActComparisonActualFileForFileRef(file_ref))
def parse_from_token_parser(self, parser: TokenParser) -> CommandSdv: parser.require_is_not_at_eol('Missing {COMMAND}', _PARSE_FORMAT_MAP) arguments = self._arguments(parser) return command_sdvs.for_shell(arguments)
def parse_as_command(parser: TokenParser) -> CommandResolver: parser.require_is_not_at_eol('Missing {COMMAND}', _PARSE_FORMAT_MAP) argument = parse_string.parse_rest_of_line_as_single_string_and_consume_line(parser) return command_resolvers.for_shell(argument)
def parse_from_token_parser(self, parser: TokenParser) -> PARSE_RESULT: parser.require_is_not_at_eol(self._error_message_if_current_line_empty) return self._with_non_empty_current_line.parse_from_token_parser( parser)