Ejemplo n.º 1
0
    def goto(
        self,
        row: Optional[int],
        open_selected: bool = False,
        count: Optional[int] = None,
    ):
        """Select specific row in current filelist.

        **syntax:** ``:goto row``

        positional arguments:
            * ``row``: Number of the row to select.

        optional arguments:
            * ``--open-selected``: Automatically open any selected image.

        .. hint:: -1 is the last row.

        **count:** Select [count]th element instead.
        """
        try:
            row = number_for_command(
                row,
                count,
                max_count=self.model().rowCount(),
                number_name="row",
                elem_name="path",
            )
        except ValueError as e:
            raise api.commands.CommandError(str(e))
        self._select_row(row, open_selected_image=open_selected)
Ejemplo n.º 2
0
def goto(index: Optional[int], count: Optional[int] = None) -> None:
    """Select specific image in current filelist.

    **syntax:** ``:goto index``

    positional arguments:
        * ``index``: Number of the image to select.

    .. hint:: -1 is the last image.

    **count:** Select [count]th image instead.
    """
    try:
        index = number_for_command(index, count, max_count=len(_paths))
    except ValueError:
        raise api.commands.CommandError("Either index or count is required")
    _set_index(index)
Ejemplo n.º 3
0
    def goto(self, index: Optional[int], count: Optional[int] = None):
        """Select specific thumbnail in current filelist.

        **syntax:** ``:goto index``


        positional arguments:
            * ``index``: Number of the thumbnail to select.

        .. hint:: -1 is the last thumbnail.

        **count:** Select [count]th thubnail instead.
        """
        try:
            index = number_for_command(index, count, max_count=self.count())
        except ValueError:
            raise api.commands.CommandError(
                "Either index or count is required")
        self._select_index(index)
Ejemplo n.º 4
0
def test_fail_number_for_command():
    with pytest.raises(ValueError):
        commands.number_for_command(None, None, max_count=42)
Ejemplo n.º 5
0
def test_number_for_command(number, count, max_count, expected):
    assert commands.number_for_command(number, count,
                                       max_count=max_count) == expected