コード例 #1
0
    def write(self,
              string,
              flags=None,
              new_line=False,
              with_indent=True
              ):  # type: (str, Optional[int], bool, bool) -> None
        """
        Writes a string to the output stream.

        The string is formatted before it is written to the output stream.
        """
        if self._may_write(flags):
            if self._indent > 0 and with_indent:
                string = "\n".join((" " * self._indent + s) if s else s
                                   for s in string.split("\n"))

            if self._format_output:
                formatted = self.format(string)
            else:
                formatted = self.remove_format(string)

            if new_line:
                formatted += "\n"

            self._stream.write(to_str(formatted))
コード例 #2
0
ファイル: output.py プロジェクト: pmav99/clikit
 def write_line_raw(self,
                    string,
                    flags=None):  # type: (str, Optional[int]) -> None
     """
     Writes a string to the output stream without formatting.
     """
     if self._may_write(flags):
         self._stream.write(to_str(string.rstrip("\n") + "\n"))
コード例 #3
0
ファイル: output.py プロジェクト: pmav99/clikit
    def write(self, string, flags=None):  # type: (str, Optional[int]) -> None
        """
        Writes a string to the output stream.

        The string is formatted before it is written to the output stream.
        """
        if self._may_write(flags):
            if self._format_output:
                formatted = self.format(string)
            else:
                formatted = self.remove_format(string)

            self._stream.write(to_str(formatted))
コード例 #4
0
ファイル: output.py プロジェクト: pmav99/clikit
    def write_line(self,
                   string,
                   flags=None):  # type: (str, Optional[int]) -> None
        """
        Writes a line of text to the output stream.

        The string is formatted before it is written to the output stream.
        """
        if self._may_write(flags):
            string = string.rstrip("\n")
            if self._format_output:
                formatted = self.format(string)
            else:
                formatted = self.remove_format(string)

            self._stream.write(to_str(formatted + "\n"))