File: db.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 (870 lines) | stat: -rw-r--r-- 34,389 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# SPDX-FileCopyrightText: All Contributors to the PyTango project
# SPDX-License-Identifier: LGPL-3.0-or-later

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

__all__ = ("db_init",)

__docformat__ = "restructuredtext"

import collections.abc

from tango import (
    StdStringVector,
    Database,
    DbDatum,
    DbData,
    DbDevInfo,
    DbDevInfos,
    DbDevExportInfo,
    DbDevExportInfos,
)

from tango.utils import (
    _trace_client,
    is_non_str_seq,
    seq_2_DbDevInfos,
    seq_2_DbDevExportInfos,
    seq_2_DbData,
    DbData_2_dict,
    parameter_2_dbdata,
)

# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
# DbDatum extension
# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-


def __DbDatum___setitem(self, k, v):
    self.value_string[k] = v


def __DbDatum___delitem(self, k):
    self.value_string.__delitem__(k)


def __DbDatum_append(self, v):
    self.value_string.append(v)


def __DbDatum_extend(self, v):
    self.value_string.extend(v)


def __DbDatum___imul(self, n):
    self.value_string *= n


def __init_DbDatum():
    DbDatum.__len__ = lambda self: len(self.value_string)
    DbDatum.__getitem__ = lambda self, k: self.value_string[k]
    DbDatum.__setitem__ = __DbDatum___setitem
    DbDatum.__delitem__ = __DbDatum___delitem
    DbDatum.__iter__ = lambda self: self.value_string.__iter__()
    DbDatum.__contains__ = lambda self, v: self.value_string.__contains__(v)
    DbDatum.__add__ = lambda self, seq: self.value_string + seq
    DbDatum.__mul__ = lambda self, n: self.value_string * n
    DbDatum.__imul__ = __DbDatum___imul
    DbDatum.append = __DbDatum_append
    DbDatum.extend = __DbDatum_extend


#    DbDatum.__str__      = __DbDatum___str__
#    DbDatum.__repr__      = __DbDatum___repr__

# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
# Database extension
# -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-


def __Database__add_server(self, servname, dev_info, with_dserver=False):
    """
    add_server( self, servname, dev_info, with_dserver=False) -> None

            Add a (group of) devices to the database. This is considered as a
            low level call because it may render the database inconsistent
            if it is not used properly.

            If *with_dserver* parameter is set to False (default), this
            call will only register the given dev_info(s). You should include
            in the list of dev_info an entry to the usually hidden **DServer**
            device.

            If *with_dserver* parameter is set to True, the call will add an
            additional **DServer** device if it is not included in the
            *dev_info* parameter.

        Example using *with_dserver=True*::

            dev_info1 = DbDevInfo()
            dev_info1.name = 'my/own/device'
            dev_info1._class = 'MyDevice'
            dev_info1.server = 'MyServer/test'
            db.add_server(dev_info1.server, dev_info1, with_dserver=True)

        Same example using *with_dserver=False*::

            dev_info1 = DbDevInfo()
            dev_info1.name = 'my/own/device'
            dev_info1._class = 'MyDevice'
            dev_info1.server = 'MyServer/test'

            dev_info2 = DbDevInfo()
            dev_info2.name = 'dserver/' + dev_info1.server
            dev_info2._class = 'DServer
            dev_info2.server = dev_info1.server

            dev_info = dev_info1, dev_info2
            db.add_server(dev_info1.server, dev_info)

        .. versionadded:: 8.1.7
            added *with_dserver* parameter

        Parameters :
            - servname : (str) server name
            - dev_info : (sequence<DbDevInfo> | DbDevInfos | DbDevInfo) containing the server device(s) information
            - with_dserver: (bool) whether or not to auto create **DServer** device in server
        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """

    if not isinstance(dev_info, collections.abc.Sequence) and not isinstance(
        dev_info, DbDevInfo
    ):
        raise TypeError("Value must be a DbDevInfos, a seq<DbDevInfo> or a DbDevInfo")

    if isinstance(dev_info, DbDevInfos):
        pass
    elif isinstance(dev_info, DbDevInfo):
        dev_info = seq_2_DbDevInfos((dev_info,))
    else:
        dev_info = seq_2_DbDevInfos(dev_info)
    if with_dserver:
        has_dserver = False
        for i in dev_info:
            if i._class == "DServer":
                has_dserver = True
                break
        if not has_dserver:
            dserver_info = DbDevInfo()
            dserver_info.name = "dserver/" + dev_info[0].server
            dserver_info._class = "DServer"
            dserver_info.server = dev_info[0].server
            dev_info.append(dserver_info)
    self._add_server(servname, dev_info)


def __Database__export_server(self, dev_info):
    """
    export_server(self, dev_info) -> None

            Export a group of devices to the database.

        Parameters :
            - devinfo : (sequence<DbDevExportInfo> | DbDevExportInfos | DbDevExportInfo)
                        containing the device(s) to export information
        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """

    if not isinstance(dev_info, collections.abc.Sequence) and not isinstance(
        dev_info, DbDevExportInfo
    ):
        raise TypeError(
            "Value must be a DbDevExportInfos, a seq<DbDevExportInfo> or "
            "a DbDevExportInfo"
        )

    if isinstance(dev_info, DbDevExportInfos):
        pass
    elif isinstance(dev_info, DbDevExportInfo):
        dev_info = seq_2_DbDevExportInfos(
            (dev_info),
        )
    else:
        dev_info = seq_2_DbDevExportInfos(dev_info)
    self._export_server(dev_info)


def __generic_get_property(obj_name, value, f):
    new_value = parameter_2_dbdata(value, "value")
    f(obj_name, new_value)
    return new_value, value if isinstance(value, collections.abc.Mapping) else {}


def __Database__generic_get_property(self, obj_name, value, f):
    """internal usage"""

    new_value, ret = __generic_get_property(obj_name, value, f)
    return DbData_2_dict(new_value, ret)


def __Database__generic_put_property(self, obj_name, value, f):
    """internal usage"""
    value = parameter_2_dbdata(value, "value")
    return f(obj_name, value)


def __Database__generic_delete_property(self, obj_name, value, f):
    """internal usage"""
    value = parameter_2_dbdata(value, "value")
    return f(obj_name, value)


def __Database__generic_get_attr_pipe_property(self, obj_name, value, f):
    """internal usage for class or device attribute and pipe properties."""

    new_value, ret = __generic_get_property(obj_name, value, f)
    nb_items = len(new_value)
    i = 0
    while i < nb_items:
        db_datum = new_value[i]
        curr_dict = {}
        ret[db_datum.name] = curr_dict
        nb_props = int(db_datum[0])
        i += 1
        for k in range(nb_props):
            db_datum = new_value[i]
            curr_dict[db_datum.name] = db_datum.value_string
            i += 1

    return ret


def __Database__generic_put_attr_pipe_property(self, obj_name, value, f):
    """internal usage for class or device attribute and pipe properties."""
    new_value = parameter_2_dbdata(value, "value")
    return f(obj_name, new_value)


def __Database__generic_delete_attr_pipe_property(self, obj_name, value, f):
    """internal usage for class or device attribute and pipe properties."""
    if isinstance(value, DbData):
        f(obj_name, value)
    elif is_non_str_seq(value):
        f(obj_name, seq_2_DbData(value))
    elif isinstance(value, collections.abc.Mapping):
        for attr_pipe_name, properties in value.items():
            new_value = DbData()
            new_value.append(DbDatum(attr_pipe_name))
            for prop in properties:
                new_value.append(DbDatum(prop))
            f(obj_name, new_value)
    else:
        raise TypeError(
            "Value must be a string, tango.DbDatum, "
            "tango.DbData, a sequence or a dictionary"
        )


def __Database__put_property(self, obj_name, value):
    """
    put_property(self, obj_name, value) -> None

        Insert or update a list of properties for the specified object.

    Parameters :
        - obj_name : (str) object name
        - value : can be one of the following:

            1. DbDatum - single property data to be inserted
            2. DbData - several property data to be inserted
            3. sequence<DbDatum> - several property data to be inserted
            4. dict<str, DbDatum> - keys are property names and value has data to be inserted
            5. dict<str, obj> - keys are property names and str(obj) is property value
            6. dict<str, seq<str>> - keys are property names and value has data to be inserted
    Return     : None

    Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """

    return __Database__generic_put_property(self, obj_name, value, self._put_property)


def __Database__get_property(self, obj_name, value):
    """
    get_property(self, obj_name, value) -> dict<str, seq<str>>

            Query the database for a list of object (i.e non-device) properties.

        Parameters :
            - obj_name : (str) object name
            - value : can be one of the following:

                1. str [in] - single property data to be fetched
                2. DbDatum [in] - single property data to be fetched
                3. DbData [in,out] - several property data to be fetched
                   In this case (direct C++ API) the DbData will be filled with
                   the property values
                4. sequence<str> [in] - several property data to be fetched
                5. sequence<DbDatum> [in] - several property data to be fetched
                6. dict<str, obj> [in,out] - keys are property names
                   In this case the given dict values will be changed to contain
                   the several property values

        Return     : a dictionary which keys are the property names the value
                     associated with each key being a a sequence of strings being
                     the property value.

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_get_property(self, obj_name, value, self._get_property)


def __Database__get_property_forced(self, obj_name, value):
    return __Database__generic_get_property(
        self, obj_name, value, self._get_property_forced
    )


__Database__get_property_forced.__doc__ = __Database__get_property.__doc__


def __Database__delete_property(self, obj_name, value):
    """
    delete_property(self, obj_name, value) -> None

            Delete a the given of properties for the specified object.

        Parameters :
            - obj_name : (str) object name
            - value : can be one of the following:

                1. str [in] - single property data to be deleted
                2. DbDatum [in] - single property data to be deleted
                3. DbData [in] - several property data to be deleted
                4. sequence<string> [in]- several property data to be deleted
                5. sequence<DbDatum> [in] - several property data to be deleted
                6. dict<str, obj> [in] - keys are property names to be deleted
                   (values are ignored)
                7. dict<str, DbDatum> [in] - several DbDatum.name are property names
                   to be deleted (keys are ignored)
        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_delete_property(
        self, obj_name, value, self._delete_property
    )


def __Database__get_device_property(self, dev_name, value):
    """
    get_device_property(self, dev_name, value) -> dict<str, seq<str>>

        Query the database for a list of device properties.

        Parameters :
            - dev_name : (str) object name
            - value : can be one of the following:

                1. str [in] - single property data to be fetched
                2. DbDatum [in] - single property data to be fetched
                3. DbData [in,out] - several property data to be fetched
                   In this case (direct C++ API) the DbData will be filled with
                   the property values
                4. sequence<str> [in] - several property data to be fetched
                5. sequence<DbDatum> [in] - several property data to be fetched
                6. dict<str, obj> [in,out] - keys are property names
                   In this case the given dict values will be changed to contain
                   the several property values

        Return     : a dictionary which keys are the property names the value
                    associated with each key being a a sequence of strings being the
                    property value.

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_get_property(
        self, dev_name, value, self._get_device_property
    )


def __Database__put_device_property(self, dev_name, value):
    """
    put_device_property(self, dev_name, value) -> None

        Insert or update a list of properties for the specified device.

        Parameters :
            - dev_name : (str) object name
            - value : can be one of the following:

                1. DbDatum - single property data to be inserted
                2. DbData - several property data to be inserted
                3. sequence<DbDatum> - several property data to be inserted
                4. dict<str, DbDatum> - keys are property names and value has data to be inserted
                5. dict<str, obj> - keys are property names and str(obj) is property value
                6. dict<str, seq<str>> - keys are property names and value has data to be inserted
        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_put_property(
        self, dev_name, value, self._put_device_property
    )


def __Database__delete_device_property(self, dev_name, value):
    """
    delete_device_property(self, dev_name, value) -> None

        Delete a the given of properties for the specified device.

        Parameters :
            - dev_name : (str) object name
            - value : can be one of the following:

                1. str [in] - single property data to be deleted
                2. DbDatum [in] - single property data to be deleted
                3. DbData [in] - several property data to be deleted
                4. sequence<str> [in]- several property data to be deleted
                5. sequence<DbDatum> [in] - several property data to be deleted
                6. dict<str, obj> [in] - keys are property names to be deleted (values are ignored)
                7. dict<str, DbDatum> [in] - several DbDatum.name are property names to be deleted (keys are ignored)

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_delete_property(
        self, dev_name, value, self._delete_device_property
    )


def __Database__get_device_property_list(self, dev_name, wildcard, array=None):
    """
    get_device_property_list(self, dev_name, wildcard, array=None) -> DbData

            Query the database for a list of properties defined for the
            specified device and which match the specified wildcard.
            If array parameter is given, it must be an object implementing de 'append'
            method. If given, it is filled with the matching property names. If not given
            the method returns a new DbDatum containing the matching property names.

        New in PyTango 7.0.0

        Parameters :
            - dev_name : (str) device name
            - wildcard : (str) property name wildcard
            - array : [out] (sequence) (optional) array that
                          will contain the matching property names.
        Return     : if container is None, return is a new DbDatum containing the
                     matching property names. Otherwise returns the given array
                     filled with the property names

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device"""
    if array is None:
        return self._get_device_property_list(dev_name, wildcard)
    elif isinstance(array, StdStringVector):
        return self._get_device_property_list(dev_name, wildcard, array)
    elif is_non_str_seq(array):
        res = self._get_device_property_list(dev_name, wildcard)
        for e in res:
            array.append(e)
        return array


def __Database__get_device_attribute_property(self, dev_name, value):
    """
    get_device_attribute_property(self, dev_name, value) -> dict<str, dict<str, seq<str>>>

            Query the database for a list of device attribute properties for the
            specified device. The method returns all the properties for the specified
            attributes.

        Parameters :
            - dev_name : (string) device name
            - value : can be one of the following:

                1. str [in] - single attribute properties to be fetched
                2. DbDatum [in] - single attribute properties to be fetched
                3. DbData [in,out] - several attribute properties to be fetched
                   In this case (direct C++ API) the DbData will be filled with
                   the property values
                4. sequence<str> [in] - several attribute properties to be fetched
                5. sequence<DbDatum> [in] - several attribute properties to be fetched
                6. dict<str, obj> [in,out] - keys are attribute names
                   In this case the given dict values will be changed to contain the
                   several attribute property values

        Return     :  a dictionary which keys are the attribute names the
                             value associated with each key being a another
                             dictionary where keys are property names and value is
                             a DbDatum containing the property value.

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_get_attr_pipe_property(
        self, dev_name, value, self._get_device_attribute_property
    )


def __Database__get_device_pipe_property(self, dev_name, value):
    """
    get_device_pipe_property(self, dev_name, value) -> dict<str, dict<str, seq<str>>>

            Query the database for a list of device pipe properties for the
            specified device. The method returns all the properties for the specified
            pipes.

        Parameters :
            - dev_name : (string) device name
            - value : can be one of the following:

                1. str [in] - single pipe properties to be fetched
                2. DbDatum [in] - single pipe properties to be fetched
                3. DbData [in,out] - several pipe properties to be fetched
                   In this case (direct C++ API) the DbData will be filled with
                   the property values
                4. sequence<str> [in] - several pipe properties to be fetched
                5. sequence<DbDatum> [in] - several pipe properties to be fetched
                6. dict<str, obj> [in,out] - keys are pipe names
                   In this case the given dict values will be changed to contain the
                   several pipe property values

        Return     :  a dictionary which keys are the pipe names the
                             value associated with each key being a another
                             dictionary where keys are property names and value is
                             a DbDatum containing the property value.

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_get_attr_pipe_property(
        self, dev_name, value, self._get_device_pipe_property
    )


def __Database__put_device_attribute_property(self, dev_name, value):
    """
    put_device_attribute_property( self, dev_name, value) -> None

            Insert or update a list of properties for the specified device.

        Parameters :
            - dev_name : (str) device name
            - value : can be one of the following:

                1. DbData - several property data to be inserted
                2. sequence<DbDatum> - several property data to be inserted
                3. dict<str, dict<str, obj>> keys are attribute names and value being another
                   dictionary which keys are the attribute property names and the value
                   associated with each key being seq<str> or tango.DbDatum.

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_put_attr_pipe_property(
        self, dev_name, value, self._put_device_attribute_property
    )


def __Database__put_device_pipe_property(self, dev_name, value):
    """
    put_device_pipe_property( self, dev_name, value) -> None

            Insert or update a list of properties for the specified device.

        Parameters :
            - dev_name : (str) device name
            - value : can be one of the following:

                1. DbData - several property data to be inserted
                2. sequence<DbDatum> - several property data to be inserted
                3. dict<str, dict<str, obj>> keys are pipe names and value being another
                   dictionary which keys are the pipe property names and the value
                   associated with each key being seq<str> or tango.DbDatum.

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_put_attr_pipe_property(
        self, dev_name, value, self._put_device_pipe_property
    )


def __Database__delete_device_attribute_property(self, dev_name, value):
    """
    delete_device_attribute_property(self, dev_name, value) -> None

            Delete a list of attribute properties for the specified device.

        Parameters :
            - devname : (str) device name
            - propnames : can be one of the following:

                1. DbData [in] - several property data to be deleted
                2. sequence<str> [in]- several property data to be deleted
                3. sequence<DbDatum> [in] - several property data to be deleted
                4. dict<str, seq<str>> with each key an attribute name and the value a list of attribute property names to delete from that attribute

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_delete_attr_pipe_property(
        self, dev_name, value, self._delete_device_attribute_property
    )


def __Database__delete_device_pipe_property(self, dev_name, value):
    """
    delete_device_pipe_property(self, dev_name, value) -> None

            Delete a list of pipe properties for the specified device.

        Parameters :
            - devname : (string) device name
            - propnames : can be one of the following:

                1. DbData [in] - several property data to be deleted
                2. sequence<str> [in]- several property data to be deleted
                3. sequence<DbDatum> [in] - several property data to be deleted
                3. dict<str, seq<str>> with each key a pipe name and the value a list of pipe property names to delete from that pipe

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_delete_attr_pipe_property(
        self, dev_name, value, self._delete_device_pipe_property
    )


def __Database__get_class_property(self, class_name, value):
    """
    get_class_property(self, class_name, value) -> dict<str, seq<str>>

            Query the database for a list of class properties.

        Parameters :
            - class_name : (str) class name
            - value : can be one of the following:

                1. str [in] - single property data to be fetched
                2. tango.DbDatum [in] - single property data to be fetched
                3. tango.DbData [in,out] - several property data to be fetched
                   In this case (direct C++ API) the DbData will be filled with
                   the property values
                4. sequence<str> [in] - several property data to be fetched
                5. sequence<DbDatum> [in] - several property data to be fetched
                6. dict<str, obj> [in,out] - keys are property names
                   In this case the given dict values will be changed to contain
                   the several property values

        Return     : a dictionary which keys are the property names the value
                     associated with each key being a a sequence of strings being the
                     property value.

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_get_property(
        self, class_name, value, self._get_class_property
    )


def __Database__put_class_property(self, class_name, value):
    """
    put_class_property(self, class_name, value) -> None

            Insert or update a list of properties for the specified class.

        Parameters :
            - class_name : (str) class name
            - value : can be one of the following:

                1. DbDatum - single property data to be inserted
                2. DbData - several property data to be inserted
                3. sequence<DbDatum> - several property data to be inserted
                4. dict<str, DbDatum> - keys are property names and value has data to be inserted
                5. dict<str, obj> - keys are property names and str(obj) is property value
                6. dict<str, seq<str>> - keys are property names and value has data to be inserted
        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_put_property(
        self, class_name, value, self._put_class_property
    )


def __Database__delete_class_property(self, class_name, value):
    """
    delete_class_property(self, class_name, value) -> None

            Delete a the given of properties for the specified class.

        Parameters :
            - class_name : (str) class name
            - value : can be one of the following:

                1. str [in] - single property data to be deleted
                2. DbDatum [in] - single property data to be deleted
                3. DbData [in] - several property data to be deleted
                4. sequence<str> [in]- several property data to be deleted
                5. sequence<DbDatum> [in] - several property data to be deleted
                6. dict<str, obj> [in] - keys are property names to be deleted
                   (values are ignored)
                7. dict<str, DbDatum> [in] - several DbDatum.name are property names
                   to be deleted (keys are ignored)

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_delete_property(
        self, class_name, value, self._delete_class_property
    )


def __Database__get_class_attribute_property(self, class_name, value):
    """
    get_class_attribute_property( self, class_name, value) -> dict<str, dict<str, seq<str>>

            Query the database for a list of class attribute properties for the
            specified class. The method returns all the properties for the specified
            attributes.

        Parameters :
            - class_name : (str) class name
            - propnames : can be one of the following:

                1. str [in] - single attribute properties to be fetched
                2. DbDatum [in] - single attribute properties to be fetched
                3. DbData [in,out] - several attribute properties to be fetched
                   In this case (direct C++ API) the DbData will be filled with the property
                   values
                4. sequence<str> [in] - several attribute properties to be fetched
                5. sequence<DbDatum> [in] - several attribute properties to be fetched
                6. dict<str, obj> [in,out] - keys are attribute names
                   In this case the given dict values will be changed to contain the several
                   attribute property values

        Return     : a dictionary which keys are the attribute names the
                     value associated with each key being a another
                     dictionary where keys are property names and value is
                     a sequence of strings being the property value.

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_get_attr_pipe_property(
        self, class_name, value, self._get_class_attribute_property
    )


def __Database__put_class_attribute_property(self, class_name, value):
    """
    put_class_attribute_property(self, class_name, value) -> None

            Insert or update a list of properties for the specified class.

        Parameters :
            - class_name : (str) class name
            - propdata : can be one of the following:

                1. tango.DbData - several property data to be inserted
                2. sequence<DbDatum> - several property data to be inserted
                3. dict<str, dict<str, obj>> keys are attribute names and value
                   being another dictionary which keys are the attribute property
                   names and the value associated with each key being seq<str> or
                   tango.DbDatum

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed, DevFailed from device (DB_SQLError)
    """
    return __Database__generic_put_attr_pipe_property(
        self, class_name, value, self._put_class_attribute_property
    )


def __Database__delete_class_attribute_property(self, class_name, value):
    """
    delete_class_attribute_property(self, class_name, value) -> None

            Delete a list of attribute properties for the specified class.

        Parameters :
            - class_name : (str) class name
            - propnames : can be one of the following:

                1. DbData [in] - several property data to be deleted
                2. sequence<str> [in]- several property data to be deleted
                3. sequence<DbDatum> [in] - several property data to be deleted
                4. dict<str, seq<str>> keys are attribute names and value being a
                   list of attribute property names

        Return     : None

        Throws     : ConnectionFailed, CommunicationFailed
                     DevFailed from device (DB_SQLError)"""
    return __Database__generic_delete_attr_pipe_property(
        self, class_name, value, self._delete_class_attribute_property
    )


def __Database__get_service_list(self, filter=".*"):
    import re

    data = self.get_property("CtrlSystem", "Services")
    res = {}
    filter_re = re.compile(filter)
    for service in data["Services"]:
        service_name, service_value = service.split(":")
        if filter_re.match(service_name) is not None:
            res[service_name] = service_value
    return res


def __Database__str(self):
    return f"Database({self.get_db_host()}, {self.get_db_port()})"


def __init_Database():
    Database.add_server = _trace_client(__Database__add_server)
    Database.export_server = _trace_client(__Database__export_server)
    Database.put_property = _trace_client(__Database__put_property)
    Database.get_property = _trace_client(__Database__get_property)
    Database.get_property_forced = _trace_client(__Database__get_property_forced)
    Database.delete_property = _trace_client(__Database__delete_property)
    Database.get_device_property = _trace_client(__Database__get_device_property)
    Database.put_device_property = _trace_client(__Database__put_device_property)
    Database.delete_device_property = _trace_client(__Database__delete_device_property)
    Database.get_device_property_list = _trace_client(
        __Database__get_device_property_list
    )
    Database.get_device_attribute_property = _trace_client(
        __Database__get_device_attribute_property
    )
    Database.put_device_attribute_property = _trace_client(
        __Database__put_device_attribute_property
    )
    Database.delete_device_attribute_property = _trace_client(
        __Database__delete_device_attribute_property
    )
    Database.get_class_property = _trace_client(__Database__get_class_property)
    Database.put_class_property = _trace_client(__Database__put_class_property)
    Database.delete_class_property = _trace_client(__Database__delete_class_property)
    Database.get_class_attribute_property = _trace_client(
        __Database__get_class_attribute_property
    )
    Database.put_class_attribute_property = _trace_client(
        __Database__put_class_attribute_property
    )
    Database.delete_class_attribute_property = _trace_client(
        __Database__delete_class_attribute_property
    )
    Database.get_service_list = _trace_client(__Database__get_service_list)
    Database.__str__ = __Database__str
    Database.__repr__ = __Database__str


def db_init():
    __init_DbDatum()
    __init_Database()