forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkdb.i
57 lines (47 loc) · 1.18 KB
/
kdb.i
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
/**
* @file
*
* @brief
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
%module kdb
#pragma SWIG nowarn=317 // Disable warning: Specialization of non-template
%include "../python/kdb.i"
/* python2 compat
%pythonbegin %{
from __future__ import print_function
%}
*/
/*
* python2 doesn't have a binary datatype
* so we overwrite the __init__ to handle KEY_VALUE/BINARY
*/
%pythoncode %{
Key.__oldinit__ = Key.__init__
def __Key_new_init__(self, *args):
passed = []
value = None
if len(args):
args = iter(args)
passed.append(next(args))
for arg in args:
if arg == KEY_VALUE:
value = next(args)
else:
passed.append(arg)
self.__oldinit__(*passed)
if value:
if self.isBinary():
self.binary = value
else:
self.string = value
Key.__init__ = __Key_new_init__
%}
/* more "binary datatype missing"-stuff */
%pythoncode %{
del Key.set
Key.value = property(Key.get, None, None, "Key value")
Key.string = property(Key._getString, Key._setString, None, "Key string value")
Key.binary = property(Key._getBinary, Key._setBinary, None, "Key binary value")
%}