예제 #1
0
 def _children_renderer(self) -> SequenceRenderer[MinorBlock]:
     return rend_comb.ConcatenationR(
         [
             TreeRendererToMinorBlocks(self._configuration, child)
             for child in self._tree.children
         ]
     )
예제 #2
0
    def visit_indented(self, x: IndentedDetail) -> Sequence[LineElement]:
        details_renderer = rend_comb.ConcatenationR([
            self._renderer_for_next_depth(value)
            for value in x.details
        ])

        return details_renderer.render_sequence()
예제 #3
0
    def render_sequence(self) -> Sequence[MajorBlock]:
        everything = rend_comb.ConcatenationR([
            self._failure_info.accept(_GetFailureInfoLocationRenderer()),
            failure_details.FailureDetailsRenderer(self._failure_info.failure_details),
        ])

        return everything.render_sequence()
예제 #4
0
def _suite_read_error_renderer(ex: SuiteReadError) -> SequenceRenderer[MajorBlock]:
    blocks_renderers = [
        source_location.location_blocks_renderer(ex.source_location,
                                                 ex.maybe_section_name,
                                                 None),
        _error_message_blocks__read_error(ex),
    ]
    return comb.ConcatenationR(blocks_renderers)
예제 #5
0
 def validate(self) -> Optional[TextRenderer]:
     mb_str_src_err_msg_renderer = self._string_source.validator.validate_post_sds_if_applicable(
         self._tcds)
     return (None if mb_str_src_err_msg_renderer is None else
             rend_comb.ConcatenationR([
                 text_docs.single_line(_STDIN_VALIDATION_ERROR_HEADER),
                 rend_comb.Indented(mb_str_src_err_msg_renderer),
             ]))
예제 #6
0
def location_minor_blocks_renderer(
        source_location: Optional[SourceLocationPath],
        section_name: Optional[str],
        description: Optional[str]) -> SequenceRenderer[MinorBlock]:
    return comb.ConcatenationR([
        section_and_source(section_name,
                           _location_path_and_source_blocks(source_location)),
        _OptionalDescriptionRenderer(description),
    ])
예제 #7
0
def details_renderer_to_line_elements(configuration: RenderingConfiguration[NODE_DATA],
                                      details: Sequence[Detail]
                                      ) -> SequenceRenderer[LineElement]:
    return rend_comb.ConcatenationR(
        [
            _LineElementRendererForDetail(configuration, 0, detail)
            for detail in details
        ]
    )
예제 #8
0
 def _failure_message(self,
                      model_getter: ModelGetter[MODEL],
                      model: MODEL,
                      result: MatchingResult,
                      ) -> TextRenderer:
     return rend_comb.ConcatenationR([
         self._failure_message_config.head(model_getter, model),
         rend_comb.SingletonSequenceR(rendering__node_bool.BoolTraceRenderer(result.trace)),
         self._failure_message_config.tail(model_getter, model),
     ])
예제 #9
0
    def render_sequence(self) -> Sequence[MajorBlock]:
        renderers = [
            source_location.location_blocks_renderer(
                self._error_info.source_location_path,
                self._error_info.maybe_section_name, None),
            error_description.ErrorDescriptionRenderer(
                self._error_info.description),
        ]

        return comb.ConcatenationR(renderers).render_sequence()
예제 #10
0
def section_and_source(
    section_name: Optional[str],
    source_info: SequenceRenderer[MinorBlock],
) -> SequenceRenderer[MinorBlock]:
    sequence_renderers = []
    if section_name is not None:
        sequence_renderers.append(
            blocks.MinorBlocksOfSingleLineObject(
                _InSectionHeaderRenderer(section_name)))
    sequence_renderers.append(source_info)
    return comb.ConcatenationR(sequence_renderers)
예제 #11
0
 def _minor_blocks_renderer(self) -> SequenceRenderer[MinorBlock]:
     return rend_comb.ConcatenationR([
         path_rendering.HeaderAndPathMinorBlocks.of_string_header(
             self._SRC_PATH_HEADER,
             self._src_dir.child(self._file_name).describer,
         ),
         path_rendering.HeaderAndPathMinorBlocks.of_string_header(
             self._DST_PATH_HEADER,
             self._dst_dir.child(self._file_name).describer,
         ),
     ])
예제 #12
0
    def visit_tree(self, x: TreeDetail) -> Sequence[LineElement]:
        tree = x.tree

        details_renderer = rend_comb.ConcatenationR([
            self._renderer_for_next_depth(detail)
            for detail in tree.details
        ])

        children_renderer = rend_comb.ConcatenationR([
            self._renderer_for_next_depth(TreeDetail(child, x.header_text_style))
            for child in tree.children
        ])

        ret_val = [
            LineElement(structure.StringLineObject(str(tree.header)),
                        self._text_styled_root_element_properties(x.header_text_style))
        ]
        ret_val += details_renderer.render_sequence()
        ret_val += children_renderer.render_sequence()

        return ret_val
예제 #13
0
    def visit_header_and_value(self, x: HeaderAndValueDetail) -> Sequence[LineElement]:
        value_elements_renderer = rend_comb.ConcatenationR([
            self._renderer_for_next_depth(value)
            for value in x.values
        ])

        ret_val = [
            LineElement(structure.StringLineObject(str(x.header)),
                        self._text_styled_root_element_properties(x.header_text_style))
        ]

        ret_val += value_elements_renderer.render_sequence()

        return ret_val
예제 #14
0
    def _renderer(self, failing_symbol: str,
                  symbols: SymbolTable) -> TextRenderer:
        major_blocks_sequence = []

        if self.meaning_of_failure:
            major_blocks_sequence.append(self.meaning_of_failure)

        error = self.error

        major_blocks_sequence.append(error.message)

        major_blocks_sequence.append(
            _path_to_failing_symbol(failing_symbol,
                                    self.path_to_failing_symbol, symbols))

        if error.how_to_fix is not None:
            major_blocks_sequence.append(error.how_to_fix)

        return combinators.ConcatenationR(major_blocks_sequence)