Completed
Pull Request — master (#328)
by
unknown
38:42 queued 13:44
created

Tabpage.__repr__()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 6
ccs 3
cts 3
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, handle=%r)' % (
25 5
            self.number,
26
            self.window,
27 5
            self.handle,
28
        )
29
30 5
    @property
31
    def window(self):
32 5
        """Get the `Window` currently focused on the tabpage."""
33
        return self.request('nvim_tabpage_get_win')
34
35 5
    @property
36
    def valid(self):
37
        """Return True if the tabpage still exists."""
38
        return self.request('nvim_tabpage_is_valid')
39
40
    @property
41
    def number(self):
42
        """Get the tabpage number."""
43
        return self.request('nvim_tabpage_get_number')
44