def _result_for_exception(self, path: DescribedPath, ex: Exception) -> MatchingResult: tb = (self.__tb_with_expected().append_details( details.HeaderAndValue( types.PATH_TYPE_INFO.singular_name.capitalize(), custom_details.PathDdvDetailsRenderer( path.describer))).append_details( details.HeaderAndValue('Error', details.String(ex)))) return tb.build_result(False)
def _renderer(self) -> StructureRenderer: return renderers.NodeRendererFromParts( names.REPLACE_TRANSFORMER_NAME, None, ( self._lines_selection_renderer(), custom_details.optional_option(names.PRESERVE_NEW_LINES_OPTION_NAME, self._preserve_new_lines), details.HeaderAndValue(self._PATTERN_HEADER, self._pattern), details.HeaderAndValue(self._REPLACEMENT_HEADER, self._replacement), ), (), )
def _file( path: Renderer[str], mb_matcher: Optional[TSD], ) -> DetailsRenderer: path_string = path.render() return (details.String(path_string) if mb_matcher is None else details.HeaderAndValue( path_string, custom_details.WithTreeStructure(mb_matcher)))
def _renderer(self) -> DetailsRenderer: header_parts = [ _FORMATTED_FILE_TYPE_TOKENS[self._file_type], self._file_name ] if self._contents_description is not None: header_parts.append( syntax.MODIFICATION_VARIANT_TOKENS[self._modification_type]) header = ' '.join(header_parts) return (details.String(header) if self._contents_description is None else details.HeaderAndValue( header, self._contents_description))
def _report_final_element(self, tb: TraceBuilder, result: MatchingResult, element: ELEMENT) -> MatchingResult: header = (self._matching_element_header() if result.value else self._non_matching_element_header()) actual = custom_details.actual( details.HeaderAndValue( header, self._conf.setup.rendering.renderer(element), )) tb.append_details(actual) tb.append_child(result.trace) return tb.build_result(result.value)
def render(self) -> Node[bool]: renderer = custom_details.ExpectedAndActual( _expected_file_names_renderer(self._applier.files_condition), custom_details.string_list(_files_in_model_list(self._actual)), details.HeaderAndValue( common.UNEXPECTED_NAME, details.String(self._unexpected_file.relative_to_root_dir), ) ) return Node(self._applier.name, False, renderer.render(), (), )
def _description_of(path: DetailsRenderer) -> DetailsRenderer: return details.HeaderAndValue(_DESCRIPTION_HEADER, path)
def _mk_detail(option: a.Option, limit: DetailsRenderer) -> DetailsRenderer: return details.HeaderAndValue(option_syntax.option_syntax(option.name), limit)