Completed
Pull Request — master (#328)
by
unknown
43:07 queued 18:31
created

Tabpage.__repr__()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
"""API for working with Nvim tabpages."""
2 5
from .common import Remote, RemoteSequence
3
4
5 5
__all__ = ('Tabpage')
6
7
8 5
class Tabpage(Remote):
9
    """A remote Nvim tabpage."""
10
11 5
    _api_prefix = "nvim_tabpage_"
12
13 5
    def __init__(self, *args):
14
        """Initialize from session and code_data immutable object.
15
16
        The `code_data` contains serialization information required for
17
        msgpack-rpc calls. It must be immutable for Buffer equality to work.
18
        """
19 5
        super(Tabpage, self).__init__(*args)
20 5
        self.windows = RemoteSequence(self, 'nvim_tabpage_list_wins')
21
22 5
    def __repr__(self):
23
        """Get text representation of the tabpage."""
24
        return 'Tabpage(number=%r, window=%r)' % (
25 5
            self.number,
26
            self.window,
27 5
        )
28
29
    @property
30 5
    def window(self):
31
        """Get the `Window` currently focused on the tabpage."""
32 5
        return self.request('nvim_tabpage_get_win')
33
34
    @property
35 5
    def valid(self):
36
        """Return True if the tabpage still exists."""
37
        return self.request('nvim_tabpage_is_valid')
38
39
    @property
40
    def number(self):
41
        """Get the tabpage number."""
42
        return self.request('nvim_tabpage_get_number')
43