File: Atspi.py

package info (click to toggle)
at-spi2-core 2.58.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,148 kB
  • sloc: ansic: 44,812; xml: 1,480; python: 384; sh: 239; makefile: 30; javascript: 13
file content (69 lines) | stat: -rw-r--r-- 1,952 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# AT-SPI - Assistive Technology Service Provider Interface
#
# Copyright 2025 SUSE LLC.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

from ..overrides import override
from ..module import get_introspection_module

Atspi = get_introspection_module('Atspi')

__all__ = []


class Accessible(Atspi.Accessible):

    def __bool__(self):
        return True

    def __eq__(a, b):
        return hash(a) == hash(b)

    def __getitem__(self, i):
        len = self.get_child_count()
        if i < 0:
                i = self + i
        if i < 0 or i >= len:
                raise IndexError
        return self.get_child_at_index(i)

    def __hash__(self):
        if hasattr(self, "_hashval"):
            return self._hashval
        if self.app is not None:
            self._hashval = hash(self.app.bus_name + self.path)
        else:
            self._hashval = super.__hash__(self)
        return self._hashval

    def __len__(self):
        try:
            count = self.get_child_count()
        except:
            return 0
        if count < 0:
            return 0
        return count

    def __ne__(a, b):
        return hash(a) != hash(b)

    def __nonzero__(self):
        return True

Accessible = override(Accessible)
__all__.append('Accessible')