File: base_types.py

package info (click to toggle)
pytango 10.1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,304 kB
  • sloc: python: 27,795; cpp: 16,150; sql: 252; sh: 152; makefile: 43
file content (79 lines) | stat: -rw-r--r-- 1,721 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
# SPDX-FileCopyrightText: All Contributors to the PyTango project
# SPDX-License-Identifier: LGPL-3.0-or-later

"""
This is an internal PyTango module.
"""

__all__ = ("base_types_init",)

__docformat__ = "restructuredtext"

from tango import (
    StdStringVector,
    StdLongVector,
    StdDoubleVector,
    CommandInfoList,
    AttributeInfoList,
    AttributeInfoListEx,
    DbData,
    DbDevInfos,
    DbDevExportInfos,
    DbDevImportInfos,
    DbHistoryList,
    DeviceDataHistoryList,
)


def __StdVector__add(self, seq):
    ret = seq.__class__(self)
    ret.extend(seq)
    return ret


def __StdVector__mul(self, n):
    ret = self.__class__()
    for _ in range(n):
        ret.extend(self)
    return ret


def __StdVector__imul(self, n):
    ret = self.__class__()
    for _ in range(n):
        ret.extend(self)
    return ret


def __fillVectorClass(klass):
    klass.__add__ = __StdVector__add
    klass.__mul__ = __StdVector__mul
    klass.__imul__ = __StdVector__imul


def base_types_init():
    v_klasses = (
        StdStringVector,
        StdLongVector,
        StdDoubleVector,
        CommandInfoList,
        AttributeInfoList,
        AttributeInfoListEx,
        DbData,
        DbDevInfos,
        DbDevExportInfos,
        DbDevImportInfos,
        DbHistoryList,
        DeviceDataHistoryList,
    )

    for v_klass in v_klasses:
        __fillVectorClass(v_klass)

    # Doc string for vectors is easier to add already in Python

    AttributeInfoList.__doc__ = """
    List of AttributeInfo objects, containing available information for the attributes"""

    AttributeInfoListEx.__doc__ = """
    List of AttributeInfoEx objects, containing available information for the attributes"""