Exemple #1
0
    def _get_pprint_size(max_lines=None, max_width=None):
        """Get the output size (number of lines and character width) for Column and
        Table pformat/pprint methods.

        If no value of ``max_lines`` is supplied then the height of the
        screen terminal is used to set ``max_lines``.  If the terminal
        height cannot be determined then the default will be determined
        using the ``astropy.table.conf.max_lines`` configuration item. If a
        negative value of ``max_lines`` is supplied then there is no line
        limit applied.

        The same applies for max_width except the configuration item is
        ``astropy.table.conf.max_width``.

        Parameters
        ----------
        max_lines : int or None
            Maximum lines of output (header + data rows)

        max_width : int or None
            Maximum width (characters) output

        Returns
        -------
        max_lines, max_width : int

        """
        # Declare to keep static type checker happy.
        lines = None
        width = None

        if max_lines is None:
            max_lines = conf.max_lines

        if max_width is None:
            max_width = conf.max_width

        if max_lines is None or max_width is None:
            lines, width = terminal_size()

        if max_lines is None:
            max_lines = lines
        elif max_lines < 0:
            max_lines = sys.maxsize
        if max_lines < 8:
            max_lines = 8

        if max_width is None:
            max_width = width
        elif max_width < 0:
            max_width = sys.maxsize
        if max_width < 10:
            max_width = 10

        return max_lines, max_width
Exemple #2
0
 def test_format0(self, table_type):
     """Try getting screen size but fail to defaults because testing doesn't
     have access to screen (fcntl.ioctl fails).
     """
     self._setup(table_type)
     arr = np.arange(4000, dtype=np.float64).reshape(100, 40)
     lines = table_type(arr).pformat()
     nlines, width = console.terminal_size()
     assert len(lines) == nlines
     for line in lines[:-1]:  # skip last "Length = .. rows" line
         assert width - 10 < len(line) <= width
Exemple #3
0
 def test_format0(self, table_type):
     """Try getting screen size but fail to defaults because testing doesn't
     have access to screen (fcntl.ioctl fails).
     """
     self._setup(table_type)
     arr = np.arange(4000, dtype=np.float64).reshape(100, 40)
     lines = table_type(arr).pformat()
     nlines, width = console.terminal_size()
     assert len(lines) == nlines
     for line in lines[:-1]:  # skip last "Length = .. rows" line
         assert width - 10 < len(line) <= width
Exemple #4
0
 def _handle_resize(self, signum=None, frame=None):
     terminal_width = terminal_size(self._file)[1]
     self._bar_length = terminal_width - 37
Exemple #5
0
 def _handle_resize(self, signum=None, frame=None):
     terminal_width = terminal_size(self._file)[1]
     self._bar_length = terminal_width - 37