def _parse_from_tokens(self, tokens: TokenParser) -> _TheInstructionEmbryo: path_to_create = self._path_parser.parse_from_token_parser(tokens) file_maker_ = self._file_maker_parser.parse(tokens) tokens.report_superfluous_arguments_if_not_at_eol() return _TheInstructionEmbryo(path_to_create, file_maker_)
def parse_from_token_parser(self, parser: TokenParser) -> AssertPhaseInstruction: actual_file_constructor = self._actual_file_parser.parse_from_token_parser( parser) actual_file_assertion_part = parse_file_contents_assertion_part.parse( parser) parser.report_superfluous_arguments_if_not_at_eol() assertion_part_sequence = assertion_part.compose( IdentityAssertionPartWithValidationAndReferences( actual_file_constructor.validator, actual_file_constructor.references), FileConstructorAssertionPart(), ) assertion_part_sequence = assertion_part.compose_with_sequence( assertion_part_sequence, IsExistingRegularFileAssertionPart(), ) assertion_part_sequence = assertion_part.compose_with_sequence( assertion_part_sequence, actual_file_assertion_part, ) return AssertionInstructionFromAssertionPart( assertion_part_sequence, lambda env: actual_file_constructor, actual_file_constructor.failure_message_header, )
def _parse_from_tokens(self, token_parser: TokenParser) -> TheInstructionEmbryoBase: src_path = self._src_path_parser.parse_from_token_parser(token_parser) if token_parser.is_at_eol: return _CopySourceWithoutExplicitDestinationInstruction(src_path) dst_path = self._dst_path_parser.parse_from_token_parser(token_parser) token_parser.report_superfluous_arguments_if_not_at_eol() return _CopySourceWithExplicitDestinationInstruction(src_path, dst_path)
def _parse_file(my_parser: TokenParser) -> FileMaker: src_file = parse_file_ref_from_token_parser(instruction_config.src_rel_opt_arg_conf, my_parser) contents_transformer = parse_optional_transformer_resolver(parser) my_parser.report_superfluous_arguments_if_not_at_eol() return FileMakerForContentsFromExistingFile(instruction_config.source_info, contents_transformer, src_file)
def _parse_from_token_parser(token_parser: TokenParser) -> NameAndValue[Actor]: token_parser.consume_mandatory_keyword( instruction_arguments.ASSIGNMENT_OPERATOR, False) ret_val = token_parser.parse_mandatory_command( _actor_parsers_setup(), concepts.ACTOR_CONCEPT_INFO.singular_name.upper()) token_parser.report_superfluous_arguments_if_not_at_eol() return ret_val
def _parse_from_tokens(self, token_parser: TokenParser) -> InstructionEmbryo[None]: try: phases = self._parse_phases(token_parser) modifier = self._parse_modifier(token_parser) token_parser.report_superfluous_arguments_if_not_at_eol() return _impl.TheInstructionEmbryo(phases, modifier) except TokenSyntaxError as ex: raise SingleInstructionInvalidArgumentException( std_error_message_text_for_token_syntax_error_from_exception(ex))
def _parse_from_start_str(self, here_doc_start: str, token_parser: TokenParser) -> StringSdv: marker_match = re.fullmatch(string.HERE_DOCUMENT_TOKEN_RE, here_doc_start) if not marker_match: return _raise_not_a_here_doc_exception(here_doc_start) marker = marker_match.group(2) token_parser.report_superfluous_arguments_if_not_at_eol() token_parser.consume_current_line_as_string_of_remaining_part_of_current_line( ) return self._parse_contents(marker, token_parser)
def _parse_optional_file_matcher(parser: token_stream_parser.TokenParser ) -> Optional[parse_file_matcher.FileMatcherResolver]: file_matcher = None if not parser.is_at_eol: parser.consume_mandatory_constant_unquoted_string( PROPERTIES_SEPARATOR, must_be_on_current_line=True) file_matcher = parse_file_matcher.parse_resolver(parser, must_be_on_current_line=False) parser.report_superfluous_arguments_if_not_at_eol() return file_matcher
def _parse_optional_file_matcher( parser: token_stream_parser.TokenParser ) -> Optional[FileMatcherSdv]: file_matcher = None if not parser.is_at_eol: parser.consume_mandatory_constant_unquoted_string( reserved_words.COLON, must_be_on_current_line=True) file_matcher = parse_file_matcher.parsers( ).full.parse_from_token_parser(parser) parser.report_superfluous_arguments_if_not_at_eol() return file_matcher
def _parse_from_tokens( self, token_parser: TokenParser) -> InstructionEmbryo[None]: try: token_parser.consume_mandatory_keyword(defs.ASSIGNMENT_IDENTIFIER, False) value = self._parse_value(token_parser) token_parser.report_superfluous_arguments_if_not_at_eol() return _impl.TheInstructionEmbryo(value) except TokenSyntaxError as ex: raise SingleInstructionInvalidArgumentException( std_error_message_text_for_token_syntax_error_from_exception( ex))
def parse_file_maker(instruction_config: InstructionConfig, parser: TokenParser) -> FileMaker: parser.require_has_valid_head_token(instruction_config.syntax_element) head_source_string = parser.token_stream.head.source_string if is_option_string(head_source_string): return _parse_file_maker_with_transformation(instruction_config, parser) else: if head_source_string.startswith(parse_here_document.DOCUMENT_MARKER_PREFIX): contents = parse_here_document.parse_as_last_argument_from_token_parser(True, parser) return FileMakerForConstantContents(contents) else: contents = parse_string_from_token_parser(parser) parser.report_superfluous_arguments_if_not_at_eol() return FileMakerForConstantContents(contents)
def parse(token_parser: TokenParser) -> AssertionPart[ComparisonActualFile, FileToCheck]: string_matcher_resolver = parse_string_matcher.parse_string_matcher(token_parser) token_parser.report_superfluous_arguments_if_not_at_eol() token_parser.consume_current_line_as_string_of_remaining_part_of_current_line() return assertion_part.compose(ConstructFileToCheckAssertionPart(), StringMatcherAssertionPart(string_matcher_resolver))
def _parse_from_tokens(self, token_parser: TokenParser) -> InstructionEmbryo: path = self._path_parser.parse_from_token_parser(token_parser) token_parser.report_superfluous_arguments_if_not_at_eol() return InstructionEmbryo(path)
def _parse_from_tokens(self, token_parser: TokenParser) -> TheInstructionEmbryo: path = self._path_parser.parse_from_token_parser(token_parser) file_maker = self._file_maker_parser.parse(token_parser) token_parser.report_superfluous_arguments_if_not_at_eol() return TheInstructionEmbryo(path, file_maker)