Ejemplo n.º 1
0
def single_pre_formatted_line_object(x: Any,
                                     is_line_ended: bool = False
                                     ) -> TextRenderer:
    """
    :param is_line_ended: Tells if the string str(x) ends with a new-line character.
    :param x: __str__ gives the string
    """
    return blocks.MajorBlocksOfSingleLineObject(
        line_objects.PreFormattedString(x, is_line_ended))
Ejemplo n.º 2
0
 def visit_file_access_error(self, ex: exceptions.FileAccessError) -> None:
     error_info = ErrorInfo(
         error_description.file_access_error_of_message(
             line_elements.SingleLineObject(
                 line_objects.PreFormattedString(ex.message))),
         source_location_path_of_non_empty_location_path(ex.location_path),
         section_name=ex.maybe_section_name,
     )
     raise AccessorError(AccessErrorType.FILE_ACCESS_ERROR, error_info)
Ejemplo n.º 3
0
 def visit_file_source_error(self, ex: exceptions.FileSourceError) -> None:
     error_info = ErrorInfo(
         error_description.syntax_error_of_message(
             line_elements.SingleLineObject(
                 line_objects.PreFormattedString(ex.message))),
         source_location_path_of_non_empty_location_path(ex.location_path),
         section_name=ex.maybe_section_name,
     )
     raise ProcessError(error_info)
Ejemplo n.º 4
0
def os_exception_error_message(ex: OSError) -> TextRenderer:
    return blocks.MajorBlocksOfSingleLineObject(
        line_objects.PreFormattedString(
            str_constructor.FormatMap(
                _OS_EXCEPTION_ERROR_MESSAGE, {
                    'msg': ex.strerror,
                    'errno': ex.errno,
                    'filename': ex.filename,
                    'filename2': ex.filename2,
                })))
def stderr_contents_block(stderr_contents: str) -> Renderer[MinorBlock]:
    if not stderr_contents:
        stderr_contents = '<empty>'
    return comp_rend.MinorBlockR(
        combinators.SequenceR([
            comp_rend.LineElementR(
                line_objects.PreFormattedString(
                    texts.OUTPUT_ON_STDERR__HEADER)),
            comp_rend.LineElementR(
                line_objects.PreFormattedString.of_str(stderr_contents)),
        ]))
Ejemplo n.º 6
0
def single_pre_formatted(s: str) -> SequenceRenderer[LineElement]:
    return SingleLineObject(line_objects.PreFormattedString(s))
Ejemplo n.º 7
0
def _of_path(path: pathlib.Path) -> Renderer[LineElement]:
    return comp_rend.LineElementR(
        line_objects.PreFormattedString(path)
    )
Ejemplo n.º 8
0
def of_constant_message(message: str) -> ErrorDescription:
    return ErrorDescriptionOfMessage(
        blocks.MinorBlocksOfSingleLineObject(
            line_objects.PreFormattedString(message)))
 def exit_code_block() -> Renderer[MinorBlock]:
     return blocks.MinorBlockOfSingleLineObject(
         line_objects.PreFormattedString(_actual_exit_code_line(exit_code)))